1 extern void abort (void);
2 
3 static max;
4 
storemax(int i)5 static void __attribute__((noinline)) storemax (int i)
6 {
7   if (i > max)
8     max = i;
9 }
10 
CallFunctionRec(int (* fun)(int depth),int depth)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 
CallFunction(int (* fun)(int depth))21 static int CallFunction(int (*fun)(int depth)) {
22   return CallFunctionRec(fun, 1) && !fun(0);
23 }
24 
callback(int depth)25 static int callback(int depth) {
26   storemax (depth);
27   return depth != 0;
28 }
29 
main()30 int main() {
31   CallFunction(callback);
32   if (max != 10)
33     abort ();
34   return 0;
35 }
36