// verifast_options{disable_overflow_check target:ILP32} /* Compute the floor of the square root of a natural number */ extern void abort(void);//@ requires true; //@ ensures true; extern void __assert_fail(const char *, const char *, unsigned int, const char *) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); void reach_error() //@ requires false; //@ ensures true; { __assert_fail("0", "sqrt1-ll.c", 5, "reach_error"); } extern int __VERIFIER_nondet_int(void);//@ requires true; //@ ensures true; extern void abort(void); void assume_abort_if_not(int cond) //@ requires true; //@ ensures true; { if(!cond) {abort();} } void __VERIFIER_assert(int cond) //@ requires (cond != 0); //@ ensures (cond != 0); { if (!(cond)) { ERROR: {reach_error();} } return; } int main() //@ requires module(sqrt1_ll__verifast_instrumented_modified, true); //@ ensures junk(); { int n; long long a, s, t; n = __VERIFIER_nondet_int(); a = 0; s = 1; t = 1; while (1)//@ invariant (((((a * 2) + (a * a)) + 1) == s) && (t == ((a * 2) + 1))); { __VERIFIER_assert(t == 2*a + 1); __VERIFIER_assert(s == (a + 1) * (a + 1)); __VERIFIER_assert(t*t - 4*s + 2*t + 1 == 0); // the above 2 should be equiv to if (!(s <= n)) break; a = a + 1; t = t + 2; s = s + t; } __VERIFIER_assert(t == 2 * a + 1); __VERIFIER_assert(s == (a + 1) * (a + 1)); __VERIFIER_assert(t*t - 4*s + 2*t + 1 == 0); return 0; }