#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  !***********************************************************************
//     2  !*
//     3  !*                    BCPL compiler steering routines
//     4  !*
//     5  !*                             Version E1.11
//     6  !*
//     7  !*       Copyright R.D. Eager   University of Kent   MCMLXXXIV
//     8  !*
//     9  !***********************************************************************
//    10  !
//    11  !
//    12  !***********************************************************************
//    13  !*
//    14  !*          External references
//    15  !*
//    16  !***********************************************************************
//    17  !
//    18  %externalroutine compile(%string(255) s,%string(32) entry, %integername flag)

void COMPILE(_imp_string255 S, _imp_string32 ENTRY, int *FLAG) {
  //    19  %end

  return;
} /* end of COMPILE */

// ?FLAG unused
// ?ENTRY unused
// ?S unused
//    20  %externalintegermap comreg(%integer n)

int *COMREG(int N)
{

  //    21    %owninteger i

  static int I;

  //    22    %result == i

  return /*?*/ &I;

  //    23  %end

} /* end of COMREG */

// ?N unused
//    24  %externalstring(255)%function failuremessage(%integer mess)

_imp_string255 FAILUREMESSAGE(int MESS) {
  //    25    %result = "FAILURE: ".itos(mess, 0)

  return *(_imp_string255 *)/*?*/ &
      *({
        _imp_string255 tmp = _imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("FAILURE: "), ({
                                         __typeof__(_imp_string255) tmp; /*E*/
                                         tmp = _imp_ITOS(MESS, 0);
                                         (void *)&tmp;
                                       }));
        (_imp_string255 *)&tmp;
      })
      ;

  //    26  %end

} /* end of FAILUREMESSAGE */

//    27  %externalintegerfunction return code

int RETURNCODE(void) {
  //    28    %result = 0

  return 0;

  //    29  %end

} /* end of RETURNCODE */

//    30  %externalroutine setfname(%string(40) file)

void SETFNAME(_imp_string40 FILE) {
  //    31  %end

  return;
} /* end of SETFNAME */

// ?FILE unused
//    32  !
//    33  %externalintegerfunction icl9cezbcplx(%string(255) parms)

int ICL9CEZBCPLX(_imp_string255 PARMS) {
  //    34    %result = 0

  return 0;

  //    35  %end

} /* end of ICL9CEZBCPLX */

// ?PARMS unused
//    36  !
//    37  !
//    38  !***********************************************************************
//    39  !*
//    40  !*          S H U F F L E
//    41  !*
//    42  !*    This routine:
//    43  !*      a) Moves any keyword parameters out of the first four parameter
//    44  !*         positions
//    45  !*      b) Puts the first four parameters into CPARMS (for COMPILE)
//    46  !*      c) Puts the rest of the parameters into S (for passing over
//    47  !*         via COMREG(9))
//    48  !*
//    49  !***********************************************************************
//    50  !
//    51  %routine shuffle(%string(*)%name s,cparms)

