#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  !!This version of ECCE, derived from a paper copy believed to
//     2  !!date from 1975, removes PDP9/15 machine code, and other
//     3  !!IMP9/15 system dependencies, and I'm hopeful that as a result
//     4  !!it might well work if compiled with a generic Imp compiler.
//     5
//     6  !!RWT Feb 2002
//     7
//     8  !!Code slightly rearranged to fit the model of Peter Stephen's Imp to C
//     9  !!translator.  This now compiles and runs exactly as on the pdp9/15
//    10  !!Remember to run it with redirected input, eg ecce < file.txt > file2.txt
//    11
//    12  !!The I/O library currently assumes you are running on Unix.
//    13  !!NOTE: There IS a bug in this implementation.  Lines of more
//    14  !!than 120 characters have a newline inserted at the 120th character
//    15  !!on output.  This *may* be an original bug rather than an artifact
//    16  !!of the translation or run-time library..
//    17
//    18  !!GT 02 Mar 2002
//    19
//    20  !%external %integer outstream
//    21  %begin;                                     !edit15: ecce for pdp9/15

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

  //    22
  //    23  %owninteger in=1;                           !current input stream

  static int IN = 1;

  //    24  %constinteger min=1;                        !main input stream
  //    25  %constinteger mout=1;                       !main output stream
  //    26  %constinteger sin=2;                        !secondary input stream
  //    27  %constinteger sextra=122;                   !extra buff for sin
  //    28  %constinteger size=30000;                   !of edit buffer (bytes)
  //    29  %owninteger mon=0;                          !monitor indic

  static int MON = 0;

  //    30  %owninteger print1=0,print2=0;              !print indicators

  static int PRINT1 = 0;
  static int PRINT2 = 0;

  //    31  %constinteger stop=-5000;                   !loop stop (const)
  //    32  %owninteger i,j,k,pp1,sym

  static int I;
  static int J;
  static int K;
  static int PP1;
  static int SYM;

  //    33  %owninteger code;                              !command code letter

  static int CODE;

  //    34  %owninteger text;                              !text pointer

  static int TEXT;

  //    35  %owninteger num;                               !repetition number

  static int NUM;

  //    36  %ownintegername mainfp;                        ! == fp or mfp (for sin)

  static int *MAINFP;

  //    37  %constinteger cbase=1,tbase=120
  //    38  %ownintegerarray c(cbase:tbase);            !command -> <- text

  static int C[120];
  _imp_create_constdv(static, int, C, 1, 120);

  //    39  ! each command unit -- letter, parenthesis or comma -- is
  //    40  ! represented by a trio:  code(+lim)  text  num
  //    41  ! in the case of parentheses and commas 'text' is a pointer
  //    42  ! to another command unit (not to a text string)
  //    43  %owninteger ci;                                !command index (ad)

  static int CI;

  //    44  %owninteger ti;                                !text index (ad)

  static int TI;

  //    45  %owninteger cmax=0;                         !command max (ad)

  static int CMAX = 0;

  //    46  %ownintegerarray stored(1:192);                !defs of x,y,z

  static int STORED[192];
  _imp_create_constdv(static, int, STORED, 1, 192);

  //    47  %owninteger pos1=0, pos2=0, pos3=0

  static int POS1 = 0;
  static int POS2 = 0;
  static int POS3 = 0;

  //    48  %ownbyteintegerarray byte(1:size)

  static unsigned char BYTE[30000];
  _imp_create_constdv(static, unsigned char, BYTE, 1, 30000);

  //    49  %owninteger top = 2;                     !top of buff (index)

  static int TOP = 2;

  //    50  %owninteger bot = size-sextra;           !bottom of buff (index)

  static int BOT = 29878;

  //    51  %owninteger lbeg;                              !line start (index)

  static int LBEG;

  //    52  %owninteger pp;                                !previous pointer (index)

  static int PP;

  //    53  %owninteger fp=0;                           !file pointer (index)

  static int FP = 0;

  //    54  %owninteger lend;                              !line end (index)

  static int LEND;

  //    55  %owninteger fend;                           !end of file in buff (index)

  static int FEND;

  //    56  %owninteger ms=0;                           !match start (index)

  static int MS = 0;

  //    57  %owninteger ml=0;                           !match limit (index)

  static int ML = 0;

  //    58  ! significance of file pointers:
  //    59  ! [nl] o n e nl t w . . . o nl n e x t nl . . nl l a s t nl [nl]
  //    60  !      !        !   !     !  !                                !
  //    61  !      t        l   p     f  l                                f
  //    62  !      o        b   p     p  e                                e
  //    63  !      p        e            n                                n
  //    64  !               g            d                                d
  //    65
  //    66  %owninteger type,chain;                        !command input vars

  static int TYPE;
  static int CHAIN;

  //    67  %owninteger pend=0;                         !ditto

  static int PEND = 0;

  //    68
  //    69  !%routine prompt(%string(1) s); ! Emulating pdp9/15 routine
  //    70  !  %integer oldstream, c
  //    71  !  c = charno(s, 1)
  //    72  !  %if c # 0 %then %start  ; ! c = 0 is supposed to flush output on the 9/15
  //    73  !    oldstream = outstream
  //    74  !    select output(0)
  //    75  !    print symbol(c)
  //    76  !    select output(oldstream)
  //    77  !  %finish
  //    78  !%end
  //    79
  //    80  %routine load pp(%integer k);               !!!also increments pp

  void LOADPP(int K) {
    _imp_enter(LOADPP);

    //    81      byte(pp) = k;  pp = pp+1

    BYTE[PP - 1] = K;
    PP = PP + 1;

    //    82  %end

    _imp_return;
    _imp_begin_backtrace(LOADPP);
    _imp_diagf("\n\nArguments:\n\n");
    _imp_diagf("K = %d\n", K);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_end_backtrace();
  } /* end of LOADPP */

  //    83
  //    84  %routine load fp(%integer k)

  void LOADFP(int K) {
    _imp_enter(LOADFP);

    //    85      byte(fp) = k

    BYTE[FP - 1] = K;

    //    86  %end

    _imp_return;
    _imp_begin_backtrace(LOADFP);
    _imp_diagf("\n\nArguments:\n\n");
    _imp_diagf("K = %d\n", K);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_end_backtrace();
  } /* end of LOADFP */

  //    87
  //    88  %routine left star

  void LEFTSTAR(void) {
    _imp_enter(LEFTSTAR);

    //    89      %cycle

  L_0001:;

  //    90         %return %if pp = lbeg

    if ((PP) != (LBEG)) goto L_0002;
    _imp_return;
  L_0002:;

  //    91         fp = fp-1;  pp = pp-1

    FP = FP - 1;
    PP = PP - 1;

    //    92         load fp(byte(pp))

    LOADFP(BYTE[PP - 1]);

    //    93      %repeat

    goto L_0001;

    //    94  %end

    _imp_begin_backtrace(LEFTSTAR);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_end_backtrace();
  } /* end of LEFTSTAR */

  //    95
  //    96  %routine right star

  void RIGHTSTAR(void) {
    _imp_enter(RIGHTSTAR);

    //    97      %cycle

  L_0003:;

  //    98         %return %if fp = lend

    if ((FP) != (LEND)) goto L_0004;
    _imp_return;
  L_0004:;

  //    99         load pp(byte(fp))

    LOADPP(BYTE[FP - 1]);

    //   100         fp = fp+1

    FP = FP + 1;

    //   101      %repeat

    goto L_0003;

    //   102  %end

    _imp_begin_backtrace(RIGHTSTAR);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_end_backtrace();
  } /* end of RIGHTSTAR */

  //   103
  //   104  %ownintegerarray symtype(33:95) = %c

  static int SYMTYPE[63] = {64, 3,  3,  3, 2, 3,  3,  11, 9,  64, 3, 12, 2,  3,  3,  0,  0,  0,  0, 0, 0,
                            0,  0,  0,  0, 3, 1,  3,  3,  3,  64, 3, 2,  10, 18, 5,  8,  52, 10, 2, 6, 10,
                            10, 10, 56, 2, 2, 10, 50, 10, 22, 5,  5, 6,  2,  32, 32, 32, 3,  10, 3, 3, 3};
  _imp_create_constdv(static, int, SYMTYPE, 33, 95);

  //   105+      64, 3, 3, 3, 2, 3, 3,11, 9,64, 3,12, 2, 3, 3,
  //   106+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 3, 3, 3,64,
  //   107+    3, 2,10,18, 5, 8,52,10, 2, 6,10,10,10,56, 2, 2,
  //   108+   10,50,10,22, 5, 5, 6, 2,32,32,32, 3,10, 3, 3, 3
  //   109  !     !  "  #  $  %  &  '  (  )  *  +  ,  -  .  /
  //   110  !  0  1  2  3  4  5  6  7  8  9  :     <  =  >  ?
  //   111  !  @  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O
  //   112  !  P  Q  R  S  T  U  V  W  X  Y  Z  [  \  ]  ^  _
  //   113
  //   114  %routine read sym

  void READSYM(void) {
    _imp_enter(READSYM);

    //   115      %if pend # 0 %then sym=pend %and pend=0 %else %start

    if ((PEND) == (0)) goto L_0005;
    SYM = PEND;
    PEND = 0;
    goto L_0006;
  L_0005:;

  //   116         %while pos3 # 0 %cycle

  L_0007:;
    if ((POS3) == (0)) goto L_0008;

      //   117            sym = stored(pos3);  pos3 = pos3+1

    SYM = STORED[POS3 - 1];
    POS3 = POS3 + 1;

    //   118            %return %unless sym = nl

    if ((SYM) == (10)) goto L_0009;
    _imp_return;
  L_0009:;

  //   119            pos3 = pos2; pos2 = pos1; pos1 = 0

    POS3 = POS2;
    POS2 = POS1;
    POS1 = 0;

    //   120         %repeat

    goto L_0007;
  L_0008:;

  //   121         read symbol(sym)

    _imp_READSYMBOL(&SYM);

    //   122      %finish

  L_0006:;

  //   123  %end

    _imp_return;
    _imp_begin_backtrace(READSYM);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_end_backtrace();
  } /* end of READSYM */

  //   124
  //   125  %routine read item

  void READITEM(void) {
    _imp_enter(READITEM);

    //   126      type = 1

    TYPE = 1;

    //   127      %cycle

  L_000A:;

  //   128         read sym %until sym # ' '

  L_000B:;
    READSYM();
    if ((SYM) != (32)) goto L_000C;
    goto L_000B;
  L_000C:;

  //   129         %return %if sym < 32;                !nl

    if ((SYM) >= (32)) goto L_000D;
    _imp_return;
  L_000D:;

  //   130         sym = sym-32 %if sym >= 96;          !ensure upper case

    if ((SYM) < (96)) goto L_000E;
    SYM = SYM - 32;
  L_000E:;

  //   131         type = symtype(sym)

    TYPE = SYMTYPE[SYM - 33];

    //   132         %return %unless type&15 = 0

    if ((TYPE & 15) == (0)) goto L_000F;
    _imp_return;
  L_000F:;

  //   133         %exit %unless type=32

    if ((TYPE) == (32)) goto L_0010;
    goto L_0011;
  L_0010:;

  //   134         pos1 = pos2;  pos2 = pos3

    POS1 = POS2;
    POS2 = POS3;

    //   135         pos3 = (sym-'X')<<6+1

    POS3 = (((int)SYM - 88) << (((int)6) & 31)) + 1;

    //   136      %repeat

    goto L_000A;
  L_0011:;

  //   137
  //   138      %if type = 0 %start

    if ((TYPE) != (0)) goto L_0012;

      //   139         num = sym-'0'

    NUM = SYM - 48;

    //   140         %cycle

  L_0013:;

  //   141            read symbol(pend)

    _imp_READSYMBOL(&PEND);

    //   142            %exit %unless '0' <= pend <= '9'

    {
      int tmp;
      if ((48) > (tmp = PEND)) goto L_0014;
      // Double-sided test on PEND (Part II)
      if (tmp <= (57)) goto L_0015;
    }
  L_0014:;
    goto L_0016;
  L_0015:;

  //   143            !num = (num<<2+num)<<1-'0'+pend
  //   144            num = num*10+(pend-'0')

    NUM = NUM * 10 + (PEND - 48);

    //   145         %repeat

    goto L_0013;
  L_0016:;

  //   146      %finish %else %start

    goto L_0017;
  L_0012:;

  //   147         type = 0

    TYPE = 0;

    //   148         num = 0;   %return %if sym = '*'

    NUM = 0;
    if ((SYM) != (42)) goto L_0018;
    _imp_return;
  L_0018:;

  //   149         num = stop+1;  %return %if sym = '?'

    NUM = (-5000) + 1;
    if ((SYM) != (63)) goto L_0019;
    _imp_return;
  L_0019:;

  //   150         num = stop;                          ! '!'

    NUM = -5000;

    //   151      %finish

  L_0017:;

  //   152  %end

    _imp_return;
    _imp_begin_backtrace(READITEM);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_end_backtrace();
  } /* end of READITEM */

  //   153
  //   154  %routine unchain

  void UNCHAIN(void) {
    _imp_enter(UNCHAIN);

    //   155      %cycle

  L_001A:;

  //   156         text = chain;  %return %if text = 0

    TEXT = CHAIN;
    if ((TEXT) != (0)) goto L_001B;
    _imp_return;
  L_001B:;

  //   157         chain = c(text+1);  c(text+1) = ci

    CHAIN = C[TEXT + 1 - 1];
    C[TEXT + 1 - 1] = CI;

    //   158      %repeat %until c(text) = 'X'

    if ((C[TEXT - 1]) == (88)) goto L_001C;
    goto L_001A;
  L_001C:;

  //   159  %end

    _imp_return;
    _imp_begin_backtrace(UNCHAIN);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_end_backtrace();
  } /* end of UNCHAIN */

  //   160
  //   161  %routine stack(%integer v)

  void STACK(int V) {
    _imp_enter(STACK);

    //   162      c(ci) = v;  ci = ci+1

    C[CI - 1] = V;
    CI = CI + 1;

    //   163  %end

    _imp_return;
    _imp_begin_backtrace(STACK);
    _imp_diagf("\n\nArguments:\n\n");
    _imp_diagf("V = %d\n", V);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_end_backtrace();
  } /* end of STACK */

  //   164
  //   165  %routine make space

  void MAKESPACE(void) {
    _imp_enter(MAKESPACE);

    //   166  %integer k,p1,p2

    int K = 0xFEFEFEFE;
    int P1 = 0xFEFEFEFE;
    int P2 = 0xFEFEFEFE;

    //   167      %return %if mainfp-pp-240 > 0

    if ((*MAINFP - PP - 240) <= (0)) goto L_001D;
    _imp_return;
  L_001D:;

  //   168      select output(mout)

    _imp_SELECTOUTPUT(1);

    //   169      p1 = top;  p2 = (p1+lbeg)>>1;           !output about half

    P1 = TOP;
    P2 = (unsigned int)P1 + LBEG >> 1;

    //   170      p2 = lbeg %if code = 'C';               !but all if closing

    if ((CODE) != (67)) goto L_001E;
    P2 = LBEG;
  L_001E:;

  //   171      %monitor %and %stop %if p2 = top;               !!!logical error

    if ((P2) != (TOP)) goto L_001F;
    _imp_monitor_loc(__LINE__, __FILE__, __PRETTY_FUNCTION__);
    _imp_stop(0);
  L_001F:;

  //   172      %cycle

  L_0020:;

  //   173         k = byte(p1);  print symbol(k);  p1 = p1+1

    K = BYTE[P1 - 1];
    _imp_PRINTSYMBOL(K);
    P1 = P1 + 1;

    //   174      %repeat %until k = nl %and p1-p2 >= 0

    if ((K) != (10)) goto L_0021;
    if ((P1 - P2) >= (0)) goto L_0022;
  L_0021:;
    goto L_0020;
  L_0022:;

  //   175      select output(0)

    _imp_SELECTOUTPUT(0);

    //   176      lbeg = top+lbeg-p1;  p2 = pp;  pp = top

    LBEG = TOP + LBEG - P1;
    P2 = PP;
    PP = TOP;

    //   177      %cycle

  L_0023:;

  //   178         %return %if p1 = p2

    if ((P1) != (P2)) goto L_0024;
    _imp_return;
  L_0024:;

  //   179         load pp(byte(p1));  p1 = p1+1

    LOADPP(BYTE[P1 - 1]);
    P1 = P1 + 1;

    //   180      %repeat

    goto L_0023;

    //   181  %end

    _imp_begin_backtrace(MAKESPACE);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_bt_int(K);
    _imp_bt_int(P1);
    _imp_bt_int(P2);
    _imp_end_backtrace();
  } /* end of MAKESPACE */

  //   182
  //   183  %routine read line

  void READLINE(void) {
    _imp_enter(READLINE);

    //   184  %integer k

    int K = 0xFEFEFEFE;

    //   185  !    %on %event 9 %start
    //   186  !       ->eof
    //   187  !    %finish
    //   188      %if fp # fend %start

    if ((FP) == (FEND)) goto L_0025;

      //   189         lend = fp

    LEND = FP;

    //   190         lend = lend+1 %while byte(lend) # nl

  L_0026:;
    if ((BYTE[LEND - 1]) == (10)) goto L_0027;
    LEND = LEND + 1;
    goto L_0026;
  L_0027:;

  //   191         %return

    _imp_return;

    //   192      %finish

  L_0025:;

  //   193      ms = 0;  print1 = 0;  print2 = 0

    MS = 0;
    PRINT1 = 0;
    PRINT2 = 0;

    //   194      select input(in)

    _imp_SELECTINPUT(IN);

    //   195      fp = bot-sextra+1

    FP = BOT - 122 + 1;

    //   196      %cycle

  L_0028:;

  //   197         %if fp # bot %then read symbol(k) %else k = nl

    if ((FP) == (BOT)) goto L_0029;
    _imp_READSYMBOL(&K);
    goto L_002A;
  L_0029:;
    K = 10;
  L_002A:;

  //   198         ->eof %if k<0

    if ((K) >= (0)) goto L_002B;
    goto U_1000;
  L_002B:;

  //   199         load fp(k);  fp = fp+1

    LOADFP(K);
    FP = FP + 1;

    //   200      %repeat %until k = nl

    if ((K) == (10)) goto L_002C;
    goto L_0028;
  L_002C:;

  //   201      fend = fp; lend = fend-1

    FEND = FP;
    LEND = FEND - 1;

    //   202      fp = bot-sextra+1

    FP = BOT - 122 + 1;

    //   203      select input(0)

    _imp_SELECTINPUT(0);

    //   204      %return

    _imp_return;

    //   205  eof:fp = bot;  lend = fp;  fend = lend

  U_1000:;
    FP = BOT;
    LEND = FP;
    FEND = LEND;

    //   206      load fp(nl)

    LOADFP(10);

    //   207      select input(0)

    _imp_SELECTINPUT(0);

    //   208  %end

    _imp_return;
    _imp_begin_backtrace(READLINE);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_bt_int(K);
    _imp_end_backtrace();
  } /* end of READLINE */

  //   209
  //   210  %routine switch inputs

  void SWITCHINPUTS(void) {
    _imp_enter(SWITCHINPUTS);

    //   211  %owninteger mfp,mlend,mend,sfp,send

    static int MFP;
    static int MLEND;
    static int MEND;
    static int SFP;
    static int SEND;

    //   212      %if in = min %start

    if ((IN) != (1)) goto L_002D;

      //   213         left star

    LEFTSTAR();

    //   214         in = sin

    IN = 2;

    //   215         mfp = fp;  mlend = lend;  mend = fend

    MFP = FP;
    MLEND = LEND;
    MEND = FEND;

    //   216         mainfp == mfp

    MAINFP = (int *)&MFP;
    //   217         bot = bot+sextra;  fp = sfp; fend = send

    BOT = BOT + 122;
    FP = SFP;
    FEND = SEND;

    //   218         read line

    READLINE();

    //   219      %finish %else %start

    goto L_002E;
  L_002D:;

  //   220         pp = lbeg

    PP = LBEG;

    //   221         in = min

    IN = 1;

    //   222         bot = bot-sextra;  sfp = fp;  send = fend

    BOT = BOT - 122;
    SFP = FP;
    SEND = FEND;

    //   223         fp = mfp;  lend = mlend;  fend = mend

    FP = MFP;
    LEND = MLEND;
    FEND = MEND;

    //   224         mainfp == fp

    MAINFP = (int *)&FP;
    //   225      %finish

  L_002E:;

  //   226  %end

    _imp_return;
    _imp_begin_backtrace(SWITCHINPUTS);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_bt_int(MFP);
    _imp_bt_int(MLEND);
    _imp_bt_int(MEND);
    _imp_bt_int(SFP);
    _imp_bt_int(SEND);
    _imp_end_backtrace();
  } /* end of SWITCHINPUTS */

  //   227
  //   228  %routine print line

  void PRINTLINE(void) {
    _imp_enter(PRINTLINE);

    //   229  %integer p

    int P = 0xFEFEFEFE;

    //   230      print1 = lend;  print2 = fp+pp

    PRINT1 = LEND;
    PRINT2 = FP + PP;

    //   231      p = lbeg

    P = LBEG;

    //   232      %cycle

  L_002F:;

  //   233         %if p = pp %start

    if ((P) != (PP)) goto L_0030;

      //   234            print symbol('^') %if p # lbeg %and num = 0

    if ((P) == (LBEG)) goto L_0031;
    if ((NUM) != (0)) goto L_0031;
    _imp_PRINTSYMBOL(94);
  L_0031:;

  //   235            p = fp

    P = FP;

    //   236         %finish

  L_0030:;

  //   237         %exit %if p = lend

    if ((P) != (LEND)) goto L_0032;
    goto L_0033;
  L_0032:;

  //   238         print symbol(byte(p))

    _imp_PRINTSYMBOL(BYTE[P - 1]);

    //   239         p = p+1

    P = P + 1;

    //   240      %repeat

    goto L_002F;
  L_0033:;

  //   241      print string("**END**") %if p = fend

    if ((P) != (FEND)) goto L_0034;
    _imp_printf("%s", "**END**");
  L_0034:;

  //   242      newline

    _imp_NEWLINE();

    //   243  %end

    _imp_return;
    _imp_begin_backtrace(PRINTLINE);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_bt_int(P);
    _imp_end_backtrace();
  } /* end of PRINTLINE */

  //   244
  //   245  %integerfn matched

  int MATCHED(void) {
    _imp_enter(MATCHED);

    //   246  %integer i,j,k,l,t1,fp1,lim

    int I = 0xFEFEFEFE;
    int J = 0xFEFEFEFE;
    int K = 0xFEFEFEFE;
    int L = 0xFEFEFEFE;
    int T1 = 0xFEFEFEFE;
    int FP1 = 0xFEFEFEFE;
    int LIM = 0xFEFEFEFE;

    //   247      lim = c(ci-3)&(\127);  t1 = c(text)

    LIM = C[CI - 3 - 1] & (~127);
    T1 = C[TEXT - 1];

    //   248  L1:  pp1 = pp;  fp1 = fp

  U_1001:;
    PP1 = PP;
    FP1 = FP;

    //   249      ->L3 %unless fp = ms %and (code='F' %or code='U')

    if ((FP) != (MS)) goto L_0035;
    if ((CODE) == (70)) goto L_0036;
    if ((CODE) == (85)) goto L_0036;
  L_0035:;
    goto U_1002;
  L_0036:;

  //   250      k = byte(fp)

    K = BYTE[FP - 1];

    //   251  L2:  load pp(k); fp = fp+1

  U_1003:;
    LOADPP(K);
    FP = FP + 1;

    //   252  L3:  ->L10 %if fp = lend

  U_1002:;
    if ((FP) != (LEND)) goto L_0037;
    goto U_1004;
  L_0037:;

  //   253      k = byte(fp)

    K = BYTE[FP - 1];

    //   254      ->L2 %unless k = t1

    if ((K) == (T1)) goto L_0038;
    goto U_1003;
  L_0038:;

  //   255      i = fp;  j = text

    I = FP;
    J = TEXT;

    //   256  L6:  i = i+1;  j = j-1

  U_1005:;
    I = I + 1;
    J = J - 1;

    //   257      l = c(j)

    L = C[J - 1];

    //   258      ->L6 %if byte(i) = l

    if ((BYTE[I - 1]) != (L)) goto L_0039;
    goto U_1005;
  L_0039:;

  //   259      ->L2 %if l # 0

    if ((L) == (0)) goto L_003A;
    goto U_1003;
  L_003A:;

  //   260      ms = fp;  ml = i

    MS = FP;
    ML = I;

    //   261      %result = 1

    _imp_result(1);

    //   262  L10: lim = lim-128

  U_1004:;
    LIM = LIM - 128;

    //   263      %if lim # 0 %and fp # fend %start

    if ((LIM) == (0)) goto L_003B;
    if ((FP) == (FEND)) goto L_003B;

      //   264         %if code # 'U' %start

    if ((CODE) == (85)) goto L_003C;

      //   265            load pp(nl);  lbeg = pp

    LOADPP(10);
    LBEG = PP;

    //   266         %finish %else pp = pp1

    goto L_003D;
  L_003C:;
    PP = PP1;
  L_003D:;

  //   267         fp = fp+1;  make space;  read line

    FP = FP + 1;
    MAKESPACE();
    READLINE();

    //   268         ->L1

    goto U_1001;

    //   269      %finish

  L_003B:;

  //   270      pp = pp1;  fp = fp1

    PP = PP1;
    FP = FP1;

    //   271      %result = 0

    _imp_result(0);

    //   272  %end

    _imp_begin_backtrace(MATCHED);
    _imp_diagf("\nLocal Variables:\n\n");
    _imp_bt_int(I);
    _imp_bt_int(J);
    _imp_bt_int(K);
    _imp_bt_int(L);
    _imp_bt_int(T1);
    _imp_bt_int(FP1);
    _imp_bt_int(LIM);
    _imp_end_backtrace();
  } /* end of MATCHED */

  //   273
  //   274
  //   275  !initialise
  //   276  %switch t(0:12)

  int T_index;
  int T_line;
  char *T_file;
  static const void *T[13] = {&&case_T_0,  &&case_T_1,  &&case_T_2,       &&case_T_3, &&case_T_4,
                              &&case_T_5,  &&case_T_6,  &&case_T_missing, &&case_T_8, &&case_T_9,
                              &&case_T_10, &&case_T_11, &&case_T_12};

  //   277  %switch s('A':'\')

  int S_index;
  int S_line;
  char *S_file;
  static const void *S[28] = {
      &&case_S_missing, &&case_S_66, &&case_S_missing, &&case_S_68, &&case_S_69, &&case_S_70,      &&case_S_71,
      &&case_S_missing, &&case_S_73, &&case_S_74,      &&case_S_75, &&case_S_76, &&case_S_77,      &&case_S_missing,
      &&case_S_79,      &&case_S_80, &&case_S_missing, &&case_S_82, &&case_S_83, &&case_S_84,      &&case_S_85,
      &&case_S_86,      &&case_S_87, &&case_S_88,      &&case_S_89, &&case_S_90, &&case_S_missing, &&case_S_92};

  //   278
  //   279  !%on %event 9 %start
  //   280  !    printstring("Caught event"); newline
  //   281  !    ->eof
  //   282  !%finish
  //   283
  //   284      select input(0)

  _imp_SELECTINPUT(0);

  //   285      pp = top-1;  load pp(nl);               !for bouncing off

  PP = TOP - 1;
  LOADPP(10);

  //   286      lbeg = pp;  mainfp == fp

  LBEG = PP;
  MAINFP = (int *)&FP;
  //   287      stored(1) = nl;  stored(65) = nl;  stored(129) = nl

  STORED[0] = 10;
  STORED[64] = 10;
  STORED[128] = 10;

  //   288      select output(0); print string("EDIT

  _imp_SELECTOUTPUT(0);
  _imp_printf("%s", "EDIT\n");

  //   289+ ")
  //   290      read line

  READLINE();

  //   291
  //   292  !read command line
  //   293
  //   294  L1:  prompt(">")

