Uhmmmm: That generates worse code.... Although it is functionally the same. (examine output by compiling with -a)
My example (2) uses registers throughout and does not have to do the comparison using a memory location.
But your code works too, so if you are happy, I am happy...
Note in the case of encryption it is better to hold code in registers and not overly access memory locations. That's why I wrote it that way. And it is faster.
It is only a minor point but it helps.