#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  %externalstring(7) P2 Version = "004"

_imp_string7 P2VERSION = _imp_str_init("004");

//     2
//     3  %recordformat Commfm(%integer i, j, k)

struct COMMFM {
  union {
    struct {
      int I;
      int J;
      int K;
    };
  };
};

//     4
//     5  %externalroutine PASS2(%record(Commfm)%name Interface)

void PASS2(struct COMMFM *INTERFACE) {
  //     6
  //     7     %recordformat Boundfm(%integer Lower, Upper, Mult)

  struct BOUNDFM {
    union {
      struct {
        int LOWER;
        int UPPER;
        int MULT;
      };
    };
  };

  //     8     %recordformat Afm(%integer Dimension,

  struct AFM {
    union {
      struct {
        int DIMENSION;
        int TOTALSIZE;
        int ZERODISPLACEMENT;
        int DV;
        int LOCALFRAME;
        int BASE;
        struct BOUNDFM BOUND[10];
      };
    };
  };

  //     9+                               Total Size,
  //    10+                               Zero Displacement,
  //    11+                               DV,
  //    12+                               Local Frame,
  //    13+                               Base,
  //    14+        %record(Boundfm)%array Bound(1:10))
  //    15
  //    16     %constrecord(Afm)%name A type == 0             {for NEW}

  const struct AFM *ATYPE = 0;

  //    17

  struct VARFM {
    union {
      struct {
        int FLAGS;
        unsigned char BASE;
        unsigned char PRIM;
        unsigned char TYPE;
        unsigned char FORM;
        union {
          struct {
            double RVAR;
          };
          struct {
            int DISP;
            union {
              struct {
                int EXTRA;
              };
              struct {
                struct AFM *ADATA;
              };
            };

          };
        };

        union {
          struct {
            int FORMAT;
          };
          struct {
            int SCALE;
          };
        };

        int AREA;
      };
    };
  };

  // typedef struct XFM XFM;
  // typedef struct DATAFM DATAFM;
  // typedef struct MEMBERFM MEMBERFM;
  // typedef struct STACKFM STACKFM;

  //    18     %recordformat Varfm(%integer Flags,
  //    19+                        %byte Base, Prim,
  //    20+                     %byte  Type, Form,
  //    21+                     (%longreal Rvar %or
  //    22+                      %integer Disp, (%integer Extra %or %record(Afm)%name Adata)),
  //    23+                     (%integer Format %or %integer Scale),
  //    24+                     %integer Area)
  //    25
  //    26
  //    27     %recordformatspec Stackfm
  //    28     %recordformat Olfm(%integer  Oper, %record(Stackfm)%name Link)

  struct OLFM {
    union {
      struct {
        int OPER;
        struct STACKFM *LINK;
      };
    };
  };

  //    29     %recordformat  Xfm(%integer Xsize, %record(Stackfm)%name Index)

  struct XFM {
    union {
      struct {
        int XSIZE;
        struct STACKFM *INDEX;
      };
    };
  };

  //    30
  //    31     %recordformat Datafm( %c

  struct DATAFM {
    union {
      struct {
        struct VARFM V;
        int VARNO;
        struct VARFM *FV;
        union {
          struct {
            int BIAS;
          };
          struct {
            unsigned char REG;
            unsigned char LABEL;
          };
        };

        struct STACKFM *PARAMS;
        struct STACKFM *RECORD;
        union {
          struct {
            int OPER;
            struct STACKFM *LINK;
          };
          struct {
            struct OLFM OPLINK;
          };
        };

        union {
          struct {
            int XSIZE;
            struct STACKFM *INDEX;
          };
          struct {
            struct XFM X;
          };
        };

      };
    };
  };

  //    32+            %record(Varfm)    V,
  //    33+            %integer Varno,
  //    34+            %record(Varfm)%name Fv,
  //    35+            (%integer Bias %or %byte Reg, Label),
  //    36+            %record(Stackfm)%name  Params, Record,
  //    37+            (%integer Oper, %record(Stackfm)%name Link %or %record(Olfm) Oplink),
  //    38+            (%integer Xsize, %record(Stackfm)%name Index %or %record(Xfm) X))
  //    39
  //    40     %recordformat Memberfm(%integer Const, Items,

  struct MEMBERFM {
    union {
      struct {
        int CONST;
        int ITEMS;
        struct STACKFM *A;
        struct STACKFM *B;
        struct MEMBERFM *LINK;
      };
    };
  };

  //    41+                           %record(Stackfm)%name A, B,
  //    42+                           %record(Memberfm)%name Link)
  //    43
  //    44     %constrecord(Memberfm)%name Memberfm Type == 0

  const struct MEMBERFM *MEMBERFMTYPE = 0;

  //    45
  //    46     %recordformat Stackfm( %c

  struct STACKFM {
    union {
      struct {
        struct VARFM V;
      };
      struct {
        struct DATAFM DATA;
      };
      struct {
        int FLAGS;
        unsigned char BASE;
        unsigned char PRIM;
        unsigned char TYPE;
        unsigned char FORM;
        union {
          struct {
            double RVAL;
          };
          struct {
            int RHIGH;
            int RLOW;
          };
          struct {
            union {
              struct {
                int DISP;
                union {
                  struct {
                    int EXTRA;
                  };
                  struct {
                    struct AFM *ADATA;
                  };
                };

              };
            };

            union {
              struct {
                int FORMAT;
              };
              struct {
                int SCALE;
              };
            };

            int AREA;
            int VARNO;
            union {
              struct {
                struct VARFM *FV;
              };
              struct {
                struct MEMBERFM *MEMBERS;
              };
            };

            union {
              struct {
                int BIAS;
              };
              struct {
                unsigned char REG;
                unsigned char LABEL;
              };
            };

            struct STACKFM *PARAMS;
            struct STACKFM *RECORD;
            union {
              struct {
                int OPER;
                struct STACKFM *LINK;
              };
              struct {
                struct OLFM OPLINK;
              };
            };

            union {
              struct {
                int XSIZE;
                struct STACKFM *INDEX;
              };
              struct {
                struct XFM X;
              };
            };

          };
        };

        struct STACKFM *USING;
        struct STACKFM *STACK;
      };
    };
  };

  //    47+       %record(Varfm)     V                   %or
  //    48+       %record(Datafm)    Data                %or
  //    49+       %integer Flags,
  //    50+       %byte Base, Prim,
  //    51+       %byte  Type, Form,
  //    52+       (%longreal Rval %or %integer Rhigh, Rlow %c
  //    53+         %or (%integer Disp, (%integer Extra %or %record(Afm)%name Adata)),
  //    54+       (%integer Format %or %integer Scale),
  //    55+       %integer Area,
  //    56+       %integer Varno,
  //    57+       (%record(Varfm)%name Fv %or %record(Memberfm)%name Members),
  //    58+       (%integer Bias %or %byte Reg, Label),
  //    59+       %record(Stackfm)%name     Params, Record,
  //    60+       (%integer  Oper, %record(Stackfm)%name Link  %or %record(Olfm) Oplink),
  //    61+       (%integer Xsize, %record(Stackfm)%name Index %or %record(Xfm) X)),
  //    62+       %record(Stackfm)%name          Using, Stack)
  //    63
  //    64     %constrecord(Stackfm)%name Stackfm Type == 0

  const struct STACKFM *STACKFMTYPE = 0;

  //    65
  //    66
  //    67     %routine Initialise(%integer Base, Form)

  void INITIALISE(int BASE, int FORM) {
    //    68
    //    69        Interface_j = 123;

    INTERFACE->J = 123;

    //    70
    //    71     %end

    return;
  } /* end of INITIALISE */

  // ?FORM unused
  // ?BASE unused
  //    72
  //    73  %end

  return;
} /* end of PASS2 */

// ?INITIALISE unused
// ?STACKFMTYPE unused
// ?MEMBERFMTYPE unused
// ?ATYPE unused
//    74
//    75  %endoffile