#include <perms.h>

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

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

  //     3    %ownrealarray x(0:5) = -11.7, -1.2, -0.5, 0.5, 1.2, 11.7

  static double X[6] = {-11.7, -1.2, -0.5, 0.5, 1.2, 11.7};

  //     4    %integer i

  int I;

  //     5    %ownreal r = 64.9

  static double R = 64.9;

  //     6
  //     7    print string("* PRINT/PRINTFL TEST"); newline

  _imp_PRINTSTRING(_imp_str_literal("* PRINT/PRINTFL TEST"));
  _imp_NEWLINE();

  //     8    print fl(pi,4); newlines(2)

  _imp_PRINTFL(_imp_PI(), 4);
  _imp_NEWLINES(2);

  //     9
  //    10    print string("* SQRT TEST"); newline

  _imp_PRINTSTRING(_imp_str_literal("* SQRT TEST"));
  _imp_NEWLINE();

  //    11    ! print string("ISqrt(64) = "); write(isqrt(64), 3); newlines(2)  ;! ISqrt is not a standard perm
  //    12
  //    13    print string("* INT/REAL CONVERSION TEST"); newline

  _imp_PRINTSTRING(_imp_str_literal("* INT/REAL CONVERSION TEST"));
  _imp_NEWLINE();

  //    14    print string("Expected: "); newline

  _imp_PRINTSTRING(_imp_str_literal("Expected: "));
  _imp_NEWLINE();

  //    15    print string("           'X'    Int(X)   Int Pt(X)   Round(X)   Trunc(X)"); newline

  _imp_PRINTSTRING(_imp_str_literal("           'X'    Int(X)   Int Pt(X)   Round(X)   Trunc(X)"));
  _imp_NEWLINE();

  //    16    newline

  _imp_NEWLINE();

  //    17    print string("          -11.7     -12       -12        -12        -11"); newline

  _imp_PRINTSTRING(_imp_str_literal("          -11.7     -12       -12        -12        -11"));
  _imp_NEWLINE();

  //    18    print string("           -1.2      -1        -2         -1         -1"); newline

  _imp_PRINTSTRING(_imp_str_literal("           -1.2      -1        -2         -1         -1"));
  _imp_NEWLINE();

  //    19    print string("           -0.5       0        -1         -1          0"); newline

  _imp_PRINTSTRING(_imp_str_literal("           -0.5       0        -1         -1          0"));
  _imp_NEWLINE();

  //    20    print string("            0.5       1         0          1          0"); newline

  _imp_PRINTSTRING(_imp_str_literal("            0.5       1         0          1          0"));
  _imp_NEWLINE();

  //    21    print string("            1.2       1         1          1          1"); newline

  _imp_PRINTSTRING(_imp_str_literal("            1.2       1         1          1          1"));
  _imp_NEWLINE();

  //    22    print string("           11.7      12        11         12         11"); newline

  _imp_PRINTSTRING(_imp_str_literal("           11.7      12        11         12         11"));
  _imp_NEWLINE();

  //    23    newline

  _imp_NEWLINE();

  //    24    print string("Actual: "); newline

  _imp_PRINTSTRING(_imp_str_literal("Actual: "));
  _imp_NEWLINE();

  //    25    print string("           'X'    Int(X)   Int Pt(X)   Round(X)   Trunc(X)"); newline

  _imp_PRINTSTRING(_imp_str_literal("           'X'    Int(X)   Int Pt(X)   Round(X)   Trunc(X)"));
  _imp_NEWLINE();

  //    26    print string(""); newline

  _imp_PRINTSTRING(_imp_str_literal(""));
  _imp_NEWLINE();

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

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

    //    28      r = x(i)

    R = X[I];

    //    29      write(int(r),8)

    _imp_WRITE(_imp_INT(R), 8);

    //    30      write(intpt(r),10)

    _imp_WRITE(_imp_INTPT(R), 10);

    //    31      newline

    _imp_NEWLINE();

    //    32    %repeat

    goto L_0001;
  }

L_0002:;

//    33    newline

  _imp_NEWLINE();

  //    34
  //    35  %endofprogram

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