#include #define FibCtor { 0, 0, NULL } typedef struct { int fn1, fn2; void * next; } Fib; int fib( Fib * f ) { if ( __builtin_expect(f->next != 0, 1) ) goto *f->next; s1: f->fn1 = 0; f->next = &&s2; return f->fn1; s2: f->fn2 = f->fn1; f->fn1 = 1; f->next = &&s3; return f->fn1; s3:; int fn = f->fn1 + f->fn2; f->fn2 = f->fn1; f->fn1 = fn; return fn; } int main() { Fib f1 = FibCtor, f2 = FibCtor; for ( int i = 0; i < 10; i += 1 ) { printf( "%d %d\n", fib( &f1 ), fib( &f2 ) ); } } // Local Variables: // // tab-width: 4 // // compile-command: "gcc-8 Fib1.c" // // End: //