aboutsummaryrefslogtreecommitdiffstats
path: root/benchmarks/polybench-syn
diff options
context:
space:
mode:
authorNadesh Ramanathan <nadeshramanathan88@gmail.com>2020-11-11 11:06:20 +0000
committerNadesh Ramanathan <nadeshramanathan88@gmail.com>2020-11-11 11:06:20 +0000
commit47bad8cabe00a40723ce04852d02e7527473f3c3 (patch)
tree545569542dafd25e79a64fc8077afc0e92221957 /benchmarks/polybench-syn
parentf912a0913c8541cdb4f448a6cb9d4e4af822f356 (diff)
downloadvericert-47bad8cabe00a40723ce04852d02e7527473f3c3.tar.gz
vericert-47bad8cabe00a40723ce04852d02e7527473f3c3.zip
divider
Diffstat (limited to 'benchmarks/polybench-syn')
-rw-r--r--benchmarks/polybench-syn/include/misc.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/benchmarks/polybench-syn/include/misc.h b/benchmarks/polybench-syn/include/misc.h
new file mode 100644
index 0000000..55bb059
--- /dev/null
+++ b/benchmarks/polybench-syn/include/misc.h
@@ -0,0 +1,81 @@
+unsigned int modulo(unsigned int x, unsigned int y)
+{
+ unsigned int r0, q0, y0, y1;
+
+ r0 = x;
+ q0 = 0;
+ y0 = y;
+ y1 = y;
+ do
+ {
+ y1 = 2 * y1;
+ }
+ while (y1 <= x);
+ do
+ {
+ y1 = y1 / 2;
+ q0 = 2 * q0;
+ if (r0 >= y1)
+ {
+ r0 = r0 - y1;
+ q0 = q0 + 1;
+ }
+ }
+ while ((int)y1 != (int)y0);
+ return r0;
+}
+
+int smodulo(int N, int D) {
+ if (D < 0) {
+ if (N < 0)
+ return modulo(-N, -D);
+ else
+ return -modulo(N, -D);
+ } else {
+ if (N < 0)
+ return -modulo(-N, D);
+ else
+ return modulo(N, D);
+ }
+}
+
+unsigned int divider(unsigned int x, unsigned int y)
+{
+ unsigned int r0, q0, y0, y1;
+
+ r0 = x;
+ q0 = 0;
+ y0 = y;
+ y1 = y;
+ do
+ {
+ y1 = 2 * y1;
+ } while (y1 <= x);
+ do
+ {
+ y1 = y1 / 2;
+ q0 = 2 * q0;
+ if (r0 >= y1)
+ {
+ r0 = r0 - y1;
+ q0 = q0 + 1;
+ }
+ } while ((int)y1 != (int)y0);
+ return q0;
+}
+
+int sdivider(int N, int D) {
+ if (D < 0) {
+ if (N < 0)
+ return divider(-N, -D);
+ else
+ return -divider(N, -D);
+ } else {
+ if (N < 0)
+ return -divider(-N, D);
+ else
+ return divider(N, D);
+ }
+}
+
+