you can also remove that unpredictable branch in the loop if you want.
whatever_t *bisect(whatever_t *offset, size_t length, whatever_t x) { while(size_t midpoint = length / 2) { bool side = x < offset[midpoint]; midpoint &= side - 1; length >>= side; offset += midpoint; length -= midpoint; } return offset; }
you can also remove that unpredictable branch in the loop if you want.