static void SHUFFLE(_imp_string *S, _imp_string *CPARMS) {
  //    52  %integer i

  int I;

  //    53  %string(255) work1,work2

  _imp_string255 WORK1;
  _imp_string255 WORK2;

  //    54  %string(255)%array p(1:4)

  _imp_string255 P[4];

  //    55  !
  //    56  %if s = "?" %then %start;               ! Handle this specially

  if (_imp_strcmp((_imp_string *)S, (_imp_string *)/*?*/ _imp_str_literal_ptr("?")) != 0) goto L_0001;

    //    57     cparms = ".IN,.NULL,.NULL,.NULL";    ! Never used really

  *CPARMS = _imp_str_literal(".IN,.NULL,.NULL,.NULL");

  //    58  %else

  goto L_0002;
L_0001:;

//    59     %for i = 1,1,4 %cycle

// %for I = 1, 1, 4 %cycle
  {
    I = 0;
  L_0003:
    if (I == 4) goto L_0004;
    I += 1;

    //    60        p(i) = "";                        ! Initialise

    _imp_strncpy(/*?*/ &P[I - 1], ({
                   __typeof__(_imp_string255) tmp; /*B*/
                   tmp = _imp_str_literal("");
                   (void *)&tmp;
                 }),
                 /*max:*/ 255);

    //    61     %repeat

    goto L_0003;
  }

L_0004:;

//    62     !
//    63     s <- s.","

  _imp_strncpy(S, ({
                 __typeof__(_imp_string255) tmp; /*C*/
                 tmp = **({
                   _imp_string255 tmp = _imp_join(({
                                                    __typeof__(_imp_string255) tmp; /*D*/
                                                    tmp = *S;
                                                    (void *)&tmp;
                                                  }),
                                                  (_imp_string *)/*?*/ _imp_str_literal_ptr(","));
                   (_imp_string255 *)&tmp;
                 });
                 (void *)&tmp;
               }),
               /*max:*/ 255);

  //    64     %for i = 1,1,4 %cycle

  // %for I = 1, 1, 4 %cycle
  {
    I = 0;
  L_0006:
    if (I == 4) goto L_0007;
    I += 1;

    //    65        %exit %unless s -> p(i).(",").s

    if (_imp_resolve(*({
          _imp_string tmp = *S;
          (_imp_string255 *)&tmp;
        }),
                     (_imp_string255 *)/*?*/ &P[I - 1], *({
                       _imp_string tmp = _imp_str_literal(",");
                       (_imp_string255 *)&tmp;
                     }),
                     (_imp_string255 *)S))
      goto L_0008;
    goto L_0007;
  L_0008:;

  //    66     %repeat

    goto L_0006;
  }

L_0007:;

//    67     !
//    68     %cycle i = 1,1,4

// %for I = 1, 1, 4 %cycle
  {
    I = 0;
  L_0009:
    if (I == 4) goto L_000A;
    I += 1;

    //    69        %if p(i) -> work1.("=").work2 %then %start

    if (!(_imp_resolve(*({
          _imp_string255 tmp = P[I - 1];
          (_imp_string255 *)&tmp;
        }),
                       (_imp_string255 *)/*?*/ &WORK1, *({
                         _imp_string tmp = _imp_str_literal("=");
                         (_imp_string255 *)&tmp;
                       }),
                       (_imp_string255 *)/*?*/ &WORK2)))
      goto L_000B;

      //    70           s = p(i).",".s

    *S =
        *({
          _imp_string255 tmp =
              _imp_join((_imp_string *)/*?*/ &*({
                          _imp_string255 tmp =
                              _imp_join((_imp_string *)/*?*/ &P[I - 1], (_imp_string *)/*?*/ _imp_str_literal_ptr(","));
                          (_imp_string255 *)&tmp;
                        }),
                        ({
                          __typeof__(_imp_string255) tmp; /*E*/
                          tmp = *S;
                          (void *)&tmp;
                        }));
          (_imp_string255 *)&tmp;
        })
        ;

    //    71           p(i) = ""

    _imp_strncpy(/*?*/ &P[I - 1], ({
                   __typeof__(_imp_string255) tmp; /*B*/
                   tmp = _imp_str_literal("");
                   (void *)&tmp;
                 }),
                 /*max:*/ 255);

    //    72        %finish

  L_000B:;

  //    73     %repeat

    goto L_0009;
  }

L_000A:;

//    74     !
//    75     cparms = p(1).",".p(2).",".p(3).",".p(4)

  *CPARMS =
      *({
        _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_string255 tmp = _imp_join(
                                                                  (_imp_string *)/*?*/ &*({
                                                                    _imp_string255 tmp = _imp_join(
                                                                        (_imp_string *)/*?*/ &P[0],
                                                                        (_imp_string *)/*?*/ _imp_str_literal_ptr(","));
                                                                    (_imp_string255 *)&tmp;
                                                                  }),
                                                                  (_imp_string *)/*?*/ &P[1]);
                                                              (_imp_string255 *)&tmp;
                                                            }),
                                                            (_imp_string *)/*?*/ _imp_str_literal_ptr(","));
                                                        (_imp_string255 *)&tmp;
                                                      }),
                                                      (_imp_string *)/*?*/ &P[2]);
                                        (_imp_string255 *)&tmp;
                                      }),
                                      (_imp_string *)/*?*/ _imp_str_literal_ptr(","));
                        (_imp_string255 *)&tmp;
                      }),
                      (_imp_string *)/*?*/ &P[3]);
        (_imp_string255 *)&tmp;
      })
      ;

  //    76  %finish

