Describe how you would use binary search in a rotated sorted array. Implement search_rotated(nums, target), returning the index of target or -1 if it is absent. Assume nums contains distinct integers and was formed by rotating an ascending array; aim for O(log n) time and O(1) extra space.
def search_rotated(nums, target):