Another thing of interest is how are the wave functions altered by this change of variables? The wave functions must change in response to this transformation if the energies of the Hamiltonian are to remain the same.

The author of the code appears to fluked out with this statement, since (0x01 != 0) == 1, which is exactly the bit that they were attempting to test against. Ironically, the != 0 was probably added for clarity, but if they had wanted to test against any other bit, the code wouldn’t have done what they expected, and “clarifying the statement” would have bugified it.