#include <stdio.h>

#define FIB_INIT { 0 }
typedef struct { int restart; int fn1, fn2; } Fib;
int fib( Fib * f ) {
	static void * states[] = { &&s0, &&s1, &&s2 };
	goto *states[f->restart];
  s0:
	f->fn1 = 0;
	f->restart = 1;
	return f->fn1;
  s1:
	f->fn2 = f->fn1;
	f->fn1 = 1;
	f->restart = 2;
	return f->fn1;
  s2:;
	int fn = f->fn1 + f->fn2;
	f->fn2 = f->fn1;
	f->fn1 = fn;
	return fn;
}
int main() {
	Fib f1 = FIB_INIT, f2 = FIB_INIT;
	for ( int i = 0; i < 10; i += 1 ) {
		printf( "%d %d\n", fib( &f1 ), fib( &f2 ) );
	}
}

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