// verifast_options{disable_overflow_check target:ILP32} /* shift_add algorithm for computing the product of two natural numbers */ extern void abort(void); //@ requires true; //@ ensures true; void reach_error() //@ requires false; //@ ensures true; {}extern int __VERIFIER_nondet_int(void); //@ requires true; //@ ensures true; void assume_abort_if_not(int cond) //@ requires true; //@ ensures (cond != 0); { if(!cond) {abort();} } void __VERIFIER_assert(int cond) //@ requires (1 <= cond); //@ ensures (1 <= cond); { if (!(cond)) { ERROR: {reach_error();} } return; } int main() //@ requires module(prodbin_ll_valuebound2__verifast_instrumented, true); //@ ensures junk(); { //@ open_module(); int a, b; long long x, y, z; a = __VERIFIER_nondet_int(); assume_abort_if_not(a>=0 && a<=2); b = __VERIFIER_nondet_int(); assume_abort_if_not(b>=0 && b<=2); assume_abort_if_not(b >= 1); x = a; y = b; z = 0; while (1) //@ invariant ((((((z == (b * a)) && (b <= 2)) && (1 <= b)) && (y == 0)) || (((((z == 0) && (y <= 2)) && (b == y)) && (1 <= y)) && (a == x))) || (((((z == 0) && (y == 1)) && ((a * 2) == x)) && ((b / 2) == 1)) && ((b % 2) != 1))); { __VERIFIER_assert(z + x * y == (long long) a * b); if (!(y != 0)) break; if (y % 2 == 1) { z = z + x; y = y - 1; } x = 2 * x; y = y / 2; } __VERIFIER_assert(z == (long long) a * b); return 0; }