with Instrument;
use Instrument;

------------------------
-- Parameter Association 10
------------------------

-- This test evaluates the code efficiency of a call to a procedure that
-- has ten formal in out parameters of the same generic formal type.

-- The procedure Param_Assoc is called in the test version using local
-- variables, Outer_1 .. Outer_10 as the actual parameters.  These
-- variables are referenced inside the procedure through the formal
-- parameters to ensure that the required parameter passing is performed.
-- In the noise version, the procedure Param_Assoc is parameterless
-- and references only the local variables, Local_1 .. Local_10, so that
-- there is no parameter passing overhead incurred,  Both the test and
-- noise versions perform the same camouflaged assignments to outer and
-- local variables, respectively.

-- The purpose of using local variables in the noise version is to
-- avoid uplevel referencing of the outer variables.  To prevent the
-- elimination of the local variables in the test version, the values
-- of the locals are used in the assignments just as they are in the
-- noise version.  The same number of assignments are performed in both
-- versions.

procedure Fpaad2 is
    package Pc_Cs is new Procs (Integer);
    use Pc_Cs;

    Outer_1, Outer_2, Outer_3, Outer_4, Outer_5 : Ref_T := new T'(Init);
    Outer_6, Outer_7, Outer_8, Outer_9, Outer_10 : Ref_T := new T'(Init);

    procedure Param_Assoc
                 (Formal_1 : in out Ref_T;         -- included in test version
                  Formal_2 : in out Ref_T;         -- included in test version
                  Formal_3 : in out Ref_T;         -- included in test version
                  Formal_4 : in out Ref_T;         -- included in test version
                  Formal_5 : in out Ref_T;         -- included in test version
                  Formal_6 : in out Ref_T;         -- included in test version
                  Formal_7 : in out Ref_T;         -- included in test version
                  Formal_8 : in out Ref_T;         -- included in test version
                  Formal_9 : in out Ref_T;         -- included in test version
                  Formal_10 : in out Ref_T)      -- included in test version
                  is

        Local_1, Local_2, Local_3, Local_4, Local_5 : T := Ident (Init);
        Local_6, Local_7, Local_8, Local_9, Local_10 : T := Ident (Init);

    begin

        Let (Formal_1.all, Ident (Formal_1.all));  -- included in test version
        Let (Formal_2.all, Ident (Formal_2.all));  -- included in test version
        Let (Formal_3.all, Ident (Formal_3.all));  -- included in test version
        Let (Formal_4.all, Ident (Formal_4.all));  -- included in test version
        Let (Formal_5.all, Ident (Formal_5.all));  -- included in test version
        Let (Formal_6.all, Ident (Formal_6.all));  -- included in test version
        Let (Formal_7.all, Ident (Formal_7.all));  -- included in test version
        Let (Formal_8.all, Ident (Formal_8.all));  -- included in test version
        Let (Formal_9.all, Ident (Formal_9.all));  -- included in test version
        Let (Formal_10.all, Ident (Formal_10.all)); -- included in test version
        --    Let(Local_1,   Ident(Local_1));           -- included in noise version
        --    Let(Local_2,   Ident(Local_2));           -- included in noise version
        --    Let(Local_3,   Ident(Local_3));           -- included in noise version
        --    Let(Local_4,   Ident(Local_4));           -- included in noise version
        --    Let(Local_5,   Ident(Local_5));           -- included in noise version
        --    Let(Local_6,   Ident(Local_6));           -- included in noise version
        --    Let(Local_7,   Ident(Local_7));           -- included in noise version
        --    Let(Local_8,   Ident(Local_8));           -- included in noise version
        --    Let(Local_9,   Ident(Local_9));           -- included in noise version
        --    Let(Local_10,  Ident(Local_10));          -- included in noise version

    end Param_Assoc;

begin
    Start ("FPAAD2",
           "Formal in/out Param. Assoc. w/10 param., Access type (Test)");
    for I in 1 .. 10000 loop

        Let (Global, Ident (Init));
        Param_Assoc (Formal_1 => Outer_1,        -- included in test version
                     Formal_2 => Outer_2,        -- included in test version
                     Formal_3 => Outer_3,        -- included in test version
                     Formal_4 => Outer_4,        -- included in test version
                     Formal_5 => Outer_5,        -- included in test version
                     Formal_6 => Outer_6,        -- included in test version
                     Formal_7 => Outer_7,        -- included in test version
                     Formal_8 => Outer_8,        -- included in test version
                     Formal_9 => Outer_9,        -- included in test version
                     Formal_10 => Outer_10);  -- included in test version
        --  Param_Assoc;                           -- included in noise version

    end loop;
    Stop;

end Fpaad2;