Obviously the second number has to be zero, since that's what the code checks at 0x08048d27
.
The first number has to be chosen such that the return value of func4
is also zero (see 0x08048d23
). If you look into func4
you can see that it is a binary search (explanation of a similar code here). When the item is found, it returns zero. Otherwise if it falls into the lower half, it returns 2*func4()
. Finally if it is in the higher half, it returns 2*func4()+1
.
Given that in this case the result has to be zero, that means the number has to be found while only traversing the lower ranges, since otherwise a +1
would creep into the result. Zero itself is a trivial solution since that will certainly be found at the bottom.
For sake of completeness, here is a walkthrough for the other possibilities. The first guess will be the midpoint in the range [0, 14]
, which is 7
. For the next step, we know the number must be less than 7
to get range [0, 6]
and that means midpoint 3
. Similarly, the next range is [0, 2]
with midpoint 1
. Finally we arrive at [0, 0]
, the trivial result.
TL;DR: The possible inputs are 0 0
, 1 0
, 3 0
and 7 0
.
Since there are versions of this with other expected results, here is some additional help: The return value actually spells out the low-high choices in binary, starting from the least significant bit. In the above example, we had all 0
bits, so all low choices. Suppose we have a result of 4
that is 100
in binary. Reading from the right, that means we need a lower, another lower and a final upper recursion. Following through the ranges, those map to [0, 6]
, [0, 2]
and [2, 2]
. So in this case 2
would be the solution.