L_0002:;

//    77  %end;   ! of shuffle

  return;
} /* end of SHUFFLE */

//    78  !
//    79  !
//    80  !***********************************************************************
//    81  !*
//    82  !*          B C P L
//    83  !*
//    84  !***********************************************************************
//    85  !
//    86  %externalroutine bcpl(%string(255) parms)

void BCPL(_imp_string255 PARMS) {
  //    87  %integer flag

  int FLAG;

  //    88  %string(255) cparms,auxparms

  _imp_string255 CPARMS;
  _imp_string255 AUXPARMS;

  //    89  !
  //    90  setfname("")

  SETFNAME(_imp_str_literal_size(40, ""));

  //    91  shuffle(parms,cparms)

  SHUFFLE((_imp_string255 *)/*p*/ /*?*/ &PARMS, (_imp_string255 *)/*p*/ /*?*/ &CPARMS);

  //    92  auxparms = parms;                       ! Make copy, to ensure string is word-aligned

  _imp_strncpy(/*?*/ &AUXPARMS, ({
                 __typeof__(_imp_string255) tmp; /*B*/
                 tmp = PARMS;
                 (void *)&tmp;
               }),
               /*max:*/ 255);

  //    93  comreg(9) = addr(auxparms);             ! Picked up by compiler

  *COMREG(9) = _imp_ADDR(/*?*/ &AUXPARMS);

  //    94  !
  //    95  compile(cparms,"ICL9CEZBCPL1",flag)

  COMPILE(
      *({
        __typeof__(_imp_string255) tmp = CPARMS /*q*/;
        (_imp_string255 *)&tmp;
      })
          ,
      _imp_str_literal_size(32, "ICL9CEZBCPL1"), /*?*/ &FLAG);

  //    96  flag = return code

  FLAG = RETURNCODE();

  //    97  flag = 0 %if flag = -1;                 ! INT:A

  if (FLAG != -1) goto L_000C;
  FLAG = 0;
L_000C:;

//    98  %if 0 # flag < 1000 %then %start

  {
// Double-sided test on FLAG (Part I)
    int tmp;
    if (0 == (tmp = FLAG)) goto L_000D;
// Double-sided test on FLAG (Part II)
    if (tmp >= 1000) goto L_000D;
  }

  //    99     newline

  _imp_NEWLINE();

  //   100     printstring("BCPL fails -".failuremessage(flag))

  _imp_PRINTSTRING(
      *({
        __typeof__(_imp_string255) tmp = *({
          _imp_string255 tmp = _imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("BCPL fails -"), ({
                                           __typeof__(_imp_string255) tmp; /*E*/
                                           tmp = FAILUREMESSAGE(FLAG);
                                           (void *)&tmp;
                                         }));
          (_imp_string255 *)&tmp;
        }) /*q*/;
        (_imp_string255 *)&tmp;
      })
  );

  //   101  %finish

L_000D:;

//   102  %end;   ! of bcpl

  return;
} /* end of BCPL */

//   103  !
//   104  !
//   105  !***********************************************************************
//   106  !*
//   107  !*          B C P L C G E N
//   108  !*
//   109  !***********************************************************************
//   110  !
//   111  %externalroutine bcplcgen(%string(255) parms)

