-- CHECKS THAT 31 PARAMETERS MAY BE PASSED

with Instrument;
use Instrument;

procedure C31pa2 is

    Add_Em : Integer;
    type An_Array_Type is array (1 .. 31) of Integer;
    X : An_Array_Type;
    type A_Composite_Type is
        record
            K : Integer;
            Xx : String (2 .. 5);
        end record;
    Y : array (1 .. 31) of A_Composite_Type;

    procedure Add_Em_Co (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R,
                         S, T, U, V, W, X, Y, Z, A1, A2, A3, A4, A5 : in out
                            A_Composite_Type) is
    begin
        A.K := B.K + C.K + D.K + E.K + F.K + G.K + H.K + I.K + J.K + K.K + L.K +
                  M.K + N.K + O.K + P.K + Q.K + R.K + S.K + T.K + U.K + V.K +
                  W.K + X.K + Y.K + Z.K + A1.K + A2.K + A3.K + A4.K + A5.K;
    end Add_Em_Co;

    function Add_Em_In
                (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q,
                 R, S, T, U, V, W, X, Y, Z, A1, A2, A3, A4, A5 : in Integer)
                return Integer is
    begin
        return A + B + C + D + E + F + G + H + I + J + K +
                  L + M + N + O + P + Q + R + S + T + U + V +
                  W + X + Y + Z + A1 + A2 + A3 + A4 + A5;
    end Add_Em_In;

    procedure Add_Em_Io (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R,
                         S, T, U, V, W, X, Y, Z, A1, A2, A3, A4, A5 : in out
                            Integer) is
    begin
        A := B + C + D + E + F + G + H + I + J + K + L + M + N + O + P + Q +
                R + S + T + U + V + W + X + Y + Z + A1 + A2 + A3 + A4 + A5;
    end Add_Em_Io;

begin
    Start ("C31PA2", " CHECKS PASSING OF 31 PARAMETERS");
    for I in 1 .. 1000 loop
        Add_Em := Add_Em_In (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
                             13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
                             23, 24, 25, 26, 27, 28, 29, 30, 31);
        if Add_Em /= 496 then
            Comment ("FAILED ADD_EM_IN = " & Integer'Image (Add_Em));
        end if;

        for I in 2 .. 31 loop
            X (I) := I;
        end loop;

        Add_Em_Io (X (1), X (2), X (3), X (4), X (5), X (6), X (7),
                   X (8), X (9), X (10), X (11), X (12), X (13),
                   X (14), X (15), X (16), X (17), X (18), X (19),
                   X (20), X (21), X (22), X (23), X (24), X (25),
                   X (26), X (27), X (28), X (29), X (30), X (31));
        if X (1) /= 495 then
            Comment ("FAILED  ADD_EM_IO");
        end if;

        for I in 2 .. 31 loop
            Y (I).K := I;
        end loop;

        Add_Em_Co (Y (1), Y (2), Y (3), Y (4), Y (5), Y (6), Y (7),
                   Y (8), Y (9), Y (10), Y (11), Y (12), Y (13),
                   Y (14), Y (15), Y (16), Y (17), Y (18), Y (19),
                   Y (20), Y (21), Y (22), Y (23), Y (24), Y (25),
                   Y (26), Y (27), Y (28), Y (29), Y (30), Y (31));
        if Y (1).K /= 495 then
            Comment ("FAILED  ADD_EM_CO IS " & Integer'Image (Y (1).K));
        end if;

    end loop;
    Stop;
end C31pa2;