As suggested in D50222, this has been refactored into a separate patch.
The undef and the infinite loop at the end cause this test to be translated unpredictably. In particular, the checked-for mpy disappears under certain legal optimizations (e.g. the one in D50222). Since the use of these constructs is not relevant to the behavior tested, according to the header comment, this change, suggested by @kparzysz, eliminates them.
It's the multiplication at line 25 that should only occur once. Could you change these two lines to