#include <perms.h>

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

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

  //     2
  //     3    %routine do5(%string (5) %array (2) %name S)

  void DO5(_imp_string5 * S) {
    //     4      %string (10) x

    _imp_string10 X;

    //     5      x = S(2,12)


    /* clang-format off */
_imp_strncpy(/*?*/&X, ({__typeof__(_imp_string5) tmp;/*B*/ tmp = S[/*BUG*/12]; (void *)&tmp;}), /*max:*/10);

    /* clang-format on */

    //     6      print string(x)

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

    //     7
    //     8      ! This is failing at compile time:
    //     9      !print string(S(2,12))
    //    10
    //    11    %end

    return;
  } /* end of DO5 */

  //    12
  //    13    %routine do(%string (*) %array (2) %name S)

  void DO(_imp_string * S) {
    //    14      %string (10) x

    _imp_string10 X;

    //    15      ! and I expect this to fail at runtime, until I implement dopevectors
    //    16      x = S(2,12)


    /* clang-format off */
_imp_strncpy(/*?*/&X, ({__typeof__(_imp_string255) tmp;/*B*/ tmp = S[/*BUG*/12]; (void *)&tmp;}), /*max:*/10);

    /* clang-format on */

    //    17      print string(x)

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

    //    18    %end

    return;
  } /* end of DO */

  //    19
  //    20    %string (5) %array mnems(1:2, 10:13)

  _imp_string5 MNEMS[2][4];
  struct _imp_dv MNEMS_dv = {MNEMS, sizeof(_imp_string) /*, dims, <bounds> */};

  //    21
  //    22    mnems(1,10) = "fiver"


  /* clang-format off */
_imp_strncpy(/*?*/&MNEMS[0][0], ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("fiver"); (void *)&tmp;}), /*max:*/5);

  /* clang-format on */

  //    23    mnems(1,11) = "fours"


  /* clang-format off */
_imp_strncpy(/*?*/&MNEMS[0][1], ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("fours"); (void *)&tmp;}), /*max:*/5);

  /* clang-format on */

  //    24    mnems(1,12) = "three"


  /* clang-format off */
_imp_strncpy(/*?*/&MNEMS[0][2], ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("three"); (void *)&tmp;}), /*max:*/5);

  /* clang-format on */

  //    25    mnems(1,13) = "none!"


  /* clang-format off */
_imp_strncpy(/*?*/&MNEMS[0][3], ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("none!"); (void *)&tmp;}), /*max:*/5);

  /* clang-format on */

  //    26
  //    27    mnems(2,10) = "FIVER"


  /* clang-format off */
_imp_strncpy(/*?*/&MNEMS[1][0], ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("FIVER"); (void *)&tmp;}), /*max:*/5);

  /* clang-format on */

  //    28    mnems(2,11) = "FOURS"


  /* clang-format off */
_imp_strncpy(/*?*/&MNEMS[1][1], ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("FOURS"); (void *)&tmp;}), /*max:*/5);

  /* clang-format on */

  //    29    mnems(2,12) = "THREE"


  /* clang-format off */
_imp_strncpy(/*?*/&MNEMS[1][2], ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("THREE"); (void *)&tmp;}), /*max:*/5);

  /* clang-format on */

  //    30    mnems(2,13) = "NONE!"


  /* clang-format off */
_imp_strncpy(/*?*/&MNEMS[1][3], ({__typeof__(_imp_string255) tmp;/*B*/ tmp = _imp_str_literal("NONE!"); (void *)&tmp;}), /*max:*/5);

  /* clang-format on */

  //    31
  //    32    do5(mnems)

  DO5(
      /* clang-format off */
({  __typeof__(_imp_string5) tmp = MNEMS/*q*/;  (_imp_string5 *)&tmp;  })
      /* clang-format on */
  );

  //    33    do(mnems)

  DO(
      /* clang-format off */
({  __typeof__(_imp_string5) tmp = MNEMS/*q*/;  (_imp_string255 *)&tmp;  })
      /* clang-format on */
  );

  //    34
  //    35  %endofprogram

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