#include <perms.h>

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

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

  //     2    %string(255) s

  _imp_string255 S;

  //     3    %integer n

  int N;

  //     4
  //     5    %routine p1 (%string(*)%name k)

  void P1(_imp_string * K) {
    //     6      print string("p1: ")

    _imp_PRINTSTRING(_imp_str_literal("p1: "));

    //     7      print string(k)

    _imp_PRINTSTRING(
        /* clang-format off */
*({  __typeof__(_imp_string255) tmp = *K/*q*/;  (_imp_string255 *)&tmp;  })
        /* clang-format on */
    );

    //     8      newline

    _imp_NEWLINE();

    //     9    %end

    return;
  } /* end of P1 */

  //    10
  //    11    %routine p2 (%string(*)%name k)

  void P2(_imp_string * K) {
    //    12      print string("p2: ")

    _imp_PRINTSTRING(_imp_str_literal("p2: "));

    //    13      print string(k)

    _imp_PRINTSTRING(
        /* clang-format off */
*({  __typeof__(_imp_string255) tmp = *K/*q*/;  (_imp_string255 *)&tmp;  })
        /* clang-format on */
    );

    //    14      newline

    _imp_NEWLINE();

    //    15    %end

    return;
  } /* end of P2 */

  //    16
  //    17    %routine pass (%routine p (%string(*)%name k), %string(*)%name k)

  void PASS(void (*P)(_imp_string * K), _imp_string *K) {
    //    18      p(k)

    P((_imp_string255 *)/*p*/ K);

    //    19    %end

    return;
  } /* end of PASS */

  //    20
  //    21    %cycle

L_0001:;

//    22      read(n)

  _imp_READ(/*?*/ &N);

  //    23      read(s)

  _imp_READ(/*?*/ &S);

  //    24      %if n = 1 %start

  if (N != 1) goto L_0002;

    //    25        pass(p1,s)

  PASS(P1, (_imp_string255 *)/*p*/ /*?*/ &S);

  //    26      %else

  goto L_0003;
L_0002:;

//    27        pass(p2,s)

  PASS(P2, (_imp_string255 *)/*p*/ /*?*/ &S);

  //    28      %finish

L_0003:;

//    29      print string("test done")

  _imp_PRINTSTRING(_imp_str_literal("test done"));

  //    30      newline

  _imp_NEWLINE();

  //    31    %repeat

  goto L_0001;

  //    32
  //    33  %end

end_0:;
}

//    34  %end %of %file