/* 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 main() { int z, k; long long x, y, c; z = __VERIFIER_nondet_int(); assume_abort_if_not(z>=0 && z<=100); k = __VERIFIER_nondet_int(); assume_abort_if_not(k>=0 && k<=100); x = 1; y = 1; c = 1; /*@ loop invariant (((x + ((__int128) z * y)) == (((__int128) z * x) + 1))); @*/ while (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; }