/* Geometric Series computes x=(z-1)* sum(z^k)[k=0..k-1] , y = z^k returns 1+x-y == 0 */ void abort() { }; extern void abort(); extern int __VERIFIER_nondet_int(); /*@ requires ((counter == 0)); ensures (((counter == \old(counter)) && (counter == 0))); @*/ void assume_abort_if_not(int cond) { if(!cond) {abort();} } /*@ requires ((cond == 1)) && (cond != 0); ensures (((counter == \old(counter)) && (cond == 1))) && (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(); assume_abort_if_not(z >= 1); assume_abort_if_not(k >= 1); x = 1; y = z; c = 1; /*@ loop invariant (((\old(counter) == 0) && ((((z == y) && (x == 1)) && (counter == 0)) || ((1 <= counter) && (((((((__int128) z * x) + ((unsigned __int128) 18446744073709551615U * x)) + ((unsigned __int128) 18446744073709551615U * y)) + 1) % ((unsigned __int128) 1 << 64)) <= 0))))); @*/ while (counter++<1) { __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; }