summaryrefslogtreecommitdiff
path: root/3/6_control/absdiff_goto.c
diff options
context:
space:
mode:
Diffstat (limited to '3/6_control/absdiff_goto.c')
-rw-r--r--3/6_control/absdiff_goto.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/3/6_control/absdiff_goto.c b/3/6_control/absdiff_goto.c
new file mode 100644
index 0000000..dfcb3be
--- /dev/null
+++ b/3/6_control/absdiff_goto.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+
+// if (!t)
+// goto false;
+// then-
+// goto done;
+// false:
+// else-
+// goto done;
+// done:
+// ...
+long gotodiff_se(long x, long y)
+{
+ long result;
+ if (x >= y)
+ goto x_ge_y;
+ lt_cnt++;
+ result = y - x;
+ return result;
+
+x_get_y:
+ ge_cnt++;
+ result = x - y;
+ return result;
+}
+
+long gotodiff_se_alternate(long x, long y)
+{
+ long result;
+ if (x < y)
+ goto x_le_y;
+ ge_cnt++;
+ result = x - y;
+ return result;
+x_le_y:
+ lt_cnt++;
+ result = y - x;
+ return result;
+}