```python
def find_last_occurrence(A, x):
    """
    Finds the index of the last occurrence of a given number in a sorted array.

    Args:
        A: A sorted list of numbers.
        x: The number to search for.

    Returns:
        The index of the last occurrence of x in A, or -1 if x is not found.
    """
    low = 0
    high = len(A) - 1
    result = -1

    while low <= high:
        mid = low + (high - low) // 2
        
        if A[mid] == x:
            # Found an occurrence. It could be the last one.
            # Store this index and continue searching in the right half
            # to find a later occurrence.
            result = mid
            low = mid + 1
        elif A[mid] < x:
            # The target must be in the right half of the array.
            low = mid + 1
        else:  # A[mid] > x
            # The target must be in the left half of the array.
            high = mid - 1
            
    return result
```