Analytic derivation of comparisons in binary search

Numerous authors of programming texts and algorithms / data structures texts develop code for the binary search. The common implementation is one in which the loop contains two comparisons for three outcomes --- the key is to the left of the midpoint, to the right of the midpoint, or exactly at the midpoint --- Implementation A below.