Coroutines and state machines are indeed equivalent. Here is an example of how to (and good reasons why) translate mechanically one into the other:
http://gabriel.kerneis.info/research/files/kerneis-boutier-2...
More context in my work about Continuation-Passing C: http://gabriel.kerneis.info/research/