use bool.Bool
use int.Int

val randomb () : bool

val ref c0 : int

val ref s0 : bool
val ref s1 : bool
val ref s2 : bool
val ref serr : bool


let c [@bddinfer] ()
  requires { s0 = True}
  requires { s1 = serr = False}
  requires { c0 = 0 }
  diverges
  =
   while (not serr) do
     invariant { c0 <= 43 }

      if s1 then c0 <- c0 +1;
      (* direct call to randomb() not handled by bdd-infer
        -> if we write "if (s0 && randomb())" below, we have the following message:

	"BDD-infer failure: unsupported feature, unsupported feature: simple_expr_to_why1_expr: SEseq"

	*)

      if(s0 && randomb()) then (s0 <- false; s1 <- true; c0 <- 0)
      else if(s1 && (c0 > 42)) then (s1 <- false; serr <- true (* works if "break" here *))

 done
