When you're trying to analyze the complexity of a recursive algorithm, it often helps to find some way in which the "size" of the inputs drop over time. For example, if you're analyzing a recursive factorial implementation, then you'd probably notice that the size of the input drops by one on each call, then use that to say that there are O(n) total calls and therefore that O(n) total work is done.
This recursive function is a bit tricky to analyze because it's not at all clear what quantity is decreasing over time. The value of the first and second arguments both can increase as the function runs, which is generally not a good thing when you're using recursion!
However, there is a useful observation here. Look at the value of the second argument to the recursive function. It's recomputed each time as
b = (a & b) << 1
which has a very interesting effect: the number of 0 bits at the end of the binary representation of b increases by at least one on each function call. To see this, imagine that b ends with k 0 bits. Computing a & b
will produce a number whose last k bits are zero, then shifting the result right by one step will increase the number of rightmost 0s by one.
At the same time, the algorithm will terminate when number of rightmost 0s in the binary representation of b exceeds the position of the leftmost 1 in the binary representation of a. To see why, note that we keep ANDing b with a, and as soon as the 1 bits in b get higher than the 1 bits in a the AND evaluates to 0 and the base case triggers.
Putting this together, we can see that the number of recursive calls made is bounded by the position of the highest 1 bit in the number a, since each iteration moves the 1 bits in b higher and higher and the recursion stops when those 1s move past the 1s in a.
So now the question is what that means from a big-O perspective. If you have a number n and write n in binary, the position of the highest 1 bit in n is O(log n), since the meaning of that bit grows exponentially as a function of time. Therefore, the runtime here is O(log n), where n is the maximum of the two inputs.