#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  %recordformat Stack Fm ( %byte Form )

struct STACKFM {
  union {
    struct {
      unsigned char FORM;
    };
  };
};

//     2
//     3  %routine Fail ( %string(255) S )

static void FAIL(_imp_string255 S) {
  //     4  Print String("Fail: ")

  _imp_PRINTSTRING(_imp_str_literal("Fail: "));

  //     5  Print String(S)

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

  //     6  %stop

  _imp_stop(0);

  //     7  %end

} /* end of FAIL */

//     8
//     9  %externalroutine Pass2

void PASS2(void) {
  //    10  %ownrecord(Stack Fm) %name Stack == 0

  static struct STACKFM *STACK = 0;

  //    11  %routine Assemble

  void ASSEMBLE(void) {
    //    12  %routine Unary ( %string(2) Op )

    void UNARY(_imp_string2 OP) {
      //    13  %record(Stack Fm) %name X == Stack

      struct STACKFM *X;
      X = (struct STACKFM *)STACK;

      //    14  Fail("Unary Op") %if "-" # Op # "" %and Op # "|"

      {
        // Double-sided test on OP (Part I)
        _imp_string2 *tmp;

        /* clang-format off */
if (_imp_strcmp((_imp_string *)/*?*/_imp_str_literal_ptr("-"), (_imp_string *)(tmp=/*?*/&OP)) == 0) goto L_0001;

        /* clang-format on */

        /* clang-format off */
// Double-sided test on OP (Part II)
if (_imp_strcmp((_imp_string *)tmp, (_imp_string *)/*?*/_imp_str_literal_ptr("")) == 0) goto L_0001;
}

      /* clang-format on */

      /* clang-format off */
if (_imp_strcmp((_imp_string *)/*?*/&OP, (_imp_string *)/*?*/_imp_str_literal_ptr("|")) == 0) goto L_0001;

      /* clang-format on */
      FAIL(_imp_str_literal("Unary Op"));
    L_0001:;

    //    15  %end

      return;
    } /* end of UNARY */

    // ?X unused
    //    16  Unary("~")

    UNARY(_imp_str_literal_size(2, "~"));

    //    17  %end

    return;
  } /* end of ASSEMBLE */

  //    18  Assemble

  ASSEMBLE();

  //    19  %end

  return;
} /* end of PASS2 */

//    20
//    21  %endoffile