#include <stdio.h>

typedef struct {
	int restart, fn1, fn;
} Fib;
#define FibCtor { 0, 1, 0 }

Fib * comain( Fib * f ) {
	static void * states[] = {&&s0, &&s1};
	goto *states[f->restart];
  s0: f->restart = 1;
	for ( ;; ) {
		return f;
	  s1:; int fn = f->fn + f->fn1;
		f->fn1 = f->fn; f->fn = fn;
	}
}
int main() {
	Fib f1 = FibCtor, f2 = FibCtor;
	for ( int i = 0; i < 10; i += 1 )
		printf( "%d %d\n", comain( &f1 )->fn, comain( &f2 )->fn );
}

// Local Variables: //
// tab-width: 4 //
// compile-command: "gcc-8 Fib3.c" //
// End: //
