Qualcomm Interview Question

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