/* 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 (((\old(counter) == 0) && (((((((__int128) z * x) + (((unsigned __int128) 18446744073709551615U * y) * az)) + a) + ((unsigned __int128) 18446744073709551615U * x)) % ((unsigned __int128) 1 << 64)) == 0))); @*/ while (counter++<2) { __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; }