void BCPLCGEN(_imp_string255 PARMS) {
  //   112  %integer flag

  int FLAG;

  //   113  %string(255) cparms,auxparms

  _imp_string255 CPARMS;
  _imp_string255 AUXPARMS;

  //   114  !
  //   115  setfname("")

  SETFNAME(_imp_str_literal_size(40, ""));

  //   116  shuffle(parms,cparms)

  SHUFFLE((_imp_string255 *)/*p*/ /*?*/ &PARMS, (_imp_string255 *)/*p*/ /*?*/ &CPARMS);

  //   117  auxparms = parms;                       ! Make copy, to ensure string is word-aligned

  _imp_strncpy(/*?*/ &AUXPARMS, ({
                 __typeof__(_imp_string255) tmp; /*B*/
                 tmp = PARMS;
                 (void *)&tmp;
               }),
               /*max:*/ 255);

  //   118  comreg(9) = addr(auxparms);             ! Picked up by codegenerator

  *COMREG(9) = _imp_ADDR(/*?*/ &AUXPARMS);

  //   119  !
  //   120  compile(cparms,"ICL9CEZBCPL2",flag)

  COMPILE(
      *({
        __typeof__(_imp_string255) tmp = CPARMS /*q*/;
        (_imp_string255 *)&tmp;
      })
          ,
      _imp_str_literal_size(32, "ICL9CEZBCPL2"), /*?*/ &FLAG);

  //   121  flag = return code

  FLAG = RETURNCODE();

  //   122  flag = 0 %if flag = -1;                 ! INT:A

  if (FLAG != -1) goto L_000E;
  FLAG = 0;
L_000E:;

//   123  %if 0 # flag < 1000 %then %start

  {
// Double-sided test on FLAG (Part I)
    int tmp;
    if (0 == (tmp = FLAG)) goto L_000F;
// Double-sided test on FLAG (Part II)
    if (tmp >= 1000) goto L_000F;
  }

  //   124     newline

  _imp_NEWLINE();

  //   125     printstring("BCPLCGEN fails -".failuremessage(flag))

  _imp_PRINTSTRING(
      *({
        __typeof__(_imp_string255) tmp = *({
          _imp_string255 tmp = _imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("BCPLCGEN fails -"), ({
                                           __typeof__(_imp_string255) tmp; /*E*/
                                           tmp = FAILUREMESSAGE(FLAG);
                                           (void *)&tmp;
                                         }));
          (_imp_string255 *)&tmp;
        }) /*q*/;
        (_imp_string255 *)&tmp;
      })
  );

  //   126  %finish

L_000F:;

//   127  %end;   ! of bcplcgen

  return;
} /* end of BCPLCGEN */

//   128  !
//   129  !
//   130  !***********************************************************************
//   131  !*
//   132  !*          B C P L V
//   133  !*
//   134  !***********************************************************************
//   135  !
//   136  %externalroutine bcplv(%string(255) parms)

