| 1 |
extern void abort (void); |
| 2 |
|
| 3 |
static int max; |
| 4 |
|
| 5 |
static void __attribute__((noinline)) storemax (int i) |
| 6 |
{ |
| 7 |
if (i > max) |
| 8 |
max = i; |
| 9 |
} |
| 10 |
|
| 11 |
static int CallFunctionRec(int (*fun)(int depth), int depth) { |
| 12 |
if (!fun(depth)) { |
| 13 |
return 0; |
| 14 |
} |
| 15 |
if (depth < 10) { |
| 16 |
CallFunctionRec(fun, depth + 1); |
| 17 |
} |
| 18 |
return 1; |
| 19 |
} |
| 20 |
|
| 21 |
static int CallFunction(int (*fun)(int depth)) { |
| 22 |
return CallFunctionRec(fun, 1) && !fun(0); |
| 23 |
} |
| 24 |
|
| 25 |
static int callback(int depth) { |
| 26 |
storemax (depth); |
| 27 |
return depth != 0; |
| 28 |
} |
| 29 |
|
| 30 |
int main() { |
| 31 |
CallFunction(callback); |
| 32 |
if (max != 10) |
| 33 |
abort (); |
| 34 |
return 0; |
| 35 |
} |