1 #include <stdio.h>
2 #include <stdlib.h>
3 
4 #if __STDC_VERSION__ >= 199901L
5 
6 #else
7 #define inline
8 #endif
9 
10 #define YCF_YIELD()
11 
12 static
13 inline
14 int fun(char x);
15 
16 
17 static
18 inline
fun(char x)19 int fun(char x){
20   x = x + 1; /* x == 2*/
21   {
22   int y;
23   y = 1;
24   {
25   int z = 1;
26   YCF_YIELD();
27   x = x + y + z; /* x == 4*/
28   return x;
29   }
30   }
31 }
32 
allocator(size_t size,void * context)33 void* allocator(size_t size, void* context){
34   (void)context;
35   return malloc(size);
36 }
37 
freer(void * data,void * context)38 void freer(void* data, void* context){
39   (void)context;
40   free(data);
41 }
42 
main(int argc,const char * argv[])43 int main( int argc, const char* argv[] )
44 {
45 #ifdef YCF_YIELD_CODE_GENERATED
46   void* wb = NULL;
47   long nr_of_reductions = 1;
48 #endif
49   int ret = 0;
50   (void)fun;
51 #ifdef YCF_YIELD_CODE_GENERATED
52   do{
53     ret = fun_ycf_gen_yielding(&nr_of_reductions,&wb,NULL,allocator,freer,NULL,0,NULL,1);
54     if(wb != NULL){
55       printf("TRAPPED\n");
56     }
57   }while(wb != NULL);
58   if(wb != NULL){
59     free(wb);
60   }
61 #else
62   fun(1);
63 #endif
64   printf("RETURNED %d\n", ret);
65   if(ret != 4){
66     return 1;
67   }else{
68     return 0;
69   }
70 }
71 
72