summaryrefslogtreecommitdiff
path: root/3/6_control/absdiff_goto.c
blob: dfcb3bec2b4b51ce2f945abc279ec3d0ade10d7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
}