#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  %externalroutine toplev

void TOPLEV(void) {
  //     2    %longreal lr1

  double LR1;

  //     3    %integer i, i1 = 1, i2 = 2, i3 = 3

  int I;
  int I1;
  I1 = 1;
  int I2;
  I2 = 2;
  int I3;
  I3 = 3;

  //     4
  //     5    i = i1 %while i2 = i3

L_0001:;
  if (I2 != I3) goto L_0002;
  I = I1;
  goto L_0001;
L_0002:;

//     6    i = i1 %until i2 = i3

L_0003:;
  I = I1;
  if (I2 == I3) goto L_0004;
  goto L_0003;
L_0004:;

//     7    i = i1 %for i2 = i3, 1, i1

  // %for I2 = I3, 1, I1 %cycle
  {
    int _initial = I3, _final = I1;
    if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I2 = I3, 1, I1");
    I2 = _initial - (1);
  L_0005:
    if (I2 == _final) goto L_0006;
    I2 += 1;
    I = I1;
    goto L_0005;
  }

L_0006:;

//     8
//     9    %while i2 = i3 %then i = i1

L_0008:;
  if (I2 != I3) goto L_0009;
  I = I1;
  goto L_0008;
L_0009:;

//    10    ! ILLEGAL IMP77: %until i2 = i3 %then i = i1
//    11
//    12    ! This is legal Imp77 but my parser doesn't accept it.  FIX IT.
//    13    !%for i2 = i3, 1, i1 %then i = i1
//    14
//    15    %while i1 = i2 %cycle

L_000A:;
  if (I1 != I2) goto L_000B;

    //    16      i = i1

  I = I1;

  //    17    %repeat

  goto L_000A;
L_000B:;

//    18
//    19    ! ILLEGAL IMP77:
//    20    !%until i1 = i2 %cycle
//    21    !  i = i1
//    22    !%repeat
//    23
//    24    %cycle

L_000C:;

//    25      i = i1

  I = I1;

  //    26    %repeat %until i1 = i2

  if (I1 == I2) goto L_000D;
  goto L_000C;
L_000D:;

//    27
//    28    %for i2 = i3, 1, i1 %cycle

  // %for I2 = I3, 1, I1 %cycle
  {
    int _initial = I3, _final = I1;
    if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I2 = I3, 1, I1");
    I2 = _initial - (1);
  L_000E:
    if (I2 == _final) goto L_000F;
    I2 += 1;

    //    29      i = i1

    I = I1;

    //    30    %repeat

    goto L_000E;
  }

L_000F:;

//    31
//    32    %while i1 = i2 %cycle

L_0010:;
  if (I1 != I2) goto L_0011;

    //    33      i = i1

  I = I1;

  //    34    %repeat;! temp disabled: %until i2 = i3

  goto L_0010;
L_0011:;

//    35
//    36    ! ILLEGAL IMP77:
//    37    !%until i1 = i2 %cycle
//    38    !  i = i1
//    39    !%repeat %until i2 = i3
//    40
//    41  lab7:

U_1000:;

//    42
//    43    %for i2 = i3, 1, i1 %cycle

  // %for I2 = I3, 1, I1 %cycle
  {
    int _initial = I3, _final = I1;
    if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I2 = I3, 1, I1");
    I2 = _initial - (1);
  L_0012:
    if (I2 == _final) goto L_0013;
    I2 += 1;

    //    44      i = i1

    I = I1;

    //    45    %repeat;! temp disabled: %until i2 = i3

    goto L_0012;
  }

L_0013:;

//    46
//    47
//    48
//    49
//    50    i = i1 %and i1 = i2 %while i2 = i3

L_0014:;
  if (I2 != I3) goto L_0015;
  I = I1;
  I1 = I2;
  goto L_0014;
L_0015:;

//    51    i = i1 %and i1 = i2 %until i2 = i3

L_0016:;
  I = I1;
  I1 = I2;
  if (I2 == I3) goto L_0017;
  goto L_0016;
L_0017:;

//    52
//    53  lab3:

U_1001:;

//    54
//    55    i = i1 %and i1 = i2 %for i2 = i3, 1, i1

  // %for I2 = I3, 1, I1 %cycle
  {
    int _initial = I3, _final = I1;
    if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I2 = I3, 1, I1");
    I2 = _initial - (1);
  L_0018:
    if (I2 == _final) goto L_0019;
    I2 += 1;
    I = I1;
    I1 = I2;
    goto L_0018;
  }

L_0019:;

//    56
//    57  lab4:

U_1002:;

//    58
//    59    %while i2 = i3 %then i = i1 %and i1 = i2

L_001A:;
  if (I2 != I3) goto L_001B;
  I = I1;
  I1 = I2;
  goto L_001A;
L_001B:;

//    60    ! ILLEGAL IMP77: %until i2 = i3 %then i = i1 %and i1 = i2
//    61
//    62  lab5:

U_1003:;

//    63
//    64    ! This is legal Imp77 but my parser doesn't accept it.  FIX IT.
//    65    !%for i2 = i3, 1, i1 %then i = i1 %and i1 = i2
//    66
//    67    %while i1 = i2 %cycle

L_001C:;
  if (I1 != I2) goto L_001D;

    //    68      i = i1 ; i1 = i2

  I = I1;
  I1 = I2;

  //    69    %repeat

  goto L_001C;
L_001D:;

//    70
//    71    ! ILLEGAL IMP77:
//    72    !%until i1 = i2 %cycle
//    73    !  i = i1 ; i1 = i2
//    74    !%repeat
//    75
//    76  lab6:

U_1004:;

//    77
//    78    %cycle

L_001E:;

//    79      i = i1 ; i1 = i2

  I = I1;
  I1 = I2;

  //    80    %repeat %until i1 = i2

  if (I1 == I2) goto L_001F;
  goto L_001E;
L_001F:;

//    81
//    82  lab2:

U_1005:;

//    83
//    84    %for i2 = i3, 1, i1 %cycle

  // %for I2 = I3, 1, I1 %cycle
  {
    int _initial = I3, _final = I1;
    if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I2 = I3, 1, I1");
    I2 = _initial - (1);
  L_0020:
    if (I2 == _final) goto L_0021;
    I2 += 1;

    //    85      i = i1 ; i1 = i2

    I = I1;
    I1 = I2;

    //    86    %repeat

    goto L_0020;
  }

L_0021:;

//    87
//    88    %while i1 = i2 %cycle

L_0022:;
  if (I1 != I2) goto L_0023;

    //    89      i = i1 ; i1 = i2

  I = I1;
  I1 = I2;

  //    90    %repeat;! temp disabled: %until i2 = i3

  goto L_0022;
L_0023:;

//    91
//    92    ! ILLEGAL IMP77:
//    93    !%until i1 = i2 %cycle
//    94    !  i = i1 ; i1 = i2
//    95    !%repeat %until i2 = i3
//    96
//    97  lab1:

U_1006:;

//    98
//    99    %for i2 = i3, 1, i1 %cycle

  // %for I2 = I3, 1, I1 %cycle
  {
    int _initial = I3, _final = I1;
    if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I2 = I3, 1, I1");
    I2 = _initial - (1);
  L_0024:
    if (I2 == _final) goto L_0025;
    I2 += 1;

    //   100      i = i1 ; i1 = i2

    I = I1;
    I1 = I2;

    //   101    %repeat;! temp disabled: %until i2 = i3

    goto L_0024;
  }

L_0025:;

//   102
//   103  %end

  return;
} /* end of TOPLEV */

// ?LAB1 unused
// ?LAB2 unused
// ?LAB6 unused
// ?LAB5 unused
// ?LAB4 unused
// ?LAB3 unused
// ?LAB7 unused
// ?LR1 unused
//   104  %endoffile