/* Geometric Series computes x = sum(z^k)[k=0..k-1], y = z^(k-1) */ void abort() { }; extern void abort(); extern int __VERIFIER_nondet_int(); void assume_abort_if_not(int cond) { if(!cond) {abort();} } /*@ requires ((1 <= cond)) && (cond != 0); ensures ((1 <= cond)) && (1); @*/ void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: {/*@ assert(0); */;} } return; } int counter = 0; /*@ requires ((counter == 0)); ensures ((\old(counter) == 0)); @*/ int main() { int z, k; unsigned long long x, y, c; z = __VERIFIER_nondet_int(); k = __VERIFIER_nondet_int(); x = 1; y = 1; c = 1; /*@ loop invariant ((((((y == 1) && (x == 1)) && (counter == 0)) || (((z == y) && (1 <= counter)) && (x == ((long long) z + 1)))) && (\old(counter) == 0))); @*/ while (counter++<1) { __VERIFIER_assert(1 + x*z - x - z*y == 0); if (!(c < k)) break; c = c + 1; x = x * z + 1; y = y * z; } __VERIFIER_assert(1 + x*z - x - z*y == 0); return 0; }