// 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_valuebound100__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<=100); b = __VERIFIER_nondet_int(); assume_abort_if_not(b>=0 && b<=100); assume_abort_if_not(b >= 1); x = a; y = b; z = 0; while (1) //@ invariant (((((0 <= y) && ((z + (y * x)) == (b * a))) && (a <= 100)) && (0 <= a)) && (1 <= b)); { __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; }