#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  %begin

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

  //     2    %integer i, j, k, l

  int I = 0xFEFEFEFE;
  int J = 0xFEFEFEFE;
  int K = 0xFEFEFEFE;
  int L = 0xFEFEFEFE;

  //     3
  //     4  userlab:

U_1000:;

//     5
//     6    printstring("until:")

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

  //     7    %cycle

L_0001:;

//     8      printstring("until exit:")

  _imp_printf("%s", "until exit:");

  //     9      %exitif i=k

  if ((I) != (K)) goto L_0002;
  goto L_0003;
L_0002:;

//    10      printstring("until continue:")

  _imp_printf("%s", "until continue:");

  //    11      %continueif k=l

  if ((K) != (L)) goto L_0004;
  goto L_0005;
L_0004:;

//    12      printstring("until repeat:")

  _imp_printf("%s", "until repeat:");

  //    13    %repeatuntil i=j

L_0005:;
  if ((I) == (J)) goto L_0003;
  goto L_0001;
L_0003:;

//    14
//    15    printstring("while:");

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

  //    16    %while j#k %cycle

L_0006:;
  if ((J) == (K)) goto L_0007;

    //    17      printstring("while exit:")

  _imp_printf("%s", "while exit:");

  //    18      %exitif i=k

  if ((I) != (K)) goto L_0008;
  goto L_0007;
L_0008:;

//    19      printstring("while continue:")

  _imp_printf("%s", "while continue:");

  //    20      %continueif k=l

  if ((K) != (L)) goto L_0009;
  goto L_000A;
L_0009:;

//    21      printstring("while repeat:")

  _imp_printf("%s", "while repeat:");

  //    22    %repeat

L_000A:;
  goto L_0006;
L_0007:;

//    23
//    24    printstring("for:");

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

  //    25    %for i = j,1,k %cycle

  // %for I = J, 1, K %cycle
  {
    int _initial = J, _final = K;
    if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I = J, 1, K");
    I = _initial - (1);
  L_000B:
    if (I == _final) goto L_000C;
    I += 1;

    //    26      printstring("for exit:")

    _imp_printf("%s", "for exit:");

    //    27      %exitif i=k

    if ((I) != (K)) goto L_000E;
    goto L_000C;
  L_000E:;

  //    28      printstring("for continue:")

    _imp_printf("%s", "for continue:");

    //    29      %continueif k=l

    if ((K) != (L)) goto L_000F;
    goto L_000D;
  L_000F:;

  //    30      printstring("for repeat:")

    _imp_printf("%s", "for repeat:");

    //    31    %repeat

  L_000D:;
    goto L_000B;
  }

L_000C:;

//    32
//    33  ->userlab

  goto U_1000;

  //    34
  //    35  %endofprogram

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(I);
  _imp_bt_int(J);
  _imp_bt_int(K);
  _imp_bt_int(L);
  _imp_end_backtrace();
  _imp_stop(0);
}