C2 Microsystems Interview Question

Some state machine related problems.