What's happened here is that you've hit the runaway loop trap. There's a limitation in jit.gen that loops can only repeat up to 50001 times. To work around this currently you could duplicate the loop four times, but this might not always work. I've logged a feature request to make this loop limit configurable.
Full explanation: Gen generates machine code under the hood, which requires some extra precaution. For example, an infinite (or extremely large) loop could effectively lock up the system thread it is running in, which could make Max appear to have frozen. To prevent this happening, a loop will always exit after a certain number of iterations, which for jit.gen is currently set to 50001.