#include <perms.h>

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

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

  //     2    %integer q,w,e,r,t,y { bump up indexes for easier debugging }

  int Q;
  int W;
  int E;
  int R;
  int T;
  int Y;

  //     3    %recordformat testfm(%integer one, two)

  struct TESTFM {
    union {
      struct {
        int ONE;
        int TWO;
      };
    };
  };

  //     4    %integer u,i,o,p

  int U;
  int I;
  int O;
  int P;

  //     5    %record (testfm) %array test(0:10)

  struct TESTFM TEST[11];
  struct _imp_dv TEST_dv = {TEST, sizeof(struct TESTFM) /*, dims, <bounds> */};

  //     6    %integer a,s,d,f

  int A;
  int S;
  int D;
  int F;

  //     7
  //     8    ! BUG TODO should generate struct testfm *pointer()
  //     9    ! but currently generates struct testfm pointer
  //    10    %record (testfm) %map pointer

  struct TESTFM *POINTER(void) {
    //    11      %result == test(q)

    return /*?*/ &TEST[Q];

    //    12    %end

  } /* end of POINTER */

  //    13    %record (testfm) normal

  struct TESTFM NORMAL;

  //    14    q = 5

  Q = 5;

  //    15    normal_two = p

  NORMAL.TWO = P;

  //    16    pointer_two = p

  POINTER()->TWO = P;

  //    17
  //    18  %endofprogram

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