summary refs log tree commit diff
path: root/proto
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-07-10 03:16:39 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:27 -0400
commit116f35a44a2f781646dd252a03a3a94ffdcbad5e (patch)
treecd1a4dd61c3ba27ddd60f3149b10f243c87e282f /proto
parent037c716b6514cc717b7208457fb72085e4c278ab (diff)
downloadroux-116f35a44a2f781646dd252a03a3a94ffdcbad5e.tar.gz
add c version of some tests
Diffstat (limited to 'proto')
-rw-r--r--proto/ctests/eucl.c17
-rw-r--r--proto/ctests/pspill.c20
-rw-r--r--proto/ctests/psum.c13
3 files changed, 50 insertions, 0 deletions
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 <stdio.h>
+
+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;
+}