Easy to see that t in this code is coordinate of the lower point of some "theeth of the saw" on the graf x^2 mod p. (t1 upper)
In second cycle we just make jumps to next such "theeth" and go on. Curiosly, this process have two outcome  some closed loop, ring, and zero, or sub sqrt value of t^2 mod p one "jump" before.
I dont known, new or old one this heuristic. But its look like a sieve for n values, and hypothetically can point out on the some dependency in x^2 mod p
