Qualcomm interview question

Design a state machine from scratch and show me the code.