#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  %recordformatspec Stackfm
//     2
//     3  %recordformat Stackfm( %c

struct STACKFM {
  union {
    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;
              int EXTRA;
            };
          };

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

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

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

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

        };
      };

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

//     4+       %integer Flags,
//     5+       %byte Base, Prim,
//     6+       %byte  Type, Form,
//     7+       (%longreal Rval %or %integer Rhigh, Rlow %c
//     8+         %or (%integer Disp, Extra),
//     9+       (%integer Format %or %integer Scale),
//    10+       %integer Area,
//    11+       %integer Varno,
//    12+       (%integer Bias %or %byte Reg, Label),
//    13+       %record(Stackfm)%name     Params, Record,
//    14+       (%integer  Oper, %record(Stackfm)%name Link),
//    15+       (%integer Xsize, %record(Stackfm)%name Index)),
//    16+       %record(Stackfm)%name          Using, Stack)
//    17
//    18  %externalroutine pass2

void PASS2(void) {
  //    19     %routine Initialise(%record(Stackfm)%name V, %integer Base, Form)

  void INITIALISE(struct STACKFM * V, int BASE, int FORM) {
    //    20        V = 0

    *V = (struct STACKFM){0};

    //    21        ! In pass2.imp these fields are missing in the generated C, but
    //    22        ! I haven't yet been able to replicate the problem in a smaller
    //    23        ! test program such as this :-(
    //    24        V_Base  = Base

    V->BASE = BASE;

    //    25        V_Type  = 42

    V->TYPE = 42;

    //    26        V_Form  = Form

    V->FORM = FORM;

    //    27        V_Flags = 17

    V->FLAGS = 17;

    //    28     %end

    return;
  } /* end of INITIALISE */

  //    29  %end

  return;
} /* end of PASS2 */

// ?INITIALISE unused
//    30
//    31  %endoffile