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

% adapded from the `MacCarthy91` example of the Interproc analyzer
%   http://pop-art.inrialpes.fr/interproc/interprocweb.cgi
%
% /* exact semantics:
%    if (n>=101) then n-10 else 91 */
% proc MC(n:int) returns (r:int)
% var t1:int, t2:int;
% begin
%   if (n>100) then
%      r = n-10;
%   else
%      t1 = n + 11;
%      t2 = MC(t1);
%      r = MC(t2);
%   endif;
% end
%
% var
% a:int, b:int;
% begin
%   b = MC(a);
% end

:- entry mc(A,_B) : constraint([A >= 0]).
:- pred mc(A,B) : constraint([A >= 0]) => constraint([B >= 90, A =< B + 10]).

mc(N,R) :- N > 100,  R is N - 10.
mc(N,R) :-
        T1 is N + 11,
        mc(T1,T2),
        mc(T2,R).
