>>182
It can be useful for shifting back and forth between a bunch of different functions. IE, try doing this in a loop:
int f(int x, int y) {
if(x & 1) {
return f(y, x);
} else {
return g(x - y, x + y, x);
}
}
int g(int x, int y, int z) {
switch((x + y)%(z + 1)) {
case 16: return f(1, z);
case 1: return 6;
case 135: return g(1, 1, z);
default: return h(x + z);
}
}
int h(int x) {
if(x % 9 == 3) {
h(x % 7);
} else {
f(x % 7, x % 11);
}
}
But also imagine that these functions make sense. This might be hard to follow, but it is perfectly manageable to deal with these definitions mathematically. If you were to try to implement this using a single loop (and you can but it requires inlining it all into a single function), it becomes impossible to follow. It is still complicated of course, but the logic transfers so to speak have names, f g and h. Here is the loop, assuming the first call comes from f.
int f(int x, int y) {
if(x & 1) {
return f(y, x);
} else {
return g(x - y, x + y, x);
}
}
int g(int x, int y, int z) {
switch((x + y)%(z + 1)) {
case 16: return f(1, z);
case 1: return 6;
case 135: return g(1, 1, z);
default: return h(x + z);
}
}
int h(int x) {
if(x % 9 == 3) {
return h(x % 7);
} else {
return f(x % 7, x % 11);
}
}
--->>
int f(int fx, int fy) {
int gx, gy, gz, hx;
f_label:
if(x & 1) {
//return f(y, x);
int temp1 = y;
int temp2 = x;
x = temp1;
y = temp2;
goto f_label;
} else {
//return g(x - y, x + y, x);
gx = x - y;
gy = x + y;
gz = x;
goto g_label;
}
g_label:
switch((gx + gy)%(gz + 1)) {
case 16: //return f(1, z);
x = 1;
z = gz;
goto f_label;
case 1: return 6;
case 135: //return g(1, 1, z);
gx = 1;
gy = 1;
//gz is fixed.
goto g_label;
default: //return h(x + z);
hx = gx + gz;
goto h_label;
}
h_label:
if(hx % 9 == 3) {
//return h(x % 7);
hx = hx % 7;
goto h_label;
} else {
//return f(x % 7, x % 11);
fx = hx % 7;
fy = hx % 11;
goto f_label;
}
}
--->>