#include <perms.h>
int _imp_mainep(int _imp_argc, char **_imp_argv) {
  void Newpage(void) { Printsymbol('L' & 31); }
  void Xreadsym(int *Sym) {
    Readsymbol(*Sym);
    Printsymbol(*Sym);
  }
  void Readsymbol(int *Sym) { Xreadsym(*Sym); }
  void Xread(int *Num) {
    Read(*Num);
    Write(*Num, 0);
  }
  void Read(int *Num) { Xread(*Num); }
  int Rmn[16 /*0:15*/];
  int Reg[16 /*0:15*/];
  int Imn[31 /*1:31*/];
  int Lmn[20 /*1:20*/];
  int Lad[20 /*1:20*/];
  int R[4000 /*1:4000*/];
  int S[16384 /*0:16383*/];
  int Lp;
  int Rp;
  int Sp;
  int I;
  int J;
  int K;
  int L;
  int M;
  int N;
  int F;
  int Mr;
  int Tr;
  int St;
  int Ct;
  auto void Readmn(int *Mn, int *Next);
  auto void Fault(int I, int J, int K, int L);
  auto void Out(int I);
  auto void Dump(void);
  static int Ins_sw;
  static void *Ins[31 /*1:31*/] = {
      &&Ins_1,  &&Ins_2,  &&Ins_3,  &&Ins_4,  &&Ins_5,  &&Ins_6,  &&Ins_7,  &&Ins_8,  &&Ins_9,  &&Ins_10, &&Ins_11,
      &&Ins_12, &&Ins_13, &&Ins_14, &&Ins_15, &&Ins_16, &&Ins_17, &&Ins_18, &&Ins_19, &&Ins_20, &&Ins_21, &&Ins_22,
      &&Ins_23, &&Ins_24, &&Ins_25, &&Ins_26, &&Ins_27, &&Ins_28, &&Ins_29, &&Ins_30, &&Ins_31,
  };
  static int Ior_sw;
  static void *Ior[11 /*0:10*/] = {
      &&Ior_0, &&Ior_1, &&Ior_2, &&Ior_3, &&Ior_4, &&Ior_5, &&Ior_6, &&Ior_7, &&Ior_8, &&Ior_9, &&Ior_10,
  };
  Rmn[0] = 'BR0';
  Rmn[1] = 'BR1';
  Rmn[2] = 'BR2';
  Rmn[3] = 'BR3';
  Rmn[4] = 'BR4';
  Rmn[5] = 'BR5';
  Rmn[6] = 'BR6';
  Rmn[7] = 'BR7';
  Rmn[8] = 'BR8';
  Rmn[9] = 'BR9';
  Rmn[10] = 'BR10';
  Rmn[11] = 'BR11';
  Rmn[12] = 'BR12';
  Rmn[13] = 'WK';
  Rmn[14] = 'STP';
  Rmn[15] = 'ACC';
  Imn[1] = 'LOAD';
  Imn[2] = 'LDA';
  Imn[3] = 'ADD';
  Imn[4] = 'SUB';
  Imn[5] = 'MLT';
  Imn[6] = 'DIV';
  Imn[7] = 'EXP';
  Imn[8] = 'STR';
  Imn[9] = 'NEG';
  Imn[10] = 'NOT';
  Imn[11] = 'SHL';
  Imn[12] = 'SHR';
  Imn[13] = 'AND';
  Imn[14] = 'OR';
  Imn[15] = 'XOR';
  Imn[16] = 'BAL';
  Imn[17] = 'B';
  Imn[18] = 'BZ';
  Imn[19] = 'BNZ';
  Imn[20] = 'BG';
  Imn[21] = 'BNG';
  Imn[22] = 'BL';
  Imn[23] = 'BNL';
  Imn[24] = 'STOP';
  Imn[25] = 'ADDF';
  Imn[26] = 'SUBF';
  Imn[27] = 'MLTF';
  Imn[28] = 'DIVF';
  Imn[29] = 'EXPF';
  Imn[30] = 'NEGF';
  Imn[31] = 'FLT';
  Lp = 1;
  Rp = 1;
  Sp = 0;
  F = 0;
  Mr = 0;
  Tr = 0;
  Openinput(1, _imp_str_literal("skimp77.asm"));
  Selectinput(1);
L1 : {
  if (_imp_on_event(9)) {
    Printstring(_imp_str_literal("End of file reading skimp77.asm, not while executing it..."));
    Newline();
    exit(0);
  }
  Readsymbol(I);
}
  if (I == ';') {
    do
      Readsymbol(I);
    while (I != Nl);
    goto L1;
  }
  if (I == '\'') {
  L10:
    Readsymbol(I);
    if (I != '\'') goto L10;
    goto L1;
  }
  if (I != '.') goto L1;
  Readmn(I, J);
  if (J == ':') {
    if (Lp == 1) goto L2;
    K = 1;
  L4:
    if (I == Lmn[K]) {
      if (Lad[K] >= 0) Fault('LABE', 'L SE', 'T TW', 'ICE ');
      goto L3;
    }
    K++;
    if (K < Lp) goto L4;
    if (Lp > 20) {
      Fault('TOO ', 'MANY', ' LAB', 'ELS ');
      goto L25;
    }
  L2:
    Lmn[Lp] = I;
    K = Lp;
    Lp++;
  L3:
    Lad[K] = Sp;
  L25:
    if (I == 'ST') {
      St = Sp;
      goto L18;
    }
    goto L1;
  }
  if (J == '=') {
    Read(K);
    if (K < 0 || K > 15) {
      Fault('EQUA', 'TE N', 'UMBE', 'R ? ');
      goto L1;
    }
    Rmn[K] = I;
    goto L1;
  }
  if (I == 'REGS' && J == 10) {
    Mr = Mr | 128;
    goto L1;
  }
  if (I == 'TON' && J == 10) {
    Mr = Mr | 64;
    goto L1;
  }
  if (I == 'TOFF' && J == 10) {
    Mr = Mr | 32;
    goto L1;
  }
  if (J != ',') Fault('SYNT', 'AX ?', 0, 0);
  if (!I) {
    Readmn(I, J);
    if (I != 0 || J != ',') Fault('SYNT', 'AX ?', 0, 0);
    Readmn(I, J);
    if (I != 0 || J != ',') Fault('SYNT', 'AX ?', 0, 0);
    if (Sp >= 16384) {
      Fault('PROG', 'RAM ', 'TOO ', 'BIG ');
      exit(0);
    }
    Read(S[Sp]);
    Sp++;
    Mr = 0;
    goto L1;
  }
  K = 1;
L6:
  if (I == Imn[K]) goto L5;
  K++;
  if (K <= 31) goto L6;
  Fault('INST', 'RUCT', 'ION ', '?   ');
L5:
  Readmn(I, J);
  if (J != ',') Fault('SYNT', 'AX ?', 0, 0);
  if (!I)
    L = 0;
  else {
    L = 0;
  L8:
    if (I == Rmn[L]) goto L7;
    L++;
    if (L <= 15) goto L8;
    Fault('REGI', 'STER', ' ?  ', 0);
  }
L7:
  K = K << 4 | L;
  Readmn(I, J);
  if (J == '+') {
    Read(M);
    if (M >= 65536) Fault('DISP', '. TO', 'O BI', 'G   ');
    if (Lp == 1) goto L9;
    L = 1;
  L12:
    if (I == Lmn[L]) {
      if (Lad[L] < 0) goto L11;
      K = K << 20 | (Lad[L] + M);
      goto L13;
    }
    L++;
    if (L < Lp) goto L12;
    if (Lp > 20) {
      Fault('TOO ', 'MANY', ' LAB', 'ELS ');
      goto L11;
    }
  L9:
    Lmn[Lp] = I;
    Lad[Lp] = -1;
    L = Lp;
    Lp++;
  L11:
    if (Rp > 4000) {
      Fault('TOO ', 'MANY', ' REL', 'OCS.');
      exit(0);
    }
    R[Rp] = L << 16 | Sp;
    Rp++;
  L14:
    K = K << 20 | M;
  L13:
    if (Sp >= 16384) {
      Fault('PROG', 'RAM ', 'TOO ', 'BIG ');
      exit(0);
    }
    S[Sp] = K | Mr << 24;
    Sp++;
    Mr = 0;
    goto L1;
  }
  if (('A' <= J && J <= 'Z') || J == 10) {
    if (I == 'READ' && J == 'S') {
      M = 16384;
    L15:
      Readmn(I, J);
      if (I != 'YMBO' || J != 'L') goto L26;
      Readsymbol(I);
      if (I != 10) goto L26;
      goto L14;
    }
    if (I == 'NEXT' && J == 'S') {
      M = 16385;
      goto L15;
    }
    if (I == 'SKIP' && J == 'S') {
      M = 16386;
      goto L15;
    }
    if (I == 'PRIN' && J == 'T') {
      Readsymbol(I);
      if (I != 'S') goto L26;
      M = 16387;
      goto L15;
    }
    if (I == 'SPAC' && J == 'E') {
      Readmn(I, J);
      if (I == 0 && J == 10) {
        M = 16388;
        goto L14;
      }
      if (I == 'S' && J == 10) {
        M = 16389;
        goto L14;
      }
      goto L26;
    }
    if (I == 'NEWL' && J == 'I') {
      Readmn(I, J);
      if (I == 'NE' && J == 10) {
        M = 16390;
        goto L14;
      }
      if (I == 'NES' && J == 10) {
        M = 16391;
        goto L14;
      }
      goto L26;
    }
    if (I == 'NEWP' && J == 'A') {
      Readmn(I, J);
      if (I != 'GE' || J != 10) goto L26;
      M = 16392;
      goto L14;
    }
    if (I == 'READ' && J == 10) {
      M = 16393;
      goto L14;
    }
    if (I == 'WRIT' && J == 'E') {
      Readsymbol(I);
      if (I != 10) goto L26;
      M = 16394;
      goto L14;
    }
  L26:
    Fault('I-O ', 'NAME', ' ?  ', 0);
    goto L13;
  }
  if (J != ',') Fault('SYNT', 'AX ?', 0, 0);
  if (!I)
    L = 0;
  else {
    L = 0;
  L17:
    if (I == Rmn[L]) goto L16;
    L++;
    if (L <= 15) goto L17;
    Fault('BASE', ' REG', 'ISTE', 'R ? ');
  }
L16:
  K = K << 4 | L;
  Read(M);
  if (M >= 65536) Fault('DISP', '. TO', 'O BI', 'G   ');
  K = K << 16 | M;
  goto L13;
L18:
  Read(I);
  if (I) {
    Newline();
    Out('PROG');
    Out('RAM ');
    Out('FAUL');
    Out('TY !');
    Newline();
    exit(0);
  }
L38:
  Readsymbol(I);
  if (I != '.') goto L38;
  Selectinput(0);
  I = St;
L28:
  if (I > 16383) goto L29;
  S[I] = 999999;
  I++;
  goto L28;
L29:
  Newline();
  Out('LABE');
  Out('LS  ');
  Newline();
  I = 0;
  J = 1;
L20:
  Out(Lmn[J]);
  Out('  : ');
  if (Lad[J] < 0) {
    Out('NOT ');
    Out('SET ');
    I = 1;
  } else
    Write(Lad[J], 1);
  Newline();
  if (Lmn[J] == 'CT') Ct = Lad[J];
  J++;
  if (J < Lp) goto L20;
  if (I != 0 || F != 0) exit(0);
  if (Rp == 1) goto L21;
  M = 1;
L22:
  I = (unsigned)R[M] >> 16;
  J = R[M] & 65535;
  K = S[J] & 65535;
  L = Lad[I] + K;
  if (L >= 65536) {
    Out('ADDR');
    Out(' TRU');
    Out('NCAT');
    Out('ED  ');
    Write(J, 1);
    Newline();
    L = L & 65535;
  }
  S[J] = (unsigned)S[J] >> 16 << 16 | L;
  M++;
  if (M < Rp) goto L22;
L21:
  I = 0;
L23:
  Reg[I] = 0;
  I++;
  if (I <= 15) goto L23;
  Sp = 0;
L24:
  if (Sp < 0 || Sp >= Ct) {
    if (Sp >= 16384 && Sp <= 16394) goto *Ior[Ior_sw = Sp - 16384];
    Newline();
    Out('**  ');
    Write(Sp, 1);
    Spaces(4);
    Out('INST');
    Out('R AD');
    Out('DR ?');
    exit(0);
  }
  I = S[Sp];
  J = (unsigned)I >> 20 & 15;
  K = (unsigned)I >> 16 & 15;
  L = I & 65535;
  if (!K)
    M = L;
  else
    M = Reg[K] + L;
  I = (unsigned)I >> 24;
  if (I > 128) {
    Newline();
    N = 0;
  L27:
    Out(Rmn[N]);
    Out('  : ');
    Write(Reg[N], 1);
    Newline();
    N++;
    if (N <= 15) goto L27;
    I -= 128;
  }
  if (I > 64) {
    Tr = 1;
    I -= 64;
  }
  if (I > 32) {
    Tr = 0;
    I -= 32;
  }
  if (((unsigned)0x3E00F9FA >> I & 1) != 0 && (M < Ct || M >= 16384)) {
    Newline();
    Out('**  ');
    Write(Sp, 1);
    Spaces(4);
    Out('EFFE');
    Out('CTIV');
    Out('E AD');
    Out('DR ?');
    Write(M, 1);
    Dump();
    exit(0);
  }
  if (!I) {
    Newline();
    Out('**  ');
    Write(Sp, 1);
    Spaces(4);
    Out('INST');
    Out('RUCT');
    Out('ION?');
    Dump();
    exit(0);
  }
  if (Tr) {
    Newline();
    Write(Sp, 3);
    Spaces(2);
    Out(Imn[I]);
    Spaces(2);
    Out(Rmn[J]);
    Write(M, 4);
    Spaces(6);
  }
  goto *Ins[Ins_sw = (I)-1];
Ins_1:;
  Reg[J] = S[M];
  Sp++;
  goto L24;
Ins_2:;
  Reg[J] = M;
  Sp++;
  goto L24;
Ins_3:;
  Reg[J] = Reg[J] + S[M];
  Sp++;
  goto L24;
Ins_4:;
  Reg[J] = Reg[J] - S[M];
  Sp++;
  goto L24;
Ins_5:;
  Reg[J] = Reg[J] * S[M];
  Sp++;
  goto L24;
Ins_6:;
  Reg[J] = Reg[J] / S[M];
  Sp++;
  goto L24;
Ins_7:;
  Reg[J] = IEXP(Reg[J], S[M]);
  Sp++;
  goto L24;
Ins_8:;
  S[M] = Reg[J];
  Sp++;
  goto L24;
Ins_9:;
  Reg[J] = -Reg[J];
  Sp++;
  goto L24;
Ins_10:;
  Reg[J] = ~Reg[J];
  Sp++;
  goto L24;
Ins_11:;
  Reg[J] = Reg[J] << S[M];
  Sp++;
  goto L24;
Ins_12:;
  Reg[J] = (unsigned)Reg[J] >> S[M];
  Sp++;
  goto L24;
Ins_13:;
  Reg[J] = Reg[J] & S[M];
  Sp++;
  goto L24;
Ins_14:;
  Reg[J] = Reg[J] | S[M];
  Sp++;
  goto L24;
Ins_15:;
  Reg[J] = Reg[J] ^ S[M];
  Sp++;
  goto L24;
Ins_16:;
  Reg[J] = Sp + 1;
  Sp = M;
  goto L24;
Ins_17:;
  Sp = M;
  goto L24;
Ins_18:;
  if (!Reg[J])
    Sp = M;
  else
    Sp++;
  goto L24;
Ins_19:;
  if (Reg[J])
    Sp = M;
  else
    Sp++;
  goto L24;
Ins_20:;
  if (Reg[J] > 0)
    Sp = M;
  else
    Sp++;
  goto L24;
Ins_21:;
  if (Reg[J] <= 0)
    Sp = M;
  else
    Sp++;
  goto L24;
Ins_22:;
  if (Reg[J] < 0)
    Sp = M;
  else
    Sp++;
  goto L24;
Ins_23:;
  if (Reg[J] >= 0)
    Sp = M;
  else
    Sp++;
  goto L24;
Ins_24:;
  Newline();
  Out('STOP');
  Out('PED ');
  Out('AT  ');
  Write(Sp, 1);
  exit(0);
Ins_25:;
  *Real(Addr(Reg[J])) = *Real(Addr(Reg[J])) + *Real(Addr(S[M]));
  Sp++;
  goto L24;
Ins_26:;
  *Real(Addr(Reg[J])) = *Real(Addr(Reg[J])) - *Real(Addr(S[M]));
  Sp++;
  goto L24;
Ins_27:;
  *Real(Addr(Reg[J])) = *Real(Addr(Reg[J])) * *Real(Addr(S[M]));
  Sp++;
  goto L24;
Ins_28:;
  *Real(Addr(Reg[J])) = *Real(Addr(Reg[J])) / *Real(Addr(S[M]));
  Sp++;
  goto L24;
Ins_29:;
  *Real(Addr(Reg[J])) = REXP(*Real(Addr(Reg[J])), S[M]);
  Sp++;
  goto L24;
Ins_30:;
  *Real(Addr(Reg[J])) = -*Real(Addr(Reg[J]));
  Sp++;
  goto L24;
Ins_31:;
  *Real(Addr(Reg[J])) = Reg[J];
  Sp++;
  goto L24;
Ior_0:;
  Readsymbol(S[S[Reg[14] + 10]]);
  Sp = Reg[13];
  goto L24;
Ior_1:;
  Reg[15] = Nextsymbol();
  Sp = Reg[13];
  goto L24;
Ior_2:;
  Skipsymbol();
  Sp = Reg[13];
  goto L24;
Ior_3:;
  Printsymbol(S[Reg[14] + 10]);
  Sp = Reg[13];
  goto L24;
Ior_4:;
  Space();
  Sp = Reg[13];
  goto L24;
Ior_5:;
  Spaces(S[Reg[14] + 10]);
  Sp = Reg[13];
  goto L24;
Ior_6:;
  Newline();
  Sp = Reg[13];
  goto L24;
Ior_7:;
  Newlines(S[Reg[14] + 10]);
  Sp = Reg[13];
  goto L24;
Ior_8:;
  Newpage();
  Sp = Reg[13];
  goto L24;
Ior_9:;
  Read(S[S[Reg[14] + 10]]);
  Sp = Reg[13];
  goto L24;
Ior_10:;
  Write(S[Reg[14] + 10], S[Reg[14] + 11]);
  Sp = Reg[13];
  goto L24;
  void Readmn(int *Mn, int *Next) {
    int I;
    int J;
    int K;
  L1:
    Readsymbol(I);
    if (I == ' ') goto L1;
    if (I < 'A' || I > 'Z') {
      *Mn = 0;
      *Next = I;
      return;
    }
    J = 1;
  L2:
    Readsymbol(K);
    if (J == 4 || K < '0' || (K > '9' && K < 'A') || K > 'Z') {
      *Mn = I;
      *Next = K;
      return;
    }
    I = I << 8 | K;
    J++;
    goto L2;
  }
  void Fault(int I, int J, int K, int L) {
    Out('*** ');
    Write(Sp, 4);
    Spaces(6);
    Out(I);
    Out(J);
    Out(K);
    Out(L);
    Newline();
    F++;
  }
  void Out(int I) {
    if ((unsigned)I >> 24) Printsymbol((unsigned)I >> 24);
    if ((unsigned)I >> 16 & 255) Printsymbol((unsigned)I >> 16 & 255);
    if ((unsigned)I >> 8 & 255) Printsymbol((unsigned)I >> 8 & 255);
    if (I & 255) Printsymbol(I & 255);
  }
  void Dump(void) {
    int I;
    int J;
    Newline();
    I = 0;
  L1:
    Out(Rmn[I]);
    Out('  : ');
    Write(Reg[I], 1);
    Newline();
    I++;
    if (I <= 15) goto L1;
    if (Reg[14] < St) {
      Out('STP<');
      Out('ST: ');
      Newline();
      return;
    }
    I = St;
    J = 0;
  L2:
    if (!J) {
      Newline();
      Write(I, 5);
      Spaces(4);
    }
    Write(S[I], 6);
    I++;
    J++;
    if (J == 8) J = 0;
    if (I <= Reg[14]) goto L2;
  }
  exit(0);
  return (1);
}
