binsearch(x, S.0..m-1, present) is
{@$x \in Int \land  m$@@$>$@@$0 \land S.0..m-1 \in Int \land ordered.S(0..m-1)$@} 
@$\bb$@ Var i,j,h @$\in$@ Int
  initially i=0@$ \land $@j=m
  do {@$P$@}
  j @$\neq$@ i+1 @$\rightarrow$@ {@$P\land B$@}
             let h = (i+j)/2
              @$\text{\bf in}$@ {@$P\land B\land \ltlt ihj$@}
                 if x @$<$@ S.h @$\rightarrow$@ j:=h
                               {@$P$@}
                  @$\assync\ $@S.h@$ \le $@x @$\rightarrow$@ i:=h
                            {@$P$@}
             fi {@$P$@}
  od
  {@$P\land \neg B$@}
  {@$R$@}
  present:= x=S.i
@$\be$@
