#include <perms.h>
int _imp_mainep(int _imp_argc, char **_imp_argv) {
  static int Pos;
  static int Line;
  static int Icount;
  static int Dcount;
  static int Lcount;
  static int Section;
  static int Lmax;
  static int Tmax;
  static int Text;
  static int First;
  int Code;
  int N1;
  int N2;
  int N3;
  int N4;
  int Nums;
  static int Tab[50 /*1:50*/] = {
      0x0B48D /*SZL*/, 0741400, 0x0B2F2 /*SPA*/, 0741100,
      0x0B2A2 /*SNA*/, 0741200, 0x0B239 /*SKP*/, 0741000,
      0x0B2AD /*SNL*/, 0740400, 0x0B27A /*SMA*/, 0740100,
      0x0B482 /*SZA*/, 0740200, 0x0B39D /*STL*/, 0744002,
      0x0AAB5 /*RCL*/, 0744010, 0x0AABB /*RCR*/, 0744020,
      0x04E5D /*CLL*/, 0744000, 0x04E54 /*CLC*/, 0750001,
      0x084EC /*LAS*/, 0750004, 0x04E52 /*CLA*/, 0750000,
      0x04E7A /*CMA*/, 0740001, 0x04E85 /*CML*/, 0740002,
      0x0AD5D /*RTL*/, 0742010, 0x0AD63 /*RTR*/, 0742020,
      0x0AA65 /*RAL*/, 0740010, 0x0AA6B /*RAR*/, 0740020,
      0x097AC /*OAS*/, 0740004, 0x06DA5 /*HLT*/, 0740040,
      0x09399 /*NOP*/, 0740000};
  int Lval[1000 /*1:1000*/];
  static int C_sw;
  static void *C[48 /*0:47*/] = {
      &&C_0,  &&C_1,  &&C_2,  &&C_3,  &&C_4,  &&C_5,  &&C_6,  &&C_7,
      &&C_8,  &&C_9,  &&C_10, &&C_11, &&C_12, &&C_13, &&C_14, &&C_15,
      &&C_16, &&C_17, &&C_18, &&C_19, &&C_20, &&C_21, &&C_22, &&C_23,
      &&C_24, &&C_25, &&C_26, &&C_27, &&C_28, &&C_29, &&C_30, &&C_31,
      &&C_32, &&C_33, &&C_34, &&C_35, &&C_36, &&C_37, &&C_38, &&C_39,
      &&C_40, &&C_41, &&C_42, &&C_43, &&C_44, &&C_45, &&C_46, &&C_47,
  };
  void Readitem(void) {
    void Read(int *N) {
      int Shift;
      int Sign;
      *N = 0;
      Shift = 0;
      Sign = 0;
    L__1:
      Readsymbol(Code);
      if (Code == '-') {
        Sign = 1;
        goto L__1;
      }
      if ('0' <= Code && Code <= '?') {
        *N = ((Code & 15) << Shift) + *N;
        Shift += 4;
        goto L__1;
      }
      if (Sign) *N = -*N;
      Nums++;
    }
    Nums = 0;
  L__1:
    Read(N1);
    if (Code != ' ') return;
    N4 = N3;
    N3 = N2;
    N2 = N1;
    goto L__1;
  }
  void Psym(int K) {
    Printsymbol(K);
    Pos++;
  }
  void Write(int V, int P) {
    int Sign;
    int D;
    void Try(int N) {
      if (N == -1) goto L__3;
      D = 0;
    L__1:
      if (V + N < 0) goto L__2;
      V += N;
      D++;
      goto L__1;
    L__2:
      if (Sign == 0 || D != 0) goto L__4;
      P++;
      return;
    L__3:
      D = V;
    L__4:
      if (Sign) {
        if (P - 6 > 0) {
          Spaces(P - 6);
          Pos = Pos + P - 6;
        }
        if (Sign != ' ') Psym(Sign);
        Sign = 0;
      }
      Psym(D + '0');
    }
    Sign = ' ';
    if (V >= 0) goto L__1;
    V = -V;
    Sign = '-';
  L__1:
    Try(-100000);
    Try(-10000);
    Try(-1000);
    Try(-100);
    Try(-10);
    Try(-1);
  }
  void Count(int K) {
    if (!Section)
      Icount++;
    else
      Dcount++;
    if (First == 1) {
      if (Pos < 9) {
        Spaces(9 - Pos);
        Pos = 9;
      }
      First = 0;
      return;
    }
    if (Pos <= 60) {
      Psym(';');
      Psym(' ');
      if (K) Psym(K);
    } else {
      Newline();
      Spaces(9);
      Pos = 9;
    }
  }
  void Print(int X) {
    int I;
    int J;
    int K;
    void Pr(int D) {
      if (D < 10)
        D += '0';
      else
        D = D - 10 + 'A';
      Printsymbol(D);
    }
    J = X / 40;
    K = X - 40 * J;
    I = J / 40;
    J -= 40 * I;
    Pr(I);
    Pr(J);
    Pr(K);
    Pos += 3;
  }
  void Translate(int V) {
    int I;
    int J;
    int U;
    U = 0;
    for (I = 2; I <= 50; I += 2) {
      J = Tab[I];
      if ((~V & J) == 0 && (~U & J) != 0) {
        if (U != 0 && (~32767 & J) == ~32767) Psym('!');
        Print(Tab[I - 1]);
        U = U | J;
        if (U == V) return;
      }
    }
    Psym(' ');
    Write(~U & V, 4);
  }
  void Jms(int T) {
    static int Sub_sw;
    static void *Sub[53 /*4:56*/] = {
        &&Sub_4,  &&Sub_5,  &&Sub_6,  &&Sub_7,  &&Sub_8,  &&Sub_9,  &&Sub_10,
        &&Sub_11, &&Sub_12, &&Sub_13, &&Sub_14, &&Sub_15, &&Sub_16, &&Sub_17,
        &&Sub_18, &&Sub_19, &&Sub_20, &&Sub_21, &&Sub_22, &&Sub_23, &&Sub_24,
        &&Sub_25, &&Sub_26, &&Sub_27, &&Sub_28, &&Sub_29, &&Sub_30, &&Sub_31,
        &&Sub_32, &&Sub_33, &&Sub_34, &&Sub_35, &&Sub_36, &&Sub_37, &&Sub_38,
        &&Sub_39, &&Sub_40, &&Sub_41, &&Sub_42, &&Sub_43, &&Sub_44, &&Sub_45,
        &&Sub_46, &&Sub_47, &&Sub_48, &&Sub_49, &&Sub_50, &&Sub_51, &&Sub_52,
        &&Sub_53, &&Sub_54, &&Sub_55, &&Sub_56,
    };
    goto *Sub[Sub_sw = (T)-4];
  Sub_4:
    printstring("MON");
    goto P3;
  Sub_5:
    printstring("NEST");
    goto P4;
  Sub_6:
    printstring("LE");
    goto P2;
  Sub_7:
    printstring("GE");
    goto P2;
  Sub_8:
    printstring("AREF");
    goto P4;
  Sub_9:
    printstring("ADEC");
    goto P4;
  Sub_10:
    printstring("SHIFT");
    goto P5;
  Sub_11:
    printstring("OR");
    goto P2;
  Sub_12:
    printstring("MULT");
    goto P4;
  Sub_13:
    printstring("IDIV");
    goto P4;
  Sub_14:
    printstring("DIV");
    goto P3;
  Sub_15:
    printstring("EXP");
    goto P3;
  Sub_16:
    printstring("ENTRY");
    goto P5;
  Sub_17:
    printstring("FTRAP");
    goto P5;
  Sub_18:
    printstring("DA");
    goto P2;
  Sub_19:
    printstring("S");
    goto P6;
  Sub_20:
    printstring("BAR");
    goto P3;
  Sub_21:
    printstring("BGET");
    goto P4;
  Sub_22:
    printstring("BPUT");
    goto P4;
  Sub_23:
    printstring("W");
    goto P6;
  Sub_24:
    printstring("X");
    goto P6;
  Sub_25:
    printstring("PTEXT");
    Text = 1;
    goto P5;
  Sub_26:
    printstring("Z");
    goto P6;
  Sub_27:
    printstring("Nl");
    goto P2;
  Sub_28:
    printstring("ADDR");
    goto P4;
  Sub_29:
    printstring("INT");
    goto P3;
  Sub_30:
    printstring("SELIN");
    goto P5;
  Sub_31:
    printstring("SELOUT");
    goto P6;
  Sub_32:
    printstring("READCH");
    goto P6;
  Sub_33:
    printstring("PRINCH");
    goto P6;
  Sub_34:
    printstring("NSYM");
    goto P4;
  Sub_35:
    printstring("RSYM");
    goto P4;
  Sub_36:
    printstring("SSYM");
    goto P4;
  Sub_37:
    printstring("Psym");
    goto P4;
  Sub_38:
    printstring("NLINE");
    goto P5;
  Sub_39:
    printstring("NLINES");
    goto P6;
  Sub_40:
    printstring("SPACE");
    goto P5;
  Sub_41:
    printstring("Spaces");
    goto P6;
  Sub_42:
    printstring("READ");
    goto P4;
  Sub_43:
    printstring("Write");
    goto P5;
  Sub_44:
    printstring("CLIN");
    goto P4;
  Sub_45:
    printstring("CLOUT");
    goto P5;
  Sub_46:
    printstring("RDA");
    goto P3;
  Sub_47:
    printstring("WDA");
    goto P3;
  Sub_48:
    printstring("INSTR");
    goto P5;
  Sub_49:
    printstring("OUTSTR");
    goto P6;
  Sub_50:
    printstring("INDEV");
    goto P5;
  Sub_51:
    printstring("OUTDEV");
    goto P6;
  Sub_52:
    printstring("INPUT");
    goto P5;
  Sub_53:
    printstring("PROMPT");
    goto P6;
  Sub_54:
    printstring("FREE");
    goto P4;
  Sub_55:
    printstring("TINT");
    goto P4;
  Sub_56:
    printstring("OUTPos");
    goto P6;
  P6:
    Pos++;
  P5:
    Pos++;
  P4:
    Pos++;
  P3:
    Pos++;
  P2:
    Pos += 2;
  }
  void Tag(int X) {
    Count(' ');
    Print(X);
    Psym(' ');
    if (X == 0x07A4C /*JMS*/ && 4 <= N1 && N1 <= 56)
      Jms(N1);
    else
      Write(N1, 1);
  }
  void Ind(int X) {
    Count(' ');
    Print(X);
    Psym('*');
    Psym(' ');
    if (X == 0x07A4C /*JMS*/ && N1 == 4)
      Print(0x08D57 /*MON*/);
    else
      Write(N1, 1);
  }
  void Lit(int X) {
    int I;
    Count(' ');
    Print(X);
    Psym(' ');
    Psym('#');
    Write(N1, 1);
    Lcount++;
    for (I = 1; I <= Lmax; I++)
      if (Lval[I] == N1) return;
    Lmax++;
    Lval[Lmax] = N1;
  }
  void Transopr(int I) {
    Count(' ');
    Translate(0740000 + I);
  }
  if (Nextsymbol() == ' ') do
      Readsymbol(Code);
    while (Code != ';' && Code != Nl);
L__1:
  Newline();
  First = 1;
  Line++;
  Write(Line, 3);
  Spaces(2);
  Pos = 5;
  if (_imp_on_event(9)) goto L__2;
  Selectinput(2);
  do {
    Readsymbol(Code);
    Printsymbol(Code);
  } while (Code != Nl);
  Spaces(5);
L__2:
  if (_imp_on_event(9)) goto L__99;
  Selectinput(1);
L__3:
  Readitem();
  if (Code == Nl) goto L__1;
  goto *C[C_sw = Code & 63];
C_0:
  Tag(0x04092 /*ADA*/);
  goto L__3;
C_1:
  Tag(0x052DC /*DAC*/);
  goto L__3;
C_2:
  Tag(0x07A4C /*JMS*/);
  goto L__3;
C_3:
  Tag(0x056CE /*DZM*/);
  goto L__3;
C_4:
  Tag(0x084DC /*LAC*/);
  goto L__3;
C_5:
  Tag(0x0D21B /*XOR*/);
  goto L__3;
C_6:
  Tag(0x04095 /*ADD*/);
  goto L__3;
C_7:
  Tag(0x0B6DD /*TAD*/);
  goto L__3;
C_8:
  Tag(0x0D03D /*XCT*/);
  goto L__3;
C_9:
  Tag(0x07503 /*ISZ*/);
  goto L__3;
C_10:
  Tag(0x04225 /*AND*/);
  goto L__3;
C_11:
  Tag(0x0B09D /*SAD*/);
  goto L__3;
C_12:
  Tag(0x07A49 /*JMP*/);
  goto L__3;
C_13:
  Tag(0x0591E /*EAE*/);
  goto L__3;
C_14:
  Tag(0x0745D /*IOT*/);
  goto L__3;
C_15:
  Transopr(N1);
  goto L__3;
C_16:
  Tag(0x040A3 /*ADR*/);
  goto L__3;
C_17:
  Ind(0x052DC /*DAC*/);
  goto L__3;
C_18:
  Ind(0x07A4C /*JMS*/);
  goto L__3;
C_19:
  Ind(0x056CE /*DZM*/);
  goto L__3;
C_20:
  Ind(0x084DC /*LAC*/);
  goto L__3;
C_21:
  Ind(0x0D21B /*XOR*/);
  goto L__3;
C_22:
  Ind(0x04095 /*ADD*/);
  goto L__3;
C_23:
  Ind(0x0B6DD /*TAD*/);
  goto L__3;
C_24:
  Ind(0x0D03D /*XCT*/);
  goto L__3;
C_25:
  Ind(0x07503 /*ISZ*/);
  goto L__3;
C_26:
  Ind(0x04225 /*AND*/);
  goto L__3;
C_27:
  Ind(0x0B09D /*SAD*/);
  goto L__3;
C_28:
  Ind(0x07A49 /*JMP*/);
  goto L__3;
C_29:
  Tag(0x052DD /*DAD*/);
  goto L__3;
C_30:
  Tag(0x04B78 /*C30*/);
  goto L__3;
C_31:
  Tag(0x084DD /*LAD*/);
  goto L__3;
C_32:
  Tag(0x04B7A /*C32*/);
  goto L__3;
C_33:
  Psym('!');
  goto L__4;
C_34:
  Tag(0x04B7C /*C34*/);
  goto L__3;
C_35:
  Count(0);
  if (!Text)
    Write(N1, 1);
  else {
    Psym('\'');
    Psym((unsigned)N1 >> 7 & 127);
    if (N1 & 127) Psym(N1 & 127);
    Psym('\'');
    if (N1 < 0) Text = 0;
  }
  goto L__3;
C_36:
  Lit(0x084DC /*LAC*/);
  goto L__3;
C_37:
  Lit(0x0D21B /*XOR*/);
  goto L__3;
C_38:
  Lit(0x04095 /*ADD*/);
  goto L__3;
C_39:
  Lit(0x0B6DD /*TAD*/);
  goto L__3;
C_40:
  Psym('(');
  Pos++;
  goto L__3;
C_41:
  Psym(')');
  Pos++;
  Write(N1, 1);
  goto L__3;
C_42:
  Lit(0x04225 /*AND*/);
  goto L__3;
C_43:
  Lit(0x0B09D /*SAD*/);
  goto L__3;
C_44:
  Psym(',');
  goto L__4;
C_45:
  Tag(0x04BA5 /*C45*/);
  goto L__3;
C_46:
  if (Pos > 5) {
    Newline();
    Pos = 0;
  }
  Spaces(5 - Pos);
  Pos = 5;
  Write(N1, 1);
  if (Nums == 1) {
    Psym(':');
    Spaces(9 - Pos);
    Pos = 9;
  } else {
    Psym('_');
    Write(N2, 1);
    Psym(':');
  }
  First = 1;
  if (Tmax < N1 && N1 < 210) Tmax = N1;
  goto L__3;
C_47:
  Psym('/');
  Section = Section ^ 1;
  goto L__3;
L__4:
  Write(N1, 1);
  if (N2) Write(N2, 7);
  if (N3) Write(N3, 7);
  if (N4) Write(N4, 7);
  goto L__3;
L__99:
  printstring("$$$$$");
  Newlines(2);
  printstring("INSTRUCTIONS:");
  Write(Icount, 9);
  Newline();
  printstring("DATA SLOTS:");
  Write(Dcount, 11);
  Newline();
  printstring("LITERALS:");
  Write(Lcount, 13);
  Newline();
  printstring("DISTINCT LITERALS:");
  Write(Lmax, 4);
  Newline();
  printstring("MAXIMUM TAG:");
  Write(Tmax, 10);
  Newline();
  Newline();
  exit(0);
  return (1);
}
