Cheap compare for cyclic terms [injective collation keys]

Since term_factorized/3 gives me a stack overflow, had to revert to a
custom factorize/3. Its even a little bit faster than term_factorized/3
for the left recursive test case:

/* using term_factorized/3 */
?- X = X-0-9-5-4-2, Y = Y-7-5-2,
    time((between(1,10000,_), rep_compare(_,X,Y), fail; true)).
% 4,149,998 inferences, 0.313 CPU in 0.296 seconds (105% CPU, 13279994 Lips)

/* using factorize/3 */
?- X = X-0-9-5-4-2, Y = Y-7-5-2,
    time((between(1,10000,_), rep_compare(_,X,Y), fail; true)).
% 1,059,998 inferences, 0.125 CPU in 0.123 seconds (101% CPU, 8479984 Lips)

Source code of the new take:

rep2.p.log (2,2 KB)