void BCPLV(_imp_string255 PARMS) {
  //   137  %integer flag

  int FLAG;

  //   138  %string(255) cparms,auxparms

  _imp_string255 CPARMS;
  _imp_string255 AUXPARMS;

  //   139  !
  //   140  setfname("")

  SETFNAME(_imp_str_literal_size(40, ""));

  //   141  shuffle(parms,cparms)

  SHUFFLE((_imp_string255 *)/*p*/ /*?*/ &PARMS, (_imp_string255 *)/*p*/ /*?*/ &CPARMS);

  //   142  auxparms = parms;                       ! Make copy, to ensure string is word-aligned

  _imp_strncpy(/*?*/ &AUXPARMS, ({
                 __typeof__(_imp_string255) tmp; /*B*/
                 tmp = PARMS;
                 (void *)&tmp;
               }),
               /*max:*/ 255);

  //   143  comreg(9) = addr(auxparms);             ! Picked up by codegenerator

  *COMREG(9) = _imp_ADDR(/*?*/ &AUXPARMS);

  //   144  !
  //   145  compile(cparms,"ICL9CEZBCPLV",flag)

  COMPILE(
      *({
        __typeof__(_imp_string255) tmp = CPARMS /*q*/;
        (_imp_string255 *)&tmp;
      })
          ,
      _imp_str_literal_size(32, "ICL9CEZBCPLV"), /*?*/ &FLAG);

  //   146  flag = return code

  FLAG = RETURNCODE();

  //   147  flag = 0 %if flag = -1;                 ! INT:A

  if (FLAG != -1) goto L_0010;
  FLAG = 0;
L_0010:;

//   148  %if 0 # flag < 1000 %then %start

  {
// Double-sided test on FLAG (Part I)
    int tmp;
    if (0 == (tmp = FLAG)) goto L_0011;
// Double-sided test on FLAG (Part II)
    if (tmp >= 1000) goto L_0011;
  }

  //   149     newline

  _imp_NEWLINE();

  //   150     printstring("BCPLV fails -".failuremessage(flag))

  _imp_PRINTSTRING(
      *({
        __typeof__(_imp_string255) tmp = *({
          _imp_string255 tmp = _imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("BCPLV fails -"), ({
                                           __typeof__(_imp_string255) tmp; /*E*/
                                           tmp = FAILUREMESSAGE(FLAG);
                                           (void *)&tmp;
                                         }));
          (_imp_string255 *)&tmp;
        }) /*q*/;
        (_imp_string255 *)&tmp;
      })
  );

  //   151  %finish

L_0011:;

//   152  %end;   ! of bcplv

  return;
} /* end of BCPLV */

//   153  !
//   154  !
//   155  !***********************************************************************
//   156  !*
//   157  !*          B C P L W
//   158  !*
//   159  !***********************************************************************
//   160  !
//   161  %externalroutine bcplw(%string(255) parms)

void BCPLW(_imp_string255 PARMS) {
  //   162  %integer flag

  int FLAG;

  //   163  %string(255) cparms,auxparms

  _imp_string255 CPARMS;
  _imp_string255 AUXPARMS;

  //   164  !
  //   165  setfname("")

  SETFNAME(_imp_str_literal_size(40, ""));

  //   166  shuffle(parms,cparms)

  SHUFFLE((_imp_string255 *)/*p*/ /*?*/ &PARMS, (_imp_string255 *)/*p*/ /*?*/ &CPARMS);

  //   167  auxparms = parms;                       ! Make copy, to ensure string is word-aligned

  _imp_strncpy(/*?*/ &AUXPARMS, ({
                 __typeof__(_imp_string255) tmp; /*B*/
                 tmp = PARMS;
                 (void *)&tmp;
               }),
               /*max:*/ 255);

  //   168  comreg(9) = addr(auxparms);             ! Picked up by codegenerator

  *COMREG(9) = _imp_ADDR(/*?*/ &AUXPARMS);

  //   169  !
  //   170  compile(cparms,"ICL9CEZBCPLW",flag)

  COMPILE(
      *({
        __typeof__(_imp_string255) tmp = CPARMS /*q*/;
        (_imp_string255 *)&tmp;
      })
          ,
      _imp_str_literal_size(32, "ICL9CEZBCPLW"), /*?*/ &FLAG);

  //   171  flag = return code

  FLAG = RETURNCODE();

  //   172  flag = 0 %if flag = -1;                 ! INT:A

  if (FLAG != -1) goto L_0012;
  FLAG = 0;
L_0012:;

//   173  %if 0 # flag < 1000 %then %start

  {
// Double-sided test on FLAG (Part I)
    int tmp;
    if (0 == (tmp = FLAG)) goto L_0013;
// Double-sided test on FLAG (Part II)
    if (tmp >= 1000) goto L_0013;
  }

  //   174     newline

  _imp_NEWLINE();

  //   175     printstring("BCPLW fails -".failuremessage(flag))

  _imp_PRINTSTRING(
      *({
        __typeof__(_imp_string255) tmp = *({
          _imp_string255 tmp = _imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("BCPLW fails -"), ({
                                           __typeof__(_imp_string255) tmp; /*E*/
                                           tmp = FAILUREMESSAGE(FLAG);
                                           (void *)&tmp;
                                         }));
          (_imp_string255 *)&tmp;
        }) /*q*/;
        (_imp_string255 *)&tmp;
      })
  );

  //   176  %finish