U_1006:;
  _imp_PROMPT(_imp_str_literal_size(31, ">"));

  //   295      read item; ->eof %if sym<0; ->L1 %if type = 1

  READITEM();
  if ((SYM) >= (0)) goto L_003E;
  goto U_1007;
L_003E:;
  if ((TYPE) != (1)) goto L_003F;
  goto U_1006;
L_003F:;

//   296      ci = cbase;  ti = tbase;  chain = 0

  CI = 1;
  TI = 120;
  CHAIN = 0;

  //   297      %if type = 0 %and cmax # 0 %start

  if ((TYPE) != (0)) goto L_0040;
  if ((CMAX) == (0)) goto L_0040;

    //   298         c(cmax+2) = num

  C[CMAX + 2 - 1] = NUM;

  //   299         read item;  ->er2 %if type # 1

  READITEM();
  if ((TYPE) == (1)) goto L_0041;
  goto U_1008;
L_0041:;

//   300         ->go

  goto U_1009;

  //   301      %finish

L_0040:;

//   302      %if sym = '%' %start

  if ((SYM) != (37)) goto L_0042;

    //   303         read sym; sym = sym-32 %if sym >= 96

  READSYM();
  if ((SYM) < (96)) goto L_0043;
  SYM = SYM - 32;
L_0043:;

