// 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 integer(&counter, ?veri_req_counter) &*& (cond != 0); //@ ensures integer(&counter, ?veri_ens_counter) &*& ((cond != 0) && (veri_ens_counter == veri_req_counter)); { if (!(cond)) { ERROR: {reach_error();} } return; } int counter = 0; int main() //@ requires module(sqrt1_ll_unwindbound10__verifast_instrumented_modified, true); //@ ensures junk(); { int n; //@ invariant integer(&counter, ?veri_req_counter) &*& (veri_req_counter == 0); long long a, s, t; n = __VERIFIER_nondet_int(); a = 0; s = 1; t = 1; while (counter++<10)//@ invariant integer(&counter, ?veri_inv_counter) &*& ((((((a * 2) + (a * a)) + 1) == s) && (veri_req_counter == 0)) && (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; }