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

exp([[ref(loc(1)),num(int(A))],[[num(int(B)),num(int(C))]]],[ref(loc(2)),[[num(int(B)),num(int(C))],[num(int(1)),num(int(1))]]]) :-
        A=<0 .
exp([[ref(loc(1)),num(int(A))],[[num(int(B)),num(int(C))]]],[ref(loc(2)),[[num(int(B)),num(int(C))],[num(int(D)),num(int(E))]]]) :-
        A>0,
        D is 1*B,
        E is 1*C,
        F is A+ -1,
        F=<0 .
exp([[ref(loc(1)),num(int(A))],[[num(int(B)),num(int(C))]]],[D,E]) :-
        A>0,
        F is 1*B,
        G is 1*C,
        H is A+ -1,
        H>0,
        I is F*B,
        J is G*C,
        execute_notrace_1(B,C,H,I,J,E,_1,_2,_3,_4,D,_5) .

execute_notrace_1(A,B,C,D,E,[[num(int(A)),num(int(B))],[num(int(D)),num(int(E))]],_1,_2,_3,_4,ref(loc(2)),[]) :-
        F is C+ -1,
        F=<0 .
execute_notrace_1(A,B,C,D,E,F,G,H,I,J,K,L) :-
        M is C+ -1,
        M>0,
        N is D*A,
        O is E*B,
        execute_notrace_1(A,B,M,N,O,F,G,H,I,J,K,L) .