L_0013:;

//   177  %end;   ! of bcplw

  return;
} /* end of BCPLW */

//   178  !
//   179  !
//   180  !***********************************************************************
//   181  !*
//   182  !*          B C P L Z
//   183  !*
//   184  !***********************************************************************
//   185  !
//   186  %externalroutine bcplz(%string(255) parms)

void BCPLZ(_imp_string255 PARMS) {
  //   187  %integer flag

  int FLAG;

  //   188  %string(255) cparms,auxparms

  _imp_string255 CPARMS;
  _imp_string255 AUXPARMS;

  //   189  !
  //   190  setfname("")

  SETFNAME(_imp_str_literal_size(40, ""));

  //   191  shuffle(parms,cparms)

  SHUFFLE((_imp_string255 *)/*p*/ /*?*/ &PARMS, (_imp_string255 *)/*p*/ /*?*/ &CPARMS);

  //   192  auxparms = parms;                       ! Make copy, to ensure string is word-aligned

  _imp_strncpy(/*?*/ &AUXPARMS, ({
                 __typeof__(_imp_string255) tmp; /*B*/
                 tmp = PARMS;
                 (void *)&tmp;
               }),
               /*max:*/ 255);

  //   193  comreg(9) = addr(auxparms);             ! Picked up by codegenerator

  *COMREG(9) = _imp_ADDR(/*?*/ &AUXPARMS);

  //   194  !
  //   195  compile(cparms,"ICL9CEZBCPLZ",flag)

  COMPILE(
      *({
        __typeof__(_imp_string255) tmp = CPARMS /*q*/;
        (_imp_string255 *)&tmp;
      })
          ,
      _imp_str_literal_size(32, "ICL9CEZBCPLZ"), /*?*/ &FLAG);

  //   196  flag = return code

  FLAG = RETURNCODE();

  //   197  flag = 0 %if flag = -1;                 ! INT:A

  if (FLAG != -1) goto L_0014;
  FLAG = 0;
L_0014:;

//   198  %if 0 # flag < 1000 %then %start

  {
// Double-sided test on FLAG (Part I)
    int tmp;
    if (0 == (tmp = FLAG)) goto L_0015;
// Double-sided test on FLAG (Part II)
    if (tmp >= 1000) goto L_0015;
  }

  //   199     newline

  _imp_NEWLINE();

  //   200     printstring("BCPLZ fails -".failuremessage(flag))

  _imp_PRINTSTRING(
      *({
        __typeof__(_imp_string255) tmp = *({
          _imp_string255 tmp = _imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("BCPLZ fails -"), ({
                                           __typeof__(_imp_string255) tmp; /*E*/
                                           tmp = FAILUREMESSAGE(FLAG);
                                           (void *)&tmp;
                                         }));
          (_imp_string255 *)&tmp;
        }) /*q*/;
        (_imp_string255 *)&tmp;
      })
  );

  //   201  %finish

L_0015:;

//   202  %end;   ! of bcplz

  return;
} /* end of BCPLZ */

//   203  !
//   204  !
//   205  !***********************************************************************
//   206  !*
//   207  !*          B C P L R
//   208  !*
//   209  !***********************************************************************
//   210  !
//   211  %externalroutine bcplr(%string(255) parms)

