#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  %begin

int main(int argc, char **argv) { /*%begin*/
  _imp_initialise(argc, argv);

  //     2  %integer i

  int I;

  //     3  %recordformat vf(%integer x,y,%INTEGERARRAY A(1:10))

  struct VF {
    union {
      struct {
        int X;
        int Y;
        int A[10];
      };
    };
  };

  //     4  %record(vf) rr

  struct VF RR;

  //     5  %record(vf)%function recd(%integername n)

  struct VF RECD(int *N) {
    //     6     %record(vf)r

    struct VF R;

    //     7     r_x=n

    R.X = *N;

    //     8     r_y=n+1

    R.Y = *N + 1;

    //     9     r_a(1)=n

    R.A[0] = *N;

    //    10     %result=r

    return R;

    //    11  %end

  } /* end of RECD */

  //    12        i=10

  I = 10;

  //    13        RR=RECD(I)

  RR = RECD(/*?*/ &I);

  //    14        i=recd(i)_y

  I = RECD(/*?*/ &I).Y;

  //    15        %if i=11 %and rr_a(1)=10 %then printstring("TEST OK") %and %stop

  if (I != 11) goto L_0001;
  if (RR.A[0] != 10) goto L_0001;
  _imp_PRINTSTRING(_imp_str_literal("TEST OK"));
  _imp_stop(0);
L_0001:;

//    16        printstring("TEST FAILED")

  _imp_PRINTSTRING(_imp_str_literal("TEST FAILED"));

  //    17  %endofprogram

  _imp_stop(0);
  return 0;
end_0:;
}