#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 print array info(%string (9) %array %name x, %integer low, high)

  void PRINTARRAYINFO(_imp_string9 * X, int LOW, int HIGH) {
    //     4      %integer i

    int I;

    //     5      %for i = low, 1, high %cycle

    // %for I = LOW, 1, HIGH %cycle
    {
      int _initial = LOW, _final = HIGH;
      if (invalid_for_loop(_initial, 1, _final)) _imp_signal(5, 1, 0, "Illegal cycle I = LOW, 1, HIGH");
      I = _initial - (1);
    L_0001:
      if (I == _final) goto L_0002;
      I += 1;

      //     6        printstring("ADDR(X("); write(i, -1);  printstring(")) = "); write(ADDR(X(i)), -1); newline

      _imp_PRINTSTRING(_imp_str_literal("ADDR(X("));
      _imp_WRITE(I, -1);
      _imp_PRINTSTRING(_imp_str_literal(")) = "));
      _imp_WRITE(_imp_ADDR(/*?*/ &X[/*BUG*/ I]), -1);
      _imp_NEWLINE();

      //     7      %repeat

      goto L_0001;
    }

  L_0002:;

  //     8    %end

    return;
  } /* end of PRINTARRAYINFO */

  //     9
  //    10
  //    11    %string (9) %array names(0:5)

  _imp_string9 NAMES[6];
  struct _imp_dv NAMES_dv = {NAMES, sizeof(_imp_string) /*, dims, <bounds> */};

  //    12
  //    13    %integer i

  int I;

  //    14    %for i = 0, 1, 5 %cycle

  // %for I = 0, 1, 5 %cycle
  {
    I = -1;
  L_0004:
    if (I == 5) goto L_0005;
    I += 1;

    //    15      printstring("ADDR(NAMES("); write(i, -1);  printstring(")) = "); write(ADDR(NAMES(i)), -1); newline

    _imp_PRINTSTRING(_imp_str_literal("ADDR(NAMES("));
    _imp_WRITE(I, -1);
    _imp_PRINTSTRING(_imp_str_literal(")) = "));
    _imp_WRITE(_imp_ADDR(/*?*/ &NAMES[I]), -1);
    _imp_NEWLINE();

    //    16    %repeat

    goto L_0004;
  }

L_0005:;

//    17
//    18    print array info(names, 0, 5)

  PRINTARRAYINFO(
      /* clang-format off */
({  __typeof__(_imp_string9) tmp = NAMES/*q*/;  (_imp_string9 *)&tmp;  })
      /* clang-format on */
      ,
      0, 5);

  //    19
  //    20  %endofprogram

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