#include <perms.h>

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

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

  //     2  %externalinteger fredfred

  int FREDFRED;

  //     3  %routine fred(%integer opcode)

  void FRED(int OPCODE) {
    //     4  %externalintegerspec fredfred

    extern int FREDFRED;

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

    int I;
    int J;
    int K;
    int L;

    //     6  %string(11) ts

    _imp_string11 TS;

    //     7        ts="abcdef"


    /* clang-format off */
_imp_strncpy(/*?*/&TS, ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("abcdef"); (void *)&tmp;}), /*max:*/11);

    /* clang-format on */

    //     8  i=1; j=2; k=3

    I = 1;
    J = 2;
    K = 3;

    //     9  write(fredfred,5)

    _imp_WRITE(FREDFRED, 5);

    //    10  %if opcode=x'9a' %or X'e8'<=opcode<=x'e9' %or x'81'<=opcode<=x'89' %then printstring("Test ok")

    if (OPCODE == 154) goto L_0001;
    {
      // Double-sided test on OPCODE (Part I)
      int tmp;
      if (232 > (tmp = OPCODE)) goto L_0002;
      // Double-sided test on OPCODE (Part II)
      if (tmp <= 233) goto L_0001;
    }
  L_0002:;
    {
      // Double-sided test on OPCODE (Part I)
      int tmp;
      if (129 > (tmp = OPCODE)) goto L_0003;
      // Double-sided test on OPCODE (Part II)
      if (tmp > 137) goto L_0003;
    }
  L_0001:;
    _imp_PRINTSTRING(_imp_str_literal("Test ok"));
  L_0003:;

  //    11  newline

    _imp_NEWLINE();

    //    12  %end

    return;
  } /* end of FRED */

  // ?L unused
  //    13  fredfred=5

  FREDFRED = 5;

  //    14  fred(x'e8')

  FRED(232);

  //    15  %endofprogram

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