#include <perms.h>
int _imp_mainep(int _imp_argc, char **_imp_argv) {
  int J = 23 + 77 - 50;
  int K = J - 40;
  int M;
  int N;
  int R;
  int P;
  int Nl;
  int Spaces;
  unsigned char B = 'F';
  short S;
  short T;
  long long int L = 2147483600;
  L = L * 2;
  static const unsigned char Cb1 = 255;
  static const unsigned char Cb2 = 0;
  static const int Cint1 = Cb1 + 3 * 4;
  static const int Cint2 = Cint1 + Cb2 + 321;
  static const int Cint4 = 3;
  static const int Mint1 = 'X';
  static const int Mint2 = 'IMP';
  static int Failures = 0;
  void Pass(void) { Printstring(_imp_str_literal("Pass: ")); }
  void Fail(void) {
    Printstring(_imp_str_literal("FAIL: "));
    Failures++;
  }
  int F(void) { return (3); }
  Newlines(2);
  Printstring(_imp_str_literal("INTEGER Arithmetic Validation"));
  Newline();
  Printstring(_imp_str_literal("============================="));
  Newlines(2);
  Printstring(_imp_str_literal("Entities:"));
  Newline();
  Printstring(_imp_str_literal("-------- "));
  Newlines(2);
  Printstring(_imp_str_literal("Constants:                      "));
  Newline();
  Printstring(_imp_str_literal("---------                       "));
  Newline();
  Printstring(_imp_str_literal("%Byte %Integer  CB1 = 255       "));
  Newline();
  Printstring(_imp_str_literal("%Byte %Integer  CB2 = 0         "));
  Newlines(2);
  Printstring(_imp_str_literal("%Integer  CInt1 = CB1 + 3 * 4      "));
  Newline();
  Printstring(_imp_str_literal("%Integer  CInt2 = CInt1 + CB2 + 321"));
  Newline();
  Printstring(_imp_str_literal("%Integer  CInt4 = 3                "));
  Newlines(2);
  Printstring(_imp_str_literal("%Integer  MInt1 = M'X'             "));
  Newline();
  Printstring(_imp_str_literal("%Integer  MInt2 = M'IMP'           "));
  Newlines(2);
  Newlines(3);
  Printstring(_imp_str_literal("Variables:               "));
  Newline();
  Printstring(_imp_str_literal("---------                "));
  Newline();
  Printstring(_imp_str_literal("%Integer J = 23 + 77 - 50"));
  Newline();
  Printstring(_imp_str_literal("%Integer K = J - 40      "));
  Newline();
  Printstring(_imp_str_literal("%Integer M               "));
  Newline();
  Printstring(_imp_str_literal("%Integer N               "));
  Newline();
  Printstring(_imp_str_literal("%Integer R               "));
  Newline();
  Printstring(_imp_str_literal("%Integer P               "));
  Newlines(2);
  Printstring(_imp_str_literal("%Integer NL              "));
  Newline();
  Printstring(_imp_str_literal("%Integer Spaces          "));
  Newlines(2);
  Printstring(_imp_str_literal("%Byte  %Integer B = 'F'  "));
  Newlines(2);
  Printstring(_imp_str_literal("%Short %Integer S        "));
  Newline();
  Printstring(_imp_str_literal("%Short %Integer T        "));
  Newlines(2);
  Printstring(_imp_str_literal("%Long  %Integer L = 2147483600 * 2"));
  Newlines(2);
  Newlines(5);
  Printstring(_imp_str_literal("Test Simple Assignment of Integer Values"));
  Newline();
  Printstring(_imp_str_literal("----------------------------------------"));
  Newlines(2);
  if (J == 50)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("Initialisation of J = 50"));
  Newline();
  if (K == 10)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("Initialisation of K = J - 40"));
  Newline();
#if 1 /* Cint1==267 */
  Pass();
#else
  Fail();
#endif
  Printstring(_imp_str_literal("Value of constant CInt1"));
  Newline();
#if 1 /* Mint1=='X' */
  Pass();
#else
  Fail();
#endif
  Printstring(_imp_str_literal("Value of constant MInt1"));
  Newline();
#if 1 /* Mint2==((('I'<<8) + 'M')<<8) + 'P' */
  Pass();
#else
  Fail();
#endif
  Printstring(_imp_str_literal("Value of constant MInt2   (for Offset = 8)."));
  Newline();
#if 1 /* Cint2==588 */
  Pass();
#else
  Fail();
#endif
  Printstring(_imp_str_literal("Value of constant CInt2"));
  Newlines(3);
  Printstring(_imp_str_literal("Test the  SIZE OF  Function."));
  Newline();
  Printstring(_imp_str_literal("----------------------------"));
  Newlines(2);
  Printstring(_imp_str_literal("Size of %LONG    ="));
  Write(Sizeof(L), 1);
  Newline();
  Printstring(_imp_str_literal("Size of %INTEGER ="));
  Write(Sizeof(J), 1);
  Newline();
  Printstring(_imp_str_literal("Size of %SHORT   ="));
  Write(Sizeof(S), 1);
  Newline();
  Printstring(_imp_str_literal("Size of %BYTE    ="));
  Write(Sizeof(B), 1);
  Newline();
  Newline();
  if (L == 4294967200)
    Printstring(_imp_str_literal("Can"));
  else
    Printstring(_imp_str_literal("Cannot"));
  Printstring(_imp_str_literal(" hold a %LONG %INTEGER greater than %INTEGER precision."));
  Newlines(4);
  Printstring(_imp_str_literal("Test Re-Assignment of Predeclared Procedures"));
  Newline();
  Printstring(_imp_str_literal("--------------------------------------------"));
  Newlines(2);
  Printstring(_imp_str_literal("Let:  NL     = 100"));
  Newline();
  Printstring(_imp_str_literal("---   Spaces = 50 "));
  Newlines(2);
  Nl = 100;
  Spaces = 50;
  if (Nl == 100)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("NL = 100"));
  Newline();
  if (Spaces == 50)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("Spaces = 50"));
  Newlines(6);
  Printstring(_imp_str_literal("Test the Handling of Integer Expressions"));
  Newline();
  Printstring(_imp_str_literal("----------------------------------------"));
  Newlines(3);
  Printstring(_imp_str_literal("Let:    M = 3"));
  Newline();
  Printstring(_imp_str_literal("---          "));
  Newline();
  M = 3;
  J = 3 + Cint4 + M + F();
  if (J == 12)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("J = 3 + CInt4 + M + F"));
  Newline();
  Newlines(2);
  Printstring(_imp_str_literal("Let:    J = 3"));
  Newline();
  Printstring(_imp_str_literal("---     K = 2"));
  Newline();
  Printstring(_imp_str_literal("        M = 30"));
  Newline();
  Printstring(_imp_str_literal("        N = 5"));
  Newlines(3);
  J = 3;
  K = 2;
  M = 30;
  N = 5;
  P = IEXP(-1, 3);
  if (P == -1)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("P = -1 ^^ 3"));
  Newline();
  P = IEXP((-1), 2);
  if (P == 1)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("(-1) ^^ 2"));
  Newline();
  P = IEXP(2, IEXP(2, 3));
  if (P == 64)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("P = 2 ^^ 2 ^^ 3"));
  Newline();
  P = 2 + 3 * IEXP(5, 3) - 1;
  if (P == 376)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("P = 2 + 3 * 5 ^^ 3 - 1"));
  Newline();
  P = 2 + (-3);
  if (P == -1)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("P = 2 + (-3)"));
  Newline();
  P = J - (-K);
  if (P == 5)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("P = J - (-K)"));
  Newline();
  P = J * K + M / N - 6;
  if (P == 6)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("P = J * K + M // N - 6"));
  Newline();
  P = J * (K + M) / N - 6;
  if (P == 13)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("P = J * (K + M) // N - 6"));
  Newline();
  P = (J * K) + M / (N - 6);
  if (P == -24)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("P = (J * K) + M // (N - 6)"));
  Newline();
  P = J * (K + M / N - 6);
  if (P == 6)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("P = J * (K + M // N - 6)"));
  Newline();
  if ((-J) * (-K) == K * J)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("(-J) * (-K) = K * J"));
  Newline();
  if ((((J * K) + (M / N)) - 6) == M / N + K * J - 6)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal(" (((((J * K) + (M // N)) - 6))) = M // N + K * J - 6"));
  Newline();
  J = abs((Cint4 + IEXP(F(), 3)) * (234 - IEXP((Cint1 - 500), K) / 30) * 3 - 1000 / (-F()));
  if (J == 141417)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("| (CInt4 + F^^3) * (234 - (CInt1 - 500) ^^ K // 30)"));
  Printstring(_imp_str_literal(" * 3 - 1000 // (-F) |"));
  Newlines(4);
  Printstring(_imp_str_literal("Test Coercion Between the Various Types"));
  Newline();
  Printstring(_imp_str_literal("---------------------------------------"));
  Newlines(2);
  Printstring(_imp_str_literal("Let:  S =  B"));
  Newline();
  Printstring(_imp_str_literal("---   T = -B"));
  Newline();
  Printstring(_imp_str_literal("      J =  B"));
  Newline();
  Printstring(_imp_str_literal("      K = -B"));
  Newline();
  Printstring(_imp_str_literal("      M = CB1"));
  Newline();
  Printstring(_imp_str_literal("      N = -CB1"));
  Newline();
  Printstring(_imp_str_literal("      P =  S"));
  Newline();
  Printstring(_imp_str_literal("      R = -S"));
  Newlines(2);
  B = 'F';
  S = B;
  T = -B;
  J = B;
  K = -B;
  M = Cb1;
  N = -Cb1;
  P = S;
  R = -S;
  if (S == 70)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("S = B"));
  Newline();
  if (T == -70)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("T = -B"));
  Newline();
  if (J == 70)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("J = B"));
  Newline();
  if (K == -70)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("K = -B"));
  Newline();
  if (M == 255)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("M = CB1"));
  Newline();
  if (N == -255)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("N = -CB1"));
  Newline();
  if (P == 70)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("P = S"));
  Newline();
  if (R == -70)
    Pass();
  else
    Fail();
  Printstring(_imp_str_literal("R = -S"));
  Newline();
  Selectoutput(0);
  Write(Failures, 1);
  Printstring(_imp_str_literal(" failure(s)"));
  Newline();
  exit(0);
  return (1);
}
