#include <perms.h>

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

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

  //     2
  //     3    %integerfn getchar

  int GETCHAR(void) {
    //     4      %integer sym

    int SYM;

    //     5      readsymbol(sym)

    _imp_READSYMBOL(/*?*/ &SYM);

    //     6      printstring("Call returned "); printsymbol(sym); newline

    _imp_PRINTSTRING(_imp_str_literal("Call returned "));
    _imp_PRINTSYMBOL(SYM);
    _imp_NEWLINE();

    //     7      %result = sym

    return SYM;

    //     8    %end

  } /* end of GETCHAR */

  //     9
  //    10    printstring("Please enter the word BUG when I ask for data:"); newline

  _imp_PRINTSTRING(_imp_str_literal("Please enter the word BUG when I ask for data:"));
  _imp_NEWLINE();

  //    11
  //    12    %if 'A' <= getchar <= 'C' %start

  {
// Double-sided test on GETCHAR() (Part I)
    int tmp;
    if (65 > (tmp = GETCHAR())) goto L_0001;
// Double-sided test on GETCHAR() (Part II)
    if (tmp > 67) goto L_0001;
  }

  //    13      printstring("Test successful."); newline

  _imp_PRINTSTRING(_imp_str_literal("Test successful."));
  _imp_NEWLINE();

  //    14    %else

  goto L_0002;
L_0001:;

//    15      printstring("Test failed - getchar was called twice."); newline

  _imp_PRINTSTRING(_imp_str_literal("Test failed - getchar was called twice."));
  _imp_NEWLINE();

  //    16    %finish

L_0002:;

//    17
//    18  %endofprogram

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