#include <perms.h>

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

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

  //     2    %routine do hanoi(%integer n, f, t, u)

  void DOHANOI(int N, int F, int T, int U) {
    //     3      do hanoi(n - 1, f, u, t) %if n >= 2

    if (N < 2) goto L_0001;
    DOHANOI(N - 1, F, U, T);
  L_0001:;

  //     4      print string("Move disk from ".itos(f,0)." to ".itos(t,0).to string(nl))

    _imp_PRINTSTRING(
        /* clang-format off */
*({  __typeof__(_imp_string255) tmp = *({_imp_string255 tmp = _imp_join((_imp_string *)/*?*/&*({_imp_string255 tmp = _imp_join((_imp_string *)/*?*/&*({_imp_string255 tmp = _imp_join((_imp_string *)/*?*/&*({_imp_string255 tmp = _imp_join((_imp_string *)/*?*/_imp_str_literal_ptr("Move disk from "), ({__typeof__(_imp_string255) tmp; /*E*/ tmp = _imp_ITOS(F, 0); (void *)&tmp;})); (_imp_string255 *)&tmp;}), (_imp_string *)/*?*/_imp_str_literal_ptr(" to ")); (_imp_string255 *)&tmp;}), ({__typeof__(_imp_string255) tmp; /*E*/ tmp = _imp_ITOS(T, 0); (void *)&tmp;})); (_imp_string255 *)&tmp;}), ({__typeof__(_imp_string1) tmp; /*E*/ tmp = _imp_TOSTRING(10); (void *)&tmp;})); (_imp_string255 *)&tmp;})/*q*/;  (_imp_string255 *)&tmp;  })
        /* clang-format on */
    );

    //     5      do hanoi(n - 1, u, t, f) %if n >= 2

    if (N < 2) goto L_0002;
    DOHANOI(N - 1, U, T, F);
  L_0002:;

  //     6    %end

    return;
  } /* end of DOHANOI */

  //     7    do hanoi(4, 1, 2, 3)

  DOHANOI(4, 1, 2, 3);

  //     8    print string("Towers of Hanoi puzzle completed!".to string(nl))

  _imp_PRINTSTRING(
      /* clang-format off */
*({  __typeof__(_imp_string255) tmp = *({_imp_string255 tmp = _imp_join((_imp_string *)/*?*/_imp_str_literal_ptr("Towers of Hanoi puzzle completed!"), ({__typeof__(_imp_string1) tmp; /*E*/ tmp = _imp_TOSTRING(10); (void *)&tmp;})); (_imp_string255 *)&tmp;})/*q*/;  (_imp_string255 *)&tmp;  })
      /* clang-format on */
  );

  //     9  %end %of %program

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