Highly recommend seeing how a state machine in C can be converted to TLA+
https://lamport.azurewebsites.net/video/videos.html
https://lamport.azurewebsites.net/video/video2-script.pdf