on mine, the registers at line 28 (at the point of evaluating whether to quit, as whether g == 0) go:
1 109900 126900 109900 109900 0 -17000 1
1 109917 126900 109917 109917 0 -16983 2
1 109934 126900 109934 109934 0 -16966 3
1 109951 126900 109951 109951 0 -16949 4
1 109968 126900 109968 109968 0 -16932 5
1 109985 126900 109985 109985 0 -16915 6
1 110002 126900 110002 110002 0 -16898 7
1 110019 126900 110019 110019 0 -16881 8
1 110036 126900 110036 110036 0 -16864 9
1 110053 126900 110053 110053 0 -16847 10
extrapolating in excel, they should (but obviously don't) finish
1 126815 126900 126815 126815 0 -85 996
1 126832 126900 126832 126832 0 -68 997
1 126849 126900 126849 126849 0 -51 998
1 126866 126900 126866 126866 0 -34 999
1 126883 126900 126883 126883 0 -17 1000
1 126900 126900 126900 126900 0 0 1001
but I put 1001 in and it was wrong (too high).
So have translated it to C++ and set it grinding away, hopefully it will have stopped by the time I come back from the gym