:- module( _, [lcm/2], [assertions , regtypes , basicmodes , nativeprops] ).

lcm([[num(int(A)),num(int(0))]],[num(int(B))]) :-
        C is A*0,
        A=\=0,
        B is C//A .
lcm([[num(int(0)),num(int(0))]],[refE(loc(1))]).
lcm([[num(int(A)),num(int(B))]],[num(int(C))]) :-
        B\=0,
        B=\=0,
        0 is A rem B,
        D is A*B,
        B=\=0,
        C is D//B .
lcm([[num(int(A)),num(int(B))]],[C]) :-
        B\=0,
        B=\=0,
        D is A rem B,
        D\=0,
        D=\=0,
        E is B rem D,
        execute_notrace_1(B,D,E,A,_1,_2,_3,_4,_5,C,_6) .

execute_notrace_1(A,B,0,C,[],_1,_2,_3,_4,num(int(D)),[]) :-
        E is C*A,
        B=\=0,
        D is E//B .
execute_notrace_1(A,0,0,B,[[]],_1,_2,_3,_4,refE(loc(1)),[]) :-
        _5 is B*A .
execute_notrace_1(A,B,C,D,E,F,G,H,I,J,K) :-
        C\=0,
        C=\=0,
        L is B rem C,
        execute_notrace_2(C,L,D,A,E,F,G,H,I,J,K) .

execute_notrace_2(A,0,B,C,[],_1,_2,_3,_4,num(int(D)),[]) :-
        E is B*C,
        A=\=0,
        D is E//A .
execute_notrace_2(0,0,A,B,[[]],_1,_2,_3,_4,refE(loc(1)),[]) :-
        _5 is A*B .
execute_notrace_2(A,B,C,D,E,F,G,H,I,J,K) :-
        B\=0,
        B=\=0,
        L is A rem B,
        execute_notrace_2(B,L,C,D,E,F,G,H,I,J,K) .


