#include <perms.h>

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

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

  //     2  %real i,j

  float I;
  float J;

  //     3  %on %event 1,2,9 %start

  if (!_imp_on_event(1, 2, 9)) goto L_0001;

    //     4       ->trap

  goto U_1000;

  //     5  %finish

L_0001:;

//     6  i=2

  I = 2;

  //     7  %cycle

L_0002:;

//     8  j=i; i=I+I

  J = I;
  I = I + I;

  //     9  %if i<00.00001 %or j>=i %then printstring("Oflow missed") %and %stop

  if (I < 00.00001) goto L_0003;
  if (J < I) goto L_0004;
L_0003:;
  _imp_PRINTSTRING(_imp_str_literal("Oflow missed"));
  _imp_stop(0);
L_0004:;

//    10  %repeat

  goto L_0002;

  //    11  printstring("FAIL")

  _imp_PRINTSTRING(_imp_str_literal("FAIL"));

  // ?access
  //    12  %stop

  _imp_stop(0);

  //    13  trap:

U_1000:;

//    14  printstring("event trapped ")

  _imp_PRINTSTRING(_imp_str_literal("event trapped "));

  //    15  write(eventinf>>8,5); write(eventinf&255,5)

  _imp_WRITE((unsigned int)_imp_EVENTINF() >> 8, 5);
  _imp_WRITE(_imp_EVENTINF() & 255, 5);

  //    16  newline

  _imp_NEWLINE();

  //    17  printstring("Line of failure =")

  _imp_PRINTSTRING(_imp_str_literal("Line of failure ="));

  //    18  write(eventline,4)

  _imp_WRITE(_imp_EVENTLINE(), 4);

  //    19  newline

  _imp_NEWLINE();

  //    20  printstring("Test OK")

  _imp_PRINTSTRING(_imp_str_literal("Test OK"));

  //    21  %endofprogram

  _imp_stop(0);
  return 0;
end_0:;
}