From 116f35a44a2f781646dd252a03a3a94ffdcbad5e Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Fri, 10 Jul 2015 03:16:39 -0400 Subject: add c version of some tests --- proto/ctests/eucl.c | 17 +++++++++++++++++ proto/ctests/pspill.c | 20 ++++++++++++++++++++ proto/ctests/psum.c | 13 +++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 proto/ctests/eucl.c create mode 100644 proto/ctests/pspill.c create mode 100644 proto/ctests/psum.c (limited to 'proto') diff --git a/proto/ctests/eucl.c b/proto/ctests/eucl.c new file mode 100644 index 0000000..fd2e9c9 --- /dev/null +++ b/proto/ctests/eucl.c @@ -0,0 +1,17 @@ +#include + +int main() +{ + int a = 123456; + int b = 32223; + int t; + + do { + t = a % b; + a = b; + b = t; + } while (b); + + printf("%d\n", a); + return 0; +} diff --git a/proto/ctests/pspill.c b/proto/ctests/pspill.c new file mode 100644 index 0000000..d3dfba8 --- /dev/null +++ b/proto/ctests/pspill.c @@ -0,0 +1,20 @@ +long f() { + long l00, l01, l02, l03, l04, l05, l06, l07, l08, l09, l10, l11, l12, l13; + + l00 = 42; + l01 = l00 + l00; + l02 = l00 + l01; + l03 = l00 + l02; + l04 = l00 + l03; + l05 = l00 + l04; + l06 = l00 + l05; + l07 = l06 + l06; + l08 = l05 + l07; + l09 = l04 + l08; + l10 = l03 + l09; + l11 = l02 + l10; + l12 = l01 + l11; + l13 = l00 + l12; + + return l13; +} diff --git a/proto/ctests/psum.c b/proto/ctests/psum.c new file mode 100644 index 0000000..4ea6a03 --- /dev/null +++ b/proto/ctests/psum.c @@ -0,0 +1,13 @@ +long f() { + long n, n0, s; + + s = 0; + n = 1234567; + for (;;) { + n0 = n - 1; + s = s + n; + if (!n0) break; + n = n0; + } + return s; +} -- cgit 1.4.1