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