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

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

execute_notrace_1(A,B,C,D,_1,_2,[],_3,_4,_5,_6,num(int(E)),[]) :-
        _7 is A+ -1,
        B=<0,
        D=\=0,
        E is C//D .
execute_notrace_1(A,B,_1,0,_2,_3,[[]],_4,_5,_6,_7,refE(loc(1)),[]) :-
        _8 is A+ -1,
        B=<0 .
execute_notrace_1(A,B,C,D,E,F,G,H,I,J,K,L,M) :-
        N is A+ -1,
        B>0,
        O is D*B,
        P is C*N,
        Q is B+ -1,
        execute_notrace_1(N,Q,P,O,E,F,G,H,I,J,K,L,M) .


