passing full test suite on -O3. Turns out returning from a function makes the second return do undefined things. Refactored to not do that...