Interesting to note that the description of how the flags and main loop works in practice makes the resulting program close to ladder logic,[0] still used in programming PLCs. Having used it the global state is annoying at first but does make the program easy to reason about.
The ladders inputs and outputs almost become like a set of invariants like you would find in a functional program, but the monad for state is implicit.
http://number-none.com/blow/john_carmack_on_inlined_code.htm...