#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1
//     2  %BEGIN

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

  //     3  !***********************************************************************
  //     4  !*    A TEST TO CHECK THE LINE NUMBER OF A FAILURE AT RUN TIME         *
  //     5  !***********************************************************************
  //     6  %INTEGERARRAY A(0:4)

  int A[5];
  struct _imp_dv A_dv = {A, sizeof(int) /*, dims, <bounds> */};

  //     7  %INTEGER I

  int I;

  //     8  %on %event 1,2,3,4,5,6,7,8,9 %start

  if (!_imp_on_event(1, 2, 3, 4, 5, 6, 7, 8, 9)) goto L_0001;

    //     9  ->continue

  goto U_1000;

  //    10  %finish

L_0001:;

//    11  I=10

  I = 10;

  //    12  %IF 1<0 %THEN %START

  if (1 >= 0) goto L_0002;

    //    13        !
    //    14        !
    //    15        %STOP

  _imp_stop(0);

  //    16  %FINISH %ELSE A(I)=A(I)+1

L_0002:;
  A[I] = A[I] + 1;

  //    17        !
  //    18  continue:

U_1000:;

//    19  printstring("event trapped ")

  _imp_PRINTSTRING(_imp_str_literal("event trapped "));

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

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

  //    21  newline

  _imp_NEWLINE();

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

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

  //    23  write(eventline,4)

  _imp_WRITE(_imp_EVENTLINE(), 4);

  //    24  newline

  _imp_NEWLINE();

  //    25  %ENDOFPROGRAM

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