//   304         code = sym;  ->er5 %if code<=32

  CODE = SYM;
  if ((CODE) > (32)) goto L_0044;
  goto U_100A;
L_0044:;

//   305         read item

  READITEM();

  //   306         ->t(symtype(code)>>4)

  T_line = __LINE__;
  T_file = __FILE__;
  T_index = (unsigned int)SYMTYPE[CODE - 33] >> 4;
  goto case_T_dispatch;

  //   307      %finish

L_0042:;

//   308  L2:  i = type&15;  ->er2 %if i < 4

U_1001:;
  I = TYPE & 15;
  if ((I) >= (4)) goto L_0046;
  goto U_1008;
L_0046:;

//   309      code = sym;  text = 0;  num = 1;        !default values

  CODE = SYM;
  TEXT = 0;
  NUM = 1;

  //   310      read item

  READITEM();

  //   311      ->t(i)

  T_line = __LINE__;
  T_file = __FILE__;
  T_index = I;
  goto case_T_dispatch;

  //   312  t(2):                                       !%x, %y, %z

case_T_2:;

//   313      ->er1 %if sym # '='

  if ((SYM) == (61)) goto L_0047;
  goto U_1002;
L_0047:;

//   314      i = (code-'X')<<6

  I = ((int)CODE - 88) << (((int)6) & 31);

  //   315      %cycle

L_0048:;

//   316         read sym

  READSYM();

  //   317         i = i+1;  stored(i) = sym

  I = I + 1;
  STORED[I - 1] = SYM;

  //   318         ->L1 %if sym = nl

  if ((SYM) != (10)) goto L_0049;
  goto U_1006;
L_0049:;

//   319      %repeat

  goto L_0048;

  //   320  t(3):                                       !%m, %f, %q

case_T_3:;

//   321      mon = 'M'-code

  MON = 77 - CODE;

  //   322      ->L1

  goto U_1006;

  //   323  t(4):                                       !find

case_T_4:;

//   324      num = 0 %unless type = 0

  if ((TYPE) == (0)) goto L_004A;
  NUM = 0;
L_004A:;

//   325  t(5):                                       !+del,trav,uncover

case_T_5:;

//   326      code = num<<7+code;  num = 1

  CODE = (((int)NUM) << (((int)7) & 31)) + CODE;
  NUM = 1;

  //   327      read item %if type = 0

  if ((TYPE) != (0)) goto L_004B;
  READITEM();
L_004B:;

//   328  t(6):                                       !+insert,subst,verify

case_T_6:;

//   329      ->er4 %if type # 3

  if ((TYPE) == (3)) goto L_004C;
  goto U_1003;
L_004C:;

//   330      text = ti;  i = sym

  TEXT = TI;
  I = SYM;

  //   331  L61: read sym

U_1004:;
  READSYM();

  //   332      %if sym # nl %start

  if ((SYM) == (10)) goto L_004D;

    //   333         %if sym # i %start

  if ((SYM) == (I)) goto L_004E;

    //   334            ->er6 %if ti <= ci

  if ((TI) > (CI)) goto L_004F;
  goto U_1005;
L_004F:;

//   335            c(ti) = sym;  ti = ti-1

  C[TI - 1] = SYM;
  TI = TI - 1;

  //   336            ->L61

  goto U_1004;

  //   337         %finish

L_004E:;

//   338      %finish %else %start

  goto L_0050;
L_004D:;

//   339         pend = sym

  PEND = SYM;

  //   340         ->er4 %unless code = 'S' %or code = 'I'

  if ((CODE) == (83)) goto L_0051;
  if ((CODE) == (73)) goto L_0051;
  goto U_1003;
L_0051:;

//   341      %finish

L_0050:;

//   342      ->er4 %if ti = text %and code # 'S'

  if ((TI) != (TEXT)) goto L_0052;
  if ((CODE) == (83)) goto L_0052;
  goto U_1003;
L_0052:;

//   343      c(ti) = 0;  ti = ti-1

  C[TI - 1] = 0;
  TI = TI - 1;

  //   344      ->L81

  goto U_100B;

  //   345  t(8):                                       !move,erase

case_T_8:;

//   346      ->L100 %unless sym = '-'

  if ((SYM) == (45)) goto L_0053;
  goto U_100C;
L_0053:;

//   347      code = code+10

  CODE = CODE + 10;

  //   348  L81: read item

U_100B:;
  READITEM();

  //   349      ->L101

  goto U_100D;

  //   350  t(9):                                       !close bracket

case_T_9:;

//   351      unchain;  ->er3 %if text = 0

  UNCHAIN();
  if ((TEXT) != (0)) goto L_0054;
  goto U_100E;
L_0054:;

//   352      code = 'Z'; c(text+2) = num

  CODE = 90;
  C[TEXT + 2 - 1] = NUM;

  //   353      text = text+3

  TEXT = TEXT + 3;

  //   354  t(10):                                      !+get,kill,etc.

case_T_10:;

//   355  L100:->er1 %if type = 3

U_100C:;
  if ((TYPE) != (3)) goto L_0055;
  goto U_1002;
L_0055:;

//   356  L101:read item %if type = 0

U_100D:;
  if ((TYPE) != (0)) goto L_0056;
  READITEM();
L_0056:;

//   357      ->put

  goto U_100F;

  //   358  t(11):                                      !open bracket

case_T_11:;

//   359      code = 'X'

  CODE = 88;

  //   360      ->L121

  goto U_1010;

  //   361  t(12):                                      !comma

case_T_12:;

//   362      code = 'Y'

  CODE = 89;

  //   363      read item %if type = 1

  if ((TYPE) != (1)) goto L_0057;
  READITEM();
L_0057:;

//   364  L121:text = chain;  chain = ci

U_1010:;
  TEXT = CHAIN;
  CHAIN = CI;

  //   365      num = 0

  NUM = 0;

  //   366  put:stack(code);  stack(text);  stack(num)

U_100F:;
  STACK(CODE);
  STACK(TEXT);
  STACK(NUM);

  //   367      ->er6 %if ci+4 >= ti

  if ((CI + 4) < (TI)) goto L_0058;
  goto U_1005;
L_0058:;

//   368      ->L2 %unless type = 1

  if ((TYPE) == (1)) goto L_0059;
  goto U_1001;
L_0059:;

//   369      unchain;  ->er3 %if text # 0

  UNCHAIN();
  if ((TEXT) == (0)) goto L_005A;
  goto U_100E;
L_005A:;

//   370      cmax = ci

  CMAX = CI;

  //   371      stack('Z');  stack(cbase);  stack(1);   !extra close b

  STACK(90);
  STACK(1);
  STACK(1);

  //   372      stack(0)

  STACK(0);

  //   373      ->go

  goto U_1009;

  //   374
  //   375  !command input error reports
  //   376
  //   377  er1:space;  print symbol(code)

U_1002:;
  _imp_SPACE();
  _imp_PRINTSYMBOL(CODE);

  //   378  er2:code = sym

U_1008:;
  CODE = SYM;

  //   379      ->er5

  goto U_100A;

  //   380  er3:print string(" ()")

U_100E:;
  _imp_printf("%s", " ()");

  //   381      ->er7

  goto U_1011;

  //   382  er4:print string(" TEXT FOR")

U_1003:;
  _imp_printf("%s", " TEXT FOR");

  //   383  t(0):

case_T_0:;

//   384  er5:space;  print symbol(code&127)

U_100A:;
  _imp_SPACE();
  _imp_PRINTSYMBOL(CODE & 127);

  //   385      ->er7

  goto U_1011;

  //   386  er6:print string(" SIZE")

U_1005:;
  _imp_printf("%s", " SIZE");

  //   387  er7:print symbol('?')

U_1011:;
  _imp_PRINTSYMBOL(63);

  //   388      newline;  cmax = 0 %if ci # cbase

  _imp_NEWLINE();
  if ((CI) == (1)) goto L_005B;
  CMAX = 0;
L_005B:;

//   389  L10: ->L1 %if sym<32

U_1012:;
  if ((SYM) >= (32)) goto L_005C;
  goto U_1006;
L_005C:;

//   390      read sym

  READSYM();

  //   391      ->L10

  goto U_1012;

  //   392
  //   393  !execute command line
  //   394
  //   395  go: ci = cbase

U_1009:;
  CI = 1;

  //   396  get:code = c(ci)&127;  ->L99 %if code = 0

U_1013:;
  CODE = C[CI - 1] & 127;
  if ((CODE) != (0)) goto L_005D;
  goto U_1014;
L_005D:;

//   397      text = c(ci+1)

  TEXT = C[CI + 1 - 1];

  //   398      num = c(ci+2)

  NUM = C[CI + 2 - 1];

  //   399      ci = ci+3

  CI = CI + 3;

  //   400  rep:num = num-1

U_1015:;
  NUM = NUM - 1;

  //   401      ->s(code)

  S_line = __LINE__;
  S_file = __FILE__;
  S_index = CODE;
  goto case_S_dispatch;

  //   402  ok: ->rep %unless num = 0 %or num = stop

U_1016:;
  if ((NUM) == (0)) goto L_005F;
  if ((NUM) == (-5000)) goto L_005F;
  goto U_1015;
L_005F:;

//   403      ->get

  goto U_1013;

  //   404  s('\'):                                     !invert

case_S_92:;

//   405  no: ->get %if num < 0

U_1017:;
  if ((NUM) >= (0)) goto L_0060;
  goto U_1013;
L_0060:;

//   406      ci = ci+3 %and ->get %if c(ci) = '\'

  if ((C[CI - 1]) != (92)) goto L_0061;
  CI = CI + 3;
  goto U_1013;
L_0061:;

//   407  skp:i = c(ci);  ci = c(ci+1) %if i = 'X'

U_1018:;
  I = C[CI - 1];
  if ((I) != (88)) goto L_0062;
  CI = C[CI + 1 - 1];
L_0062:;

//   408      ci = ci+3

  CI = CI + 3;

  //   409      num = c(ci-1)-1 %and ->no %if i > 'X'

  if ((I) <= (88)) goto L_0063;
  NUM = C[CI - 1 - 1] - 1;
  goto U_1017;
L_0063:;

//   410      ->skp %if i # 0

  if ((I) == (0)) goto L_0064;
  goto U_1018;
L_0064:;

//   411
//   412  !execution error report
//   413
//   414      print string("FAILURE: ")

  _imp_printf("%s", "FAILURE: ");

  //   415      %if code='O' %or code='W' %start

  if ((CODE) == (79)) goto L_0065;
  if ((CODE) != (87)) goto L_0066;
L_0065:;

//   416         print symbol(code-10);  code = '-'

  _imp_PRINTSYMBOL(CODE - 10);
  CODE = 45;

  //   417      %finish

L_0066:;

//   418      print symbol(code)

  _imp_PRINTSYMBOL(CODE);

  //   419      %if text # 0 %start

  if ((TEXT) == (0)) goto L_0067;

    //   420         print symbol('''')

  _imp_PRINTSYMBOL(39);

  //   421         %while c(text) # 0 %cycle

L_0068:;
  if ((C[TEXT - 1]) == (0)) goto L_0069;

    //   422            print symbol(c(text))

  _imp_PRINTSYMBOL(C[TEXT - 1]);

  //   423            text = text-1

  TEXT = TEXT - 1;

  //   424         %repeat

  goto L_0068;
L_0069:;

//   425         print symbol('''')

  _imp_PRINTSYMBOL(39);

  //   426      %finish

L_0067:;

//   427      newline

  _imp_NEWLINE();

  //   428      print1 = 0

  PRINT1 = 0;

  //   429
  //   430  !end of command line
  //   431
  //   432  L99: ->L1 %if sym # nl

U_1014:;
  if ((SYM) == (10)) goto L_006A;
  goto U_1006;
L_006A:;

//   433      ->L1 %unless (mon>=0 %and print1#lend) %or (mon>0 %and print2#fp+pp)

  if ((MON) < (0)) goto L_006B;
  if ((PRINT1) != (LEND)) goto L_006C;
L_006B:;
  if ((MON) <= (0)) goto L_006D;
  if ((PRINT2) != (FP + PP)) goto L_006C;
L_006D:;
  goto U_1006;
L_006C:;

//   434      num = 0; print line

  NUM = 0;
  PRINTLINE();

  //   435      ->L1

  goto U_1006;

  //   436
  //   437  !individual commands
  //   438
  //   439  s('X'):                                     !open bracket

case_S_88:;

//   440      c(text+2) = num+1

  C[TEXT + 2 - 1] = NUM + 1;

  //   441      ->get

  goto U_1013;

  //   442  s('Z'):                                     !close bracket

case_S_90:;

//   443      ->get %if num = 0 %or num = stop

  if ((NUM) == (0)) goto L_006E;
  if ((NUM) != (-5000)) goto L_006F;
L_006E:;
  goto U_1013;
L_006F:;

//   444      c(ci-1) = num

  C[CI - 1 - 1] = NUM;

  //   445  s('Y'):                                     !+comma

case_S_89:;

//   446      ci = text

  CI = TEXT;

  //   447      ->get

  goto U_1013;

  //   448  s('R'):                                     !right shift

case_S_82:;

//   449      ->no %if fp = lend

  if ((FP) != (LEND)) goto L_0070;
  goto U_1017;
L_0070:;

//   450      load pp(byte(fp));  fp = fp+1

  LOADPP(BYTE[FP - 1]);
  FP = FP + 1;

  //   451      ->ok

  goto U_1016;

  //   452  s('L'):                                     !left shift

case_S_76:;

//   453      ->no %if in = sin %or pp = lbeg

  if ((IN) == (2)) goto L_0071;
  if ((PP) != (LBEG)) goto L_0072;
L_0071:;
  goto U_1017;
L_0072:;

//   454      fp = fp-1;  pp = pp-1;  load fp(byte(pp))

  FP = FP - 1;
  PP = PP - 1;
  LOADFP(BYTE[PP - 1]);

  //   455      ms = 0

  MS = 0;

  //   456      ->ok

  goto U_1016;

  //   457  s('E'):                                     !erase

case_S_69:;

//   458      ->no %if fp = lend

  if ((FP) != (LEND)) goto L_0073;
  goto U_1017;
L_0073:;

//   459      fp = fp+1

  FP = FP + 1;

  //   460      ->ok

  goto U_1016;

  //   461  s('O'):                                     !erase back

case_S_79:;

//   462      ->no %if pp = lbeg

  if ((PP) != (LBEG)) goto L_0074;
  goto U_1017;
L_0074:;

//   463      pp = pp-1

  PP = PP - 1;

  //   464      ->ok

  goto U_1016;

  //   465  s('V'):                                     !verify

case_S_86:;

//   466      i = fp-1;  j = text+1

  I = FP - 1;
  J = TEXT + 1;

  //   467  v1: i = i+1; j = j-1

U_1019:;
  I = I + 1;
  J = J - 1;

  //   468      k = c(j)

  K = C[J - 1];

  //   469      ->v1 %if byte(i) = k

  if ((BYTE[I - 1]) != (K)) goto L_0075;
  goto U_1019;
L_0075:;

//   470      ->no %if k # 0

  if ((K) == (0)) goto L_0076;
  goto U_1017;
L_0076:;

//   471      ms = fp;  ml = i

  MS = FP;
  ML = I;

  //   472      ->ok

  goto U_1016;

  //   473  s('F'):                                     !find

case_S_70:;

//   474      ->no %if matched = 0

  if ((MATCHED()) != (0)) goto L_0077;
  goto U_1017;
L_0077:;

//   475      ->ok

  goto U_1016;

  //   476  s('U'):                                     !uncover

case_S_85:;

//   477      ->no %if matched = 0;  pp = pp1

  if ((MATCHED()) != (0)) goto L_0078;
  goto U_1017;
L_0078:;
  PP = PP1;

  //   478      ->ok

  goto U_1016;

  //   479  s('D'):                                     !delete

case_S_68:;

//   480      ->no %if matched = 0;  fp = ml

  if ((MATCHED()) != (0)) goto L_0079;
  goto U_1017;
L_0079:;
  FP = ML;

  //   481      ->ok

  goto U_1016;

  //   482  s('T'):                                     !traverse

case_S_84:;

//   483      ->no %if matched = 0

  if ((MATCHED()) != (0)) goto L_007A;
  goto U_1017;
L_007A:;

//   484  s('S'):                                     !+substitute

case_S_83:;

//   485      fp = ml %if fp = ms

  if ((FP) != (MS)) goto L_007B;
  FP = ML;
L_007B:;

//   486  s('I'):                                     !+insert

case_S_73:;

//   487      make space

  MAKESPACE();

  //   488  !!  ->no %if pp-lbeg+lend-fp > 80
  //   489      i = text

  I = TEXT;

  //   490  i1: ->ok %if c(i) = 0

U_101A:;
  if ((C[I - 1]) != (0)) goto L_007C;
  goto U_1016;
L_007C:;

//   491      load pp(c(i));  i = i-1

  LOADPP(C[I - 1]);
  I = I - 1;

  //   492      ->i1

  goto U_101A;

  //   493  s('G'):                                     !get (line from tt)

case_S_71:;

//   494      prompt(":")

  _imp_PROMPT(_imp_str_literal_size(31, ":"));

  //   495  !!  make space
  //   496      read symbol(i)

  _imp_READSYMBOL(&I);

  //   497      ->no %if i = ':'

  if ((I) != (58)) goto L_007D;
  goto U_1017;
L_007D:;

//   498      left star

  LEFTSTAR();

  //   499      %while i # nl %cycle

L_007E:;
  if ((I) == (10)) goto L_007F;

    //   500         load pp(i)

  LOADPP(I);

  //   501         read symbol(i)

  _imp_READSYMBOL(&I);

  //   502      %repeat

  goto L_007E;
L_007F:;

//   503  s('B'):                                     !+break (insert newline)

case_S_66:;

//   504      make space

  MAKESPACE();

  //   505      load pp(nl);  lbeg = pp

  LOADPP(10);
  LBEG = PP;

  //   506      ->ok

  goto U_1016;

  //   507  s('P'):                                     !print

case_S_80:;

//   508      print line

  PRINTLINE();

  //   509      ->get %if num = 0

  if ((NUM) != (0)) goto L_0080;
  goto U_1013;
L_0080:;

//   510  s('M'):                                     !+move

case_S_77:;

//   511      right star

  RIGHTSTAR();

  //   512      ->no %if fp = fend

  if ((FP) != (FEND)) goto L_0081;
  goto U_1017;
L_0081:;

//   513      load pp(nl); lbeg = pp

  LOADPP(10);
  LBEG = PP;

  //   514  m1: fp = fp+1;  make space;  read line

U_101B:;
  FP = FP + 1;
  MAKESPACE();
  READLINE();

  //   515      ->ok

  goto U_1016;

  //   516  s('K'):                                     !kill (line)

case_S_75:;

//   517      pp = lbeg;  fp = lend

  PP = LBEG;
  FP = LEND;

  //   518  k1: ->no %if fp = fend

U_101C:;
  if ((FP) != (FEND)) goto L_0082;
  goto U_1017;
L_0082:;

//   519      ->m1

  goto U_101B;

  //   520  s('J'):                                     !join (delete newline)

case_S_74:;

//   521      right star

  RIGHTSTAR();

  //   522  !!  ->no %if pp-lbeg > 80
  //   523      ->k1

  goto U_101C;

  //   524  s('W'):                                     !move back

case_S_87:;

//   525      ->no %if in = sin

  if ((IN) != (2)) goto L_0083;
  goto U_1017;
L_0083:;

//   526      make space

  MAKESPACE();

  //   527      ->no %if lbeg = top

  if ((LBEG) != (TOP)) goto L_0084;
  goto U_1017;
L_0084:;

//   528      lend = fp-pp+lbeg-1

  LEND = FP - PP + LBEG - 1;

  //   529  w1: k = byte(pp-1)

U_101D:;
  K = BYTE[PP - 1 - 1];

  //   530      ->w2 %if k = nl %and pp # lbeg

  if ((K) != (10)) goto L_0085;
  if ((PP) == (LBEG)) goto L_0085;
  goto U_101E;
L_0085:;

//   531      fp = fp-1;  pp = pp-1;  load fp(k)

  FP = FP - 1;
  PP = PP - 1;
  LOADFP(K);

  //   532      ->w1

  goto U_101D;

  //   533  w2: lbeg = pp;  ms = 0

U_101E:;
  LBEG = PP;
  MS = 0;

  //   534      ->ok

  goto U_1016;

  //   535  t(1):                                       !%s, %c ...

case_T_1:;

//   536      ->eof %if code = 'C'

  if ((CODE) != (67)) goto L_0086;
  goto U_1007;
L_0086:;

//   537      switch inputs

  SWITCHINPUTS();

  //   538      ->L99

  goto U_1014;

  //   539  eof:code = 'C';                             !+eof on command stream

U_1007:;
  CODE = 67;

  //   540      switch inputs %if in = sin

  if ((IN) != (2)) goto L_0087;
  SWITCHINPUTS();
L_0087:;

//   541      %cycle

L_0088:;

//   542         right star

  RIGHTSTAR();

  //   543         %exit %if fp = fend

  if ((FP) != (FEND)) goto L_0089;
  goto L_008A;
L_0089:;

//   544         load pp(nl);  lbeg = pp

  LOADPP(10);
  LBEG = PP;

  //   545         fp = fp+1;  make space;  read line

  FP = FP + 1;
  MAKESPACE();
  READLINE();

  //   546      %repeat

  goto L_0088;
L_008A:;

//   547      select output(mout)

  _imp_SELECTOUTPUT(1);

  //   548      %while top # pp %cycle

L_008B:;
  if ((TOP) == (PP)) goto L_008C;

    //   549         print symbol(byte(top));  top = top+1

  _imp_PRINTSYMBOL(BYTE[TOP - 1]);
  TOP = TOP + 1;

  //   550      %repeat

  goto L_008B;
L_008C:;

//   551      select output(0)

  _imp_SELECTOUTPUT(0);

  //   552      %if code # 'C' %then %monitor

  if ((CODE) == (67)) goto L_008D;
  _imp_monitor_loc(__LINE__, __FILE__, __PRETTY_FUNCTION__);
L_008D:;

//   553  %end

  _imp_stop(0);

case_T_dispatch:
  if (T_index < 0 || T_index > 12)
    _imp_signalf(6, 3, T_index, "->T(%d) out of bounds at %s line %d", T_index, T_file, T_line);
  goto *T[T_index - 0];

case_T_missing:
  _imp_signalf(8, 2, T_index, "switch jump to undefined label T(%d): at %s line %d", T_index, T_file, T_line);

case_S_dispatch:
  if (S_index < 65 || S_index > 92)
    _imp_signalf(6, 3, S_index, "->S(%d) out of bounds at %s line %d", S_index, S_file, S_line);
  goto *S[S_index - 65];

case_S_missing:
  _imp_signalf(8, 2, S_index, "switch jump to undefined label S(%d): at %s line %d", S_index, S_file, S_line);
end_0:;
  _imp_begin_backtrace(main);
  _imp_diagf("\n\nArguments:\n\n");
  _imp_diagf("ARGC = %d\n", argc);
  _imp_diagf("ARGV @[%p]\n", argv);
  for (int i = 0; i < argc; i++) {
    _imp_diagf("  ARGV(%d) = \"%s\"\n", i, argv[i]);
  }
  if (argv[argc] == 0) {
    _imp_diagf("  ARGV(%d) = NULL\n", argc);
  } else {
    _imp_diagf("  ARGV(%d) = \"%s\"\n", argc, argv[argc]);
  }
  _imp_diagf("\nLocal Variables:\n\n");
  _imp_bt_int(IN);
  _imp_bt_int(MON);
  _imp_bt_int(PRINT1);
  _imp_bt_int(PRINT2);
  _imp_bt_int(I);
  _imp_bt_int(J);
  _imp_bt_int(K);
  _imp_bt_int(PP1);
  _imp_bt_int(SYM);
  _imp_bt_int(CODE);
  _imp_bt_int(TEXT);
  _imp_bt_int(NUM);
  if (MAINFP == 0) {
    _imp_diagf("MAINFP @[<NIL>]\n");
  } else if (_imp_unassigned(MAINFP)) {
    _imp_diagf("MAINFP @[<UNASSIGNED POINTER>]\n");
  } else {
    if (_imp_unassigned(*MAINFP)) {
      _imp_diagf("MAINFP @[%p] = <UNASSIGNED INTEGER>\n", MAINFP);
    } else {
      _imp_diagf("MAINFP @[%p] = %d\n", MAINFP, *(int *)MAINFP);
    }
  }
  _imp_bt_int(CI);
  _imp_bt_int(TI);
  _imp_bt_int(CMAX);
  _imp_bt_int(POS1);
  _imp_bt_int(POS2);
  _imp_bt_int(POS3);
  _imp_bt_int(TOP);
  _imp_bt_int(BOT);
  _imp_bt_int(LBEG);
  _imp_bt_int(PP);
  _imp_bt_int(FP);
  _imp_bt_int(LEND);
  _imp_bt_int(FEND);
  _imp_bt_int(MS);
  _imp_bt_int(ML);
  _imp_bt_int(TYPE);
  _imp_bt_int(CHAIN);
  _imp_bt_int(PEND);
  _imp_end_backtrace();
  _imp_stop(0);
}

//   554
//   555  %endoffile