#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  %constinteger Max Bound       =      7
//     2  %recordformat Boundfm(%integer Lower, Upper, Mult)

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

//     3  %recordformat Afm(%integer Dimension,

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

//     4+                            Total Size,
//     5+                            Zero Displacement,
//     6+                            DV,
//     7+                            Local Frame,
//     8+                            Base,
//     9+     %record(Boundfm)%array Bound(1:Max Bound))
//    10
//    11  %constrecord(Afm)%name A type == 0             {for NEW}

const struct AFM *ATYPE = 0;

//    12
//    13  %recordformat Varfm(%integer Flags,

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;
    };
  };
};

//    14+                     %byte Base, Prim,
//    15+                  %byte  Type, Form,
//    16+                  (%longreal Rvar %or
//    17+                   %integer Disp, (%integer Extra %or %record(Afm)%name Adata)),
//    18+                  (%integer Format %or %integer Scale),
//    19+                  %integer Area)
//    20
//    21
//    22  %recordformatspec Stackfm
//    23  %recordformat Olfm(%integer  Oper, %record(Stackfm)%name Link)

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

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

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

//    25
//    26  %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;
        };
      };

    };
  };
};

//    27+         %record(Varfm)    V,
//    28+         %integer Varno,
//    29+         %record(Varfm)%name Fv,
//    30+         (%integer Bias %or %byte Reg, Label),
//    31+         %record(Stackfm)%name  Params, Record,
//    32+         (%integer Oper, %record(Stackfm)%name Link %or %record(Olfm) Oplink),
//    33+         (%integer Xsize, %record(Stackfm)%name Index %or %record(Xfm) X))
//    34
//    35  %recordformat Memberfm(%integer Const, Items,

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

//    36+                        %record(Stackfm)%name A, B,
//    37+                        %record(Memberfm)%name Link)
//    38
//    39  %constrecord(Memberfm)%name Memberfm Type == 0

const struct MEMBERFM *MEMBERFMTYPE = 0;

//    40
//    41  %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;
    };
  };
};

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

const struct STACKFM *STACKFMTYPE = 0;

//    60
//    61  %begin

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

  //    62    %record (stackfm) V

  struct STACKFM V;

  //    63    %routine do(%record (stackfm) %name  V)

  void DO(struct STACKFM * V) {
    //    64      write(v_Base, 0)

    _imp_WRITE(V->BASE, 0);

    //    65      write(v_Disp, 0)

    _imp_WRITE(V->DISP, 0);

    //    66      write(v_Oper, 0)

    _imp_WRITE(V->OPER, 0);

    //    67    %end

    return;
  } /* end of DO */

  //    68
  //    69    do(V)

  DO(/*?*/ &V);

  //    70
  //    71  %endofprogram

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