--  A dispatching call of primitives that read and write objects of an enclosing subprogram
--  (up-level objects, passed as parameters): the dispatcher takes those every version of the
--  operation uses and passes each version its own (C392003: the LLVM verifier rejected the call
--  that left them out).
with Ada.Text_IO;
procedure Main is
   Count : Integer := 0;
   Total : Integer := 0;
   package Accounts is
      type Account is tagged null record;
      procedure Bump (A : Account);
      function Seen (A : Account) return Integer;
      type Savings is new Account with null record;
      overriding procedure Bump (A : Savings);
      overriding function Seen (A : Savings) return Integer;
   end Accounts;
   package body Accounts is
      procedure Bump (A : Account) is
      begin
         if Count < 100 then
            Count := Count + 1;
         end if;
      end Bump;
      function Seen (A : Account) return Integer is (Count);
      procedure Bump (A : Savings) is
      begin
         if Total < 100 then
            Total := Total + 10;
         end if;
      end Bump;
      function Seen (A : Savings) return Integer is (Total);
   end Accounts;
   procedure Use_It (A : Accounts.Account'Class) is
   begin
      Accounts.Bump (A);
      Ada.Text_IO.Put_Line (Integer'Image (Accounts.Seen (A)));
   end Use_It;
   X : Accounts.Account;
   Y : Accounts.Savings;
begin
   Use_It (X);
   Use_It (Y);
   Use_It (Y);
   Accounts.Bump (X);
   Ada.Text_IO.Put_Line (Integer'Image (Count) & Integer'Image (Total));
end Main;
