forked from klee/klee
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d57e3f
commit ceb6f98
Showing
2 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* extended Euclid's algorithm */ | ||
extern void abort(void); | ||
extern void __assert_fail(const char *, const char *, unsigned int, const char *) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); | ||
void reach_error() { __assert_fail("0", "egcd3-ll.c", 4, "reach_error"); } | ||
extern int __VERIFIER_nondet_int(void); | ||
extern void abort(void); | ||
void assume_abort_if_not(int cond) { | ||
if(!cond) {abort();} | ||
} | ||
void __VERIFIER_assert(int cond) { | ||
if (!(cond)) { | ||
ERROR: | ||
{reach_error();} | ||
} | ||
return; | ||
} | ||
|
||
int counter = 0; | ||
int main() { | ||
int x, y; | ||
long long a, b, p, q, r, s; | ||
x = __VERIFIER_nondet_int(); | ||
y = __VERIFIER_nondet_int(); | ||
assume_abort_if_not(x >= 1); | ||
assume_abort_if_not(y >= 1); | ||
|
||
a = x; | ||
b = y; | ||
p = 1; | ||
q = 0; | ||
r = 0; | ||
s = 1; | ||
|
||
while (counter++<10) { | ||
if (!(b != 0)) | ||
break; | ||
long long c, k; | ||
c = a; | ||
k = 0; | ||
|
||
while (counter++<10) { | ||
if (!(c >= b)) | ||
break; | ||
long long d, v; | ||
d = 1; | ||
v = b; | ||
|
||
while (counter++<10) { | ||
__VERIFIER_assert(a == y * r + x * p); | ||
__VERIFIER_assert(b == x * q + y * s); | ||
__VERIFIER_assert(a == k * b + c); | ||
__VERIFIER_assert(v == b * d); | ||
|
||
if (!(c >= 2 * v)) | ||
break; | ||
d = 2 * d; | ||
v = 2 * v; | ||
} | ||
c = c - v; | ||
k = k + d; | ||
} | ||
|
||
a = b; | ||
b = c; | ||
long long temp; | ||
temp = p; | ||
p = q; | ||
q = temp - q * k; | ||
temp = r; | ||
r = s; | ||
s = temp - s * k; | ||
} | ||
__VERIFIER_assert(p*x - q*x + r*y - s*y == a); | ||
return 0; | ||
} | ||
|
||
// It requires bitwuzla because the script currently runs with bitwuzla solver backend | ||
// REQUIRES: bitwuzla | ||
// REQUIRES: target-x86_64 | ||
// RUN: %kleef --property-file=%S/coverage-error-call.prp --max-memory=7000000000 --max-cputime-soft=60 --32 --debug --write-ktests %s 2>&1 | FileCheck %s | ||
// CHECK: KLEE: WARNING: 100.00% Reachable Reachable |