/* 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 <= \old(cond))) && (cond != 0); ensures ((1 <= \old(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, a, k; unsigned long long x, y, c; long long az; z = __VERIFIER_nondet_int(); a = __VERIFIER_nondet_int(); k = __VERIFIER_nondet_int(); x = a; y = 1; c = 1; az = (long long) a * z; /*@ loop invariant (((((((z == y) && (1 <= counter)) && (x == (((long long) a * z) + a))) && (((long long) a * z) == az)) || ((((y == 1) && (counter == 0)) && (a == x)) && (((long long) a * z) == az))) && (\old(counter) == 0))); @*/ while (counter++<1) { __VERIFIER_assert(z*x - x + a - az*y == 0); if (!(c < k)) break; c = c + 1; x = x * z + a; y = y * z; } __VERIFIER_assert(z*x - x + a - az*y == 0); return x; }