void BCPLR(_imp_string255 PARMS) {
  //   212  %integer flag

  int FLAG;

  //   213  %string(255) cparms,auxparms

  _imp_string255 CPARMS;
  _imp_string255 AUXPARMS;

  //   214  !
  //   215  setfname("")

  SETFNAME(_imp_str_literal_size(40, ""));

  //   216  shuffle(parms,cparms)

  SHUFFLE((_imp_string255 *)/*p*/ /*?*/ &PARMS, (_imp_string255 *)/*p*/ /*?*/ &CPARMS);

  //   217  auxparms = parms;                       ! Make copy, to ensure string is word-aligned

  _imp_strncpy(/*?*/ &AUXPARMS, ({
                 __typeof__(_imp_string255) tmp; /*B*/
                 tmp = PARMS;
                 (void *)&tmp;
               }),
               /*max:*/ 255);

  //   218  comreg(9) = addr(auxparms);             ! Picked up by codegenerator

  *COMREG(9) = _imp_ADDR(/*?*/ &AUXPARMS);

  //   219  !
  //   220  compile(cparms,"ICL9CEZBCPLR",flag)

  COMPILE(
      *({
        __typeof__(_imp_string255) tmp = CPARMS /*q*/;
        (_imp_string255 *)&tmp;
      })
          ,
      _imp_str_literal_size(32, "ICL9CEZBCPLR"), /*?*/ &FLAG);

  //   221  flag = return code

  FLAG = RETURNCODE();

  //   222  flag = 0 %if flag = -1;                 ! INT:A

  if (FLAG != -1) goto L_0016;
  FLAG = 0;
L_0016:;

//   223  %if 0 # flag < 1000 %then %start

  {
// Double-sided test on FLAG (Part I)
    int tmp;
    if (0 == (tmp = FLAG)) goto L_0017;
// Double-sided test on FLAG (Part II)
    if (tmp >= 1000) goto L_0017;
  }

  //   224     newline

  _imp_NEWLINE();

  //   225     printstring("BCPLR fails -".failuremessage(flag))

  _imp_PRINTSTRING(
      *({
        __typeof__(_imp_string255) tmp = *({
          _imp_string255 tmp = _imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("BCPLR fails -"), ({
                                           __typeof__(_imp_string255) tmp; /*E*/
                                           tmp = FAILUREMESSAGE(FLAG);
                                           (void *)&tmp;
                                         }));
          (_imp_string255 *)&tmp;
        }) /*q*/;
        (_imp_string255 *)&tmp;
      })
  );

  //   226  %finish

L_0017:;

//   227  %end;   ! of bcplr

  return;
} /* end of BCPLR */

//   228  !
//   229  !
//   230  !***********************************************************************
//   231  !*
//   232  !*          B C P L Q
//   233  !*
//   234  !***********************************************************************
//   235  !
//   236  %externalroutine bcplq(%string(255) parms)

void BCPLQ(_imp_string255 PARMS) {
  //   237  %integer flag

  int FLAG;

  //   238  %string(255) cparms,auxparms

  _imp_string255 CPARMS;
  _imp_string255 AUXPARMS;

  //   239  !
  //   240  setfname("")

  SETFNAME(_imp_str_literal_size(40, ""));

  //   241  shuffle(parms,cparms)

  SHUFFLE((_imp_string255 *)/*p*/ /*?*/ &PARMS, (_imp_string255 *)/*p*/ /*?*/ &CPARMS);

  //   242  auxparms = parms;                       ! Make copy, to ensure string is word-aligned

  _imp_strncpy(/*?*/ &AUXPARMS, ({
                 __typeof__(_imp_string255) tmp; /*B*/
                 tmp = PARMS;
                 (void *)&tmp;
               }),
               /*max:*/ 255);

  //   243  comreg(9) = addr(auxparms);             ! Picked up by codegenerator

  *COMREG(9) = _imp_ADDR(/*?*/ &AUXPARMS);

  //   244  !
  //   245  compile(cparms,"ICL9CEZBCPLQ",flag)

  COMPILE(
      *({
        __typeof__(_imp_string255) tmp = CPARMS /*q*/;
        (_imp_string255 *)&tmp;
      })
          ,
      _imp_str_literal_size(32, "ICL9CEZBCPLQ"), /*?*/ &FLAG);

  //   246  flag = return code

  FLAG = RETURNCODE();

  //   247  flag = 0 %if flag = -1;                 ! INT:A

  if (FLAG != -1) goto L_0018;
  FLAG = 0;
L_0018:;

//   248  %if 0 # flag < 1000 %then %start

  {
// Double-sided test on FLAG (Part I)
    int tmp;
    if (0 == (tmp = FLAG)) goto L_0019;
// Double-sided test on FLAG (Part II)
    if (tmp >= 1000) goto L_0019;
  }

  //   249     newline

  _imp_NEWLINE();

  //   250     printstring("BCPLQ fails -".failuremessage(flag))

  _imp_PRINTSTRING(
      *({
        __typeof__(_imp_string255) tmp = *({
          _imp_string255 tmp = _imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("BCPLQ fails -"), ({
                                           __typeof__(_imp_string255) tmp; /*E*/
                                           tmp = FAILUREMESSAGE(FLAG);
                                           (void *)&tmp;
                                         }));
          (_imp_string255 *)&tmp;
        }) /*q*/;
        (_imp_string255 *)&tmp;
      })
  );

  //   251  %finish

L_0019:;

//   252  %end;   ! of bcplq

  return;
} /* end of BCPLQ */

//   253  !
//   254  !
//   255  !***********************************************************************
//   256  !*
//   257  !*          B C P L X R E F
//   258  !*
//   259  !***********************************************************************
//   260  !
//   261  %externalroutine bcplxref(%string(255) parms)

void BCPLXREF(_imp_string255 PARMS) {
  //   262  %integer flag

  int FLAG;

  //   263  !
  //   264  setfname("")

  SETFNAME(_imp_str_literal_size(40, ""));

  //   265  flag = icl9cezbcplx(parms)

  FLAG = ICL9CEZBCPLX(
      *({
        __typeof__(_imp_string255) tmp = PARMS /*q*/;
        (_imp_string255 *)&tmp;
      })
  );

  //   266  flag = 0 %if flag = -1;                 ! INT:A

  if (FLAG != -1) goto L_001A;
  FLAG = 0;
L_001A:;

//   267  %if 0 # flag < 1000 %then %start

  {
// Double-sided test on FLAG (Part I)
    int tmp;
    if (0 == (tmp = FLAG)) goto L_001B;
// Double-sided test on FLAG (Part II)
    if (tmp >= 1000) goto L_001B;
  }

  //   268     newline

  _imp_NEWLINE();

  //   269     printstring("BCPLXREF fails -".failuremessage(flag))

  _imp_PRINTSTRING(
      *({
        __typeof__(_imp_string255) tmp = *({
          _imp_string255 tmp = _imp_join((_imp_string *)/*?*/ _imp_str_literal_ptr("BCPLXREF fails -"), ({
                                           __typeof__(_imp_string255) tmp; /*E*/
                                           tmp = FAILUREMESSAGE(FLAG);
                                           (void *)&tmp;
                                         }));
          (_imp_string255 *)&tmp;
        }) /*q*/;
        (_imp_string255 *)&tmp;
      })
  );

  //   270  %finish

L_001B:;

//   271  %end;   ! of bcplxref

  return;
} /* end of BCPLXREF */

//   272
//   273  %begin

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

  //   274    bcpl("")

  BCPL(_imp_str_literal(""));

  //   275  %end

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

//   276
//   277  %endoffile