// verifast_options{disable_overflow_check target:ILP32} /* Geometric Series computes x=(z-1)* sum(z^k)[k=0..k-1] , y = z^k returns 1+x-y == 0 */ 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", "geo1-ll.c", 9, "reach_error"); } extern int __VERIFIER_nondet_int(void);//@ requires true; //@ ensures true; extern void abort(void); void assume_abort_if_not(int cond) //@ requires integer(&counter, ?veri_req_counter) &*& (veri_req_counter == 0); //@ ensures integer(&counter, ?veri_ens_counter) &*& ((veri_ens_counter == veri_req_counter) && (veri_ens_counter == 0)); { if(!cond) {abort();} } void __VERIFIER_assert(int cond) //@ requires integer(&counter, ?veri_req_counter) &*& (cond == 1); //@ ensures integer(&counter, ?veri_ens_counter) &*& ((veri_ens_counter == veri_req_counter) && (cond == 1)); { if (!(cond)) { ERROR: {reach_error();} } return; } int counter = 0; int main() //@ requires module(geo1_ll_unwindbound1__verifast_instrumented_modified, true); //@ ensures junk(); { int z, k; //@ invariant integer(&counter, ?veri_req_counter) &*& (veri_req_counter == 0); unsigned long long x, y, c; z = __VERIFIER_nondet_int(); k = __VERIFIER_nondet_int(); assume_abort_if_not(z >= 1); assume_abort_if_not(k >= 1); x = 1; y = z; c = 1; while (counter++<1)//@ invariant integer(&counter, ?veri_inv_counter) &*& ((veri_req_counter == 0) && ((((z == y) && (x == 1)) && (veri_inv_counter == 0)) || ((1 <= veri_inv_counter) && ((((((z * x) + (18446744073709551615U * x)) + (18446744073709551615U * y)) + 1) % (1 < < 64)) <= 0)))); { __VERIFIER_assert(x*z - x - y + 1 == 0); if (!(c < k)) break; c = c + 1; x = x * z + 1; y = y * z; } //geo1 x = x * (z - 1); __VERIFIER_assert(1 + x - y == 0); return 0; }