shared state fsm in c