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