#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  %externalintegerfn main

int MAIN(void) {
  //     2  %string (255) a, s

  _imp_string255 A;
  _imp_string255 S;

  //     3  %integer i, j, k, l;

  int I;
  int J;
  int K;
  int L;

  //     4  %integername p, q

  int *P;
  int *Q;

  //     5    i = 20; j = 25; k = 21; l = 27;

  I = 20;
  J = 25;
  K = 21;
  L = 27;

  //     6    p == j; q == l;

  P = (int *)/*?*/ &J;
  Q = (int *)/*?*/ &L;

  //     7    %cycle

L_0001:;

//     8      i = j; p = q

  I = J;
  *P = *Q;

  //     9    %repeat %until k=3 %or (i=p %and l=1)

  if (K == 3) goto L_0002;
  if (I != *P) goto L_0003;
  if (L == 1) goto L_0002;
L_0003:;
  goto L_0001;
L_0002:;

//    10    %begin

  { /*%begin*/

    //    11  !   %integerarray ia1(0 /* crashes if i */ :j)
    //    12      %integerarray ia1(0:l)

    int IA1[L + 1];
    struct _imp_dv IA1_dv = {IA1, sizeof(int) /*, dims, <bounds> */};

    //    13
    //    14      select input(0)

    _imp_SELECTINPUT(0);

    //    15      select output(0)

    _imp_SELECTOUTPUT(0);

    //    16      s = "1+1+1+1+1+1+1+1+1"


    /* clang-format off */
_imp_strncpy(/*?*/&S, ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("1+1+1+1+1+1+1+1+1"); (void *)&tmp;}), /*max:*/255);

    /* clang-format on */

    //    17      %while s -> a.("+").s %cycle

  L_0004:;
    if (!(_imp_resolve(*({
          _imp_string255 tmp = S;
          (_imp_string255 *)&tmp;
        }),
                       (_imp_string255 *)/*?*/ &A, *({
                         _imp_string tmp = _imp_str_literal("+");
                         (_imp_string255 *)&tmp;
                       }),
                       (_imp_string255 *)/*?*/ &S)))
      goto L_0005;

      //    18         readch(i)

    _imp_READCH(/*?*/ &I);

    //    19         %exit %if i < 0

    if (I >= 0) goto L_0006;
    goto L_0005;
  L_0006:;

  //    20         print symbol(i)

    _imp_PRINTSYMBOL(I);

    //    21      %repeat

    goto L_0004;
  L_0005:;

  //    22
  //    23      %cycle

  L_0007:;

  //    24         %exit %if i < 0

    if (I >= 0) goto L_0008;
    goto L_0009;
  L_0008:;

  //    25         print symbol(i)

    _imp_PRINTSYMBOL(I);

    //    26      %repeat %until %not s -> a.("+").s

    if (!(_imp_resolve(*({
          _imp_string255 tmp = S;
          (_imp_string255 *)&tmp;
        }),
                       (_imp_string255 *)/*?*/ &A, *({
                         _imp_string tmp = _imp_str_literal("+");
                         (_imp_string255 *)&tmp;
                       }),
                       (_imp_string255 *)/*?*/ &S)))
      goto L_0009;
    goto L_0007;
  L_0009:;

  //    27
  //    28      %for i = 0,1,10 %cycle

    // %for I = 0, 1, 10 %cycle
    {
      I = -1;
    L_000A:
      if (I == 10) goto L_000B;
      I += 1;

      // ?Non-local
      //    29         %exit %if i < 0

      if (I >= 0) goto L_000D;
      goto L_000B;
    L_000D:;

    //    30         print symbol(i)

      _imp_PRINTSYMBOL(I);

      //    31      %repeat

      goto L_000A;
    }

  L_000B:;

  //    32
  //    33      i = ia1(24)

    I = IA1[24];

    //    34    %end

    goto end_1000;
  end_1000:;
  }

  //    35    %stop

  _imp_stop(0);

  //    36  %end

} /* end of MAIN */

//    37
//    38  %endoffile