#include <perms.h>

//          Edinburgh IMP77 Compiler - Version 8.4
//
//     1  %EXTERNALROUTINE WUMPUS (%STRING(255) PARMZZZ)

void WUMPUS(_imp_string255 PARMZZZ) {
  auto int FNR(int I);

  //     2   !%EXTERNALROUTINESPEC PROMPT(%STRING(15)S)
  //     3   !%EXTERNALSTRINGFNSPEC TIME
  //     4   %INTEGERFNSPEC FNR(%INTEGER I)
  //     5   %INTEGERARRAY R(1:20,1:3),BOG(1:20)

  int R[20][3];
  struct _imp_dv R_dv = {R, sizeof(int) /*, dims, <bounds> */};

  int BOG[20];
  struct _imp_dv BOG_dv = {BOG, sizeof(int) /*, dims, <bounds> */};

  //     6   %ROUTINE DRAIN

  void DRAIN(void) {
    //     7    SKIP SYMBOL %WHILE NEXT SYMBOL#NL ; SKIP SYMBOL

  L_0001:;
    if (_imp_NEXTSYMBOL() == 10) goto L_0002;
    _imp_SKIPSYMBOL();
    goto L_0001;
  L_0002:;
    _imp_SKIPSYMBOL();

    //     8    %END

    return;
  } /* end of DRAIN */

  //     9   %INTEGERFN GETANS

  int GETANS(void) {
    //    10    %INTEGER SYM

    int SYM;

    //    11     SKIP SYMBOL %WHILE 'N'#NEXTSYMBOL&95#'Y'

  L_0003:;
    {
      // Double-sided test on _imp_NEXTSYMBOL() & 95 (Part I)
      int tmp;
      if (78 == (tmp = _imp_NEXTSYMBOL() & 95)) goto L_0004;
      // Double-sided test on _imp_NEXTSYMBOL() & 95 (Part II)
      if (tmp == 89) goto L_0004;
    }
    _imp_SKIPSYMBOL();
    goto L_0003;
  L_0004:;

  //    12     SYM=NEXTSYMBOL&95 ; DRAIN ; %RESULT=SYM

    SYM = _imp_NEXTSYMBOL() & 95;
    DRAIN();
    return SYM;

    //    13    %END

  } /* end of GETANS */

  //    14   %ROUTINE GET REQUEST(%INTEGERNAME SYM)

  void GETREQUEST(int *SYM) {
    //    15    %CYCLE

  L_0005:;

  //    16     SYM=NEXTCH

    *SYM = _imp_NEXTCH();

    //    17     %IF '0'<=SYM<='9' %THENEXIT

    {
      // Double-sided test on SYM (Part I)
      int tmp;
      if (48 > (tmp = *SYM)) goto L_0006;
      // Double-sided test on SYM (Part II)
      if (tmp > 57) goto L_0006;
    }
    goto L_0007;
  L_0006:;

  //    18     %IF SYM='s' %OR SYM='S' %THENEXIT

    if (*SYM == 115) goto L_0008;
    if (*SYM != 83) goto L_0009;
  L_0008:;
    goto L_0007;
  L_0009:;

  //    19    SKIPSYMBOL

    _imp_SKIPSYMBOL();

    //    20    %REPEAT

    goto L_0005;
  L_0007:;

  //    21    %IF SYM='s' %THEN SYM='S'

    if (*SYM != 115) goto L_000A;
    *SYM = 83;
  L_000A:;

  //    22    %IF SYM#'S' %THEN READ(SYM)

    if (*SYM == 83) goto L_000B;
    _imp_READ(SYM);
  L_000B:;

  //    23    DRAIN

    DRAIN();

    //    24    %END

    return;
  } /* end of GETREQUEST */

  //    25   %INTEGER NO OF ARROWS, MOVE TO, W, H, B1, B2, P1, P2, WO, PO, BO

  int NOOFARROWS;
  int MOVETO;
  int W;
  int H;
  int B1;
  int B2;
  int P1;
  int P2;
  int WO;
  int PO;
  int BO;

  //    26   %INTEGER N1, N2, I, J, K, L, P, T, A1, ANS

  int N1;
  int N2;
  int I;
  int J;
  int K;
  int L;
  int P;
  int T;
  int A1;
  int ANS;

  //    27   %STRING(255) LINE

  _imp_string255 LINE;

  //    28   %ROUTINE RANDOMISE

  void RANDOMISE(void) {
    //    29    %INTEGER TEMP

    int TEMP;

    //    30     N1=0

    N1 = 0;

    //    31     LINE=TIME


    /* clang-format off */
_imp_strncpy(/*?*/&LINE, ({__typeof__(_imp_string8) tmp;/*B*/ tmp = _imp_TIME(); (void *)&tmp;}), /*max:*/255);

    /* clang-format on */

    //    32     %CYCLE I=1,1,LENGTH(LINE)

    // %for I = 1, 1, *_imp_LENGTH((_imp_string255 *)/*p*//*?*/&LINE) %cycle
    {
      int _final = *_imp_LENGTH((_imp_string255 *)/*p*/ /*?*/ &LINE);
      if (invalid_for_loop(1, 1, _final))
        _imp_signal(5, 1, 0, "Illegal cycle I = 1, 1, *_imp_LENGTH((_imp_string255 *)/*p*//*?*/&LINE)");
      I = 0;
    L_000C:
      if (I == _final) goto L_000D;
      I += 1;

      // ?Non-local
      //    33      N1=N1+CHARNO(LINE,I)

      N1 = N1 + *_imp_CHARNO((_imp_string255 *)/*p*/ /*?*/ &LINE, I);

      //    34     %REPEAT

      goto L_000C;
    }

  L_000D:;

  //    35     N2=10000-N1

    N2 = 10000 - N1;

    //    36     %CYCLE I=1,1,20

    // %for I = 1, 1, 20 %cycle
    {
      I = 0;
    L_000F:
      if (I == 20) goto L_0010;
      I += 1;

      // ?Non-local
      //    37      TEMP=FNR(20)

      TEMP = FNR(20);

      //    38      BOG(I)=0

      BOG[I - 1] = 0;

      //    39     %REPEAT

      goto L_000F;
    }

  L_0010:;

  //    40     %CYCLE I=1,1,20

    // %for I = 1, 1, 20 %cycle
    {
      I = 0;
    L_0011:
      if (I == 20) goto L_0012;
      I += 1;

      // ?Non-local
      //    41      %CYCLE J=1,1,3

      // %for J = 1, 1, 3 %cycle
      {
        J = 0;
      L_0013:
        if (J == 3) goto L_0014;
        J += 1;

        // ?Non-local
        //    42       R(I,J)=0

        R[I - 1][J - 1] = 0;

        //    43      %REPEAT

        goto L_0013;
      }

    L_0014:;

    //    44     %REPEAT

      goto L_0011;
    }

  L_0012:;

  //    45     P=1

    P = 1;

    //    46     R(1,1)=99

    R[0][0] = 99;

    //    47     %CYCLE I=1,1,19

    // %for I = 1, 1, 19 %cycle
    {
      I = 0;
    L_0016:
      if (I == 19) goto L_0017;
      I += 1;

      // ?Non-local
      //    48      T=FNR(20) %UNTIL R(T,1)=0

    L_0018:;
      T = FNR(20);
      if (R[T - 1][0] == 0) goto L_0019;
      goto L_0018;
    L_0019:;

    //    49      R(P,2)=T

      R[P - 1][1] = T;

      //    50      R(T,1)=P

      R[T - 1][0] = P;

      //    51      P=T

      P = T;

      //    52     %REPEAT

      goto L_0016;
    }

  L_0017:;

  //    53     R(P,2)=1

    R[P - 1][1] = 1;

    //    54     R(1,1)=P

    R[0][0] = P;

    //    55     P2=FNR(20)

    P2 = FNR(20);

    //    56     R(P2,3)=99

    R[P2 - 1][2] = 99;

    //    57     R(R(P2,2),3)=99

    R[R[P2 - 1][1] - 1][2] = 99;

    //    58     P=1

    P = 1;

    //    59     %CYCLE I=1,1,8

    // %for I = 1, 1, 8 %cycle
    {
      I = 0;
    L_001A:
      if (I == 8) goto L_001B;
      I += 1;

      // ?Non-local
      //    60      P=P+1 %WHILE R(P,3)>0

    L_001C:;
      if (R[P - 1][2] <= 0) goto L_001D;
      P = P + 1;
      goto L_001C;
    L_001D:;

    //    61      T=FNR(20) %UNTIL R(T,1)#P  %AND  R(T,2)#P  %AND  P#T  %AND  R(T,3)=0

    L_001E:;
      T = FNR(20);
      if (R[T - 1][0] == P) goto L_0015;
      if (R[T - 1][1] == P) goto L_0015;
      if (P == T) goto L_0015;
      if (R[T - 1][2] == 0) goto L_001F;
    L_0015:;
      goto L_001E;
    L_001F:;

    //    62      R(P,3)=T

      R[P - 1][2] = T;

      //    63      R(T,3)=P

      R[T - 1][2] = P;

      //    64      P=P+1

      P = P + 1;

      //    65     %REPEAT

      goto L_001A;
    }

  L_001B:;

  //    66     LABEL: T=FNR(20) %UNTIL %C

  U_1000:;
  L_0020:;
    T = FNR(20);
    if (P2 == T) goto L_000E;
    if (R[P2 - 1][0] == T) goto L_000E;
    if (R[P2 - 1][1] == T) goto L_000E;
    if (R[T - 1][2] == 0) goto L_0021;
  L_000E:;
    goto L_0020;
  L_0021:;

  //    67+              P2#T  %AND  R(P2,1)#T  %AND  R(P2,2)#T  %AND  R(T,3)=0
  //    68     P=R(P2,2)

    P = R[P2 - 1][1];

    //    69     R(P2,3)=T

    R[P2 - 1][2] = T;

    //    70     R(T,3)=P2

    R[T - 1][2] = P2;

    //    71     %IF R(R(P,1),3)=0 %OR R(R(P,2),3)=0 %THEN R(T,3)=0 %AND ->LABEL

    if (R[R[P - 1][0] - 1][2] == 0) goto L_0022;
    if (R[R[P - 1][1] - 1][2] != 0) goto L_0023;
  L_0022:;
    R[T - 1][2] = 0;
    goto U_1000;
  L_0023:;

  //    72     T=FNR(20) %UNTIL P#T %AND R(P,2)#T %AND R(P,1)#T %AND R(T,3)=0

  L_0024:;
    T = FNR(20);
    if (P == T) goto L_0025;
    if (R[P - 1][1] == T) goto L_0025;
    if (R[P - 1][0] == T) goto L_0025;
    if (R[T - 1][2] == 0) goto L_0026;
  L_0025:;
    goto L_0024;
  L_0026:;

  //    73     R(P,3)=T

    R[P - 1][2] = T;

    //    74     R(T,3)=P

    R[T - 1][2] = P;

    //    75     W=FNR(20)

    W = FNR(20);

    //    76     B1=FNR(20)

    B1 = FNR(20);

    //    77     B2=FNR(20) %UNTIL B2#B1

  L_0027:;
    B2 = FNR(20);
    if (B2 != B1) goto L_0028;
    goto L_0027;
  L_0028:;

  //    78     P1=FNR(20)

    P1 = FNR(20);

    //    79     P2=FNR(20) %UNTIL P2#P1

  L_0029:;
    P2 = FNR(20);
    if (P2 != P1) goto L_002A;
    goto L_0029;
  L_002A:;

  //    80     H=FNR(20)  %UNTIL  H#W  %AND  H#P1  %AND  H#P2  %AND  H#B1  %AND H#B2

  L_002B:;
    H = FNR(20);
    if (H == W) goto L_002C;
    if (H == P1) goto L_002C;
    if (H == P2) goto L_002C;
    if (H == B1) goto L_002C;
    if (H != B2) goto L_002D;
  L_002C:;
    goto L_002B;
  L_002D:;

  //    81    %END

    return;
  } /* end of RANDOMISE */

  //    82   %ROUTINE  GET NOW

  void GETNOW(void) {
    //    83    %INTEGER H1

    int H1;

    //    84     WO=0 ; BO=0 ; PO=0

    WO = 0;
    BO = 0;
    PO = 0;

    //    85     %CYCLE I=1,1,3

    // %for I = 1, 1, 3 %cycle
    {
      I = 0;
    L_002E:
      if (I == 3) goto L_002F;
      I += 1;

      // ?Non-local
      //    86      H1=R(H,I)

      H1 = R[H - 1][I - 1];

      //    87      %IF H1=P1 %OR H1=P2 %THEN PO=1

      if (H1 == P1) goto L_0031;
      if (H1 != P2) goto L_0032;
    L_0031:;
      PO = 1;
    L_0032:;

    //    88      %IF H1=B1 %OR H1=B2 %THEN BO=1

      if (H1 == B1) goto L_0033;
      if (H1 != B2) goto L_0034;
    L_0033:;
      BO = 1;
    L_0034:;

    //    89      %IF H1=W %THEN WO=1

      if (H1 != W) goto L_0035;
      WO = 1;
    L_0035:;

    //    90      %CYCLE J=1,1,3

      // %for J = 1, 1, 3 %cycle
      {
        J = 0;
      L_0036:
        if (J == 3) goto L_0037;
        J += 1;

        // ?Non-local
        //    91       %IF  R(H1,1)=W  %OR  R(H1,2)=W  %OR  R(H1,3)=W  %THEN WO=1

        if (R[H1 - 1][0] == W) goto L_0039;
        if (R[H1 - 1][1] == W) goto L_0039;
        if (R[H1 - 1][2] != W) goto L_003A;
      L_0039:;
        WO = 1;
      L_003A:;

      //    92      %REPEAT

        goto L_0036;
      }

    L_0037:;

    //    93     %REPEAT

      goto L_002E;
    }

  L_002F:;

  //    94    %END

    return;
  } /* end of GETNOW */

  //    95   %ROUTINE SUMMARIZE(%INTEGER I)

  void SUMMARIZE(int I) {
    //    96    %IF I>0 %THEN ->SKIP

    if (I <= 0) goto L_003B;
    goto U_1001;
  L_003B:;

  //    97    PRINTSTRING("You are in room")

    _imp_PRINTSTRING(_imp_str_literal("You are in room"));

    //    98    WRITE(H,0);NEWLINE

    _imp_WRITE(H, 0);
    _imp_NEWLINE();

    //    99    SKIP:PRINTSTRING("There are passages to")

  U_1001:;
    _imp_PRINTSTRING(_imp_str_literal("There are passages to"));

    //   100    WRITE(R(H,1),0);PRINTCH(',')

    _imp_WRITE(R[H - 1][0], 0);
    _imp_PRINTCH(44);

    //   101    WRITE(R(H,2),0);PRINTCH(',')

    _imp_WRITE(R[H - 1][1], 0);
    _imp_PRINTCH(44);

    //   102    WRITE(R(H,3),0);NEWLINE

    _imp_WRITE(R[H - 1][2], 0);
    _imp_NEWLINE();

    //   103    %IF WO=1 %THEN PRINTSTRING("I smell a Wumpus") %AND NEWLINE

    if (WO != 1) goto L_003C;
    _imp_PRINTSTRING(_imp_str_literal("I smell a Wumpus"));
    _imp_NEWLINE();
  L_003C:;

  //   104    %IF PO=1 %THEN PRINTSTRING("I feel a draft") %AND NEWLINE

    if (PO != 1) goto L_003D;
    _imp_PRINTSTRING(_imp_str_literal("I feel a draft"));
    _imp_NEWLINE();
  L_003D:;

  //   105    %IF BO=1 %THEN PRINTSTRING("I hear squeaking") %AND NEWLINE

    if (BO != 1) goto L_003E;
    _imp_PRINTSTRING(_imp_str_literal("I hear squeaking"));
    _imp_NEWLINE();
  L_003E:;

  //   106   %END

    return;
  } /* end of SUMMARIZE */

  //   107   %INTEGERFN FNR(%INTEGER I)

  int FNR(int I) {
    //   108    %REAL RTEMP

    float RTEMP;

    //   109    %INTEGER TEMP

    int TEMP;

    //   110     TEMP=((3*(N1<<14)+N2)+N2<<14)&(1<<28-1)

    TEMP = 3 * (N1 << 14) + N2 + (N2 << 14) & (1 << 28) - 1;

    //   111     N2=TEMP&X'3FFF'

    N2 = TEMP & 16383;

    //   112     N1=(TEMP-N2)>>14

    N1 = (unsigned int)TEMP - N2 >> 14;

    //   113     RTEMP=TEMP/(1<<28)

    RTEMP = (double)(TEMP / (1 << 28));

    //   114     %RESULT=1+INTPT(I*RTEMP)

    return 1 + _imp_INTPT(I * RTEMP);

    //   115    %END

  } /* end of FNR */

  //   116    PRINTSTRING("Would you like to see the rules?") ; NEWLINE

  _imp_PRINTSTRING(_imp_str_literal("Would you like to see the rules?"));
  _imp_NEWLINE();

  //   117    %IF GETANS='Y' %THENSTART

  if (GETANS() != 89) goto L_003F;

    //   118     PRINTSTRING("Sorry, chum - but there aint none!!!")

  _imp_PRINTSTRING(_imp_str_literal("Sorry, chum - but there aint none!!!"));

  //   119     NEWLINE

  _imp_NEWLINE();

  //   120    %FINISH

L_003F:;

//   121    PROMPT(":")

  _imp_PROMPT(_imp_str_literal_size(15, ":"));

  //   122    BEGIN: RANDOMISE

U_1002:;
  RANDOMISE();

  //   123    NO OF ARROWS=5

  NOOFARROWS = 5;

  //   124    MOVE LOOP: GET NOW

U_1001:;
  GETNOW();

  //   125    ERROR INPUT: SUMMARIZE(0)

U_1003:;
  SUMMARIZE(0);

  //   126    GET MOVE: PRINTSTRING("Your move, or ""S"" to shoot.") ; NEWLINE

U_1004:;
  _imp_PRINTSTRING(_imp_str_literal("Your move, or \"S\" to shoot."));
  _imp_NEWLINE();

  //   127    GET REQUEST(MOVE TO)

  GETREQUEST(/*?*/ &MOVETO);

  //   128    %IF MOVE TO='S' %THEN ->SHOOT %ELSE ->MOVE

  if (MOVETO != 83) goto L_0040;
  goto U_1005;
L_0040:;
  goto U_1006;

  //   129    WHAT ERR:

U_1007:;

//   130    PRINTSTRING("What, er..");PRINTCH(7);NEWLINE;->ERROR INPUT

  _imp_PRINTSTRING(_imp_str_literal("What, er.."));
  _imp_PRINTCH(7);
  _imp_NEWLINE();
  goto U_1003;

  //   131    MOVE:

U_1006:;

//   132    %IF R(H,1)=MOVETO %OR R(H,2)=MOVETO %OR R(H,3)=MOVETO %START

  if (R[H - 1][0] == MOVETO) goto L_0030;
  if (R[H - 1][1] == MOVETO) goto L_0030;
  if (R[H - 1][2] != MOVETO) goto L_0041;
L_0030:;

//   133     H=MOVE TO

  H = MOVETO;

  //   134    %FINISHELSESTART

  goto L_0042;
L_0041:;

//   135     ->WHAT ERR

  goto U_1007;

  //   136    %FINISH

L_0042:;

//   137    CHECK: %IF H=W %THEN ->EAT HUNTER

U_1008:;
  if (H != W) goto L_0043;
  goto U_1009;
L_0043:;

//   138    %IF H=P1 %OR H=P2 %THEN ->PIT

  if (H == P1) goto L_0044;
  if (H != P2) goto L_0045;
L_0044:;
  goto U_100A;
L_0045:;

//   139    %IF H=B1 %OR H=B2 %THEN ->BAT

  if (H == B1) goto L_0046;
  if (H != B2) goto L_0047;
L_0046:;
  goto U_100B;
L_0047:;

//   140    %IF BOG(H)#0 %THEN ->TOILET

  if (BOG[H - 1] == 0) goto L_0048;
  goto U_100C;
L_0048:;

//   141    ->MOVE LOOP

  goto U_1001;

  //   142    BAT: LOOP:

U_100B:;
U_100D:;

//   143    T=FNR(20)

  T = FNR(20);

  //   144    %IF T=H %THEN ->LOOP

  if (T != H) goto L_0049;
  goto U_100D;
L_0049:;

//   145    H=T

  H = T;

  //   146    PRINTSTRING("You have been captured by a bat !!!");NEWLINE

  _imp_PRINTSTRING(_imp_str_literal("You have been captured by a bat !!!"));
  _imp_NEWLINE();

  //   147    PRINTSTRING("You are now in room");WRITE(H,0);NEWLINE

  _imp_PRINTSTRING(_imp_str_literal("You are now in room"));
  _imp_WRITE(H, 0);
  _imp_NEWLINE();

  //   148    %IF H=W %OR H=B1 %OR H=B2 %OR H=P1 %OR H=P2 %THEN ->CHECK

  if (H == W) goto L_004A;
  if (H == B1) goto L_004A;
  if (H == B2) goto L_004A;
  if (H == P1) goto L_004A;
  if (H != P2) goto L_004B;
L_004A:;
  goto U_1008;
L_004B:;

//   149    GET NOW

  GETNOW();

  //   150    SUMMARIZE(1)

  SUMMARIZE(1);

  //   151    ->GET MOVE

  goto U_1004;

  //   152    EAT HUNTER:

U_1009:;

//   153    PRINTSTRING("You were eaten by the Wumpus!! You LOSE!!!")

  _imp_PRINTSTRING(_imp_str_literal("You were eaten by the Wumpus!! You LOSE!!!"));

  //   154    ->FINISH

  goto U_100E;

  //   155    PIT:

U_100A:;

//   156    PRINTSTRING("You fell into a BOTTOMless pit!! ")

  _imp_PRINTSTRING(_imp_str_literal("You fell into a BOTTOMless pit!! "));

  //   157    PRINTSTRING("You LOSE!!!") %AND ->FINISH %UNLESS %C

  if (FNR(10) != 10) goto L_004C;
  if (H == B1) goto L_004D;
  if (H == B2) goto L_004D;
L_004C:;
  _imp_PRINTSTRING(_imp_str_literal("You LOSE!!!"));
  goto U_100E;
L_004D:;

//   158+        FNR(10)=10 %AND (H=B1 %OR H=B2)
//   159    PRINTSTRING("But .... ");NEWLINE ; ->BAT

  _imp_PRINTSTRING(_imp_str_literal("But .... "));
  _imp_NEWLINE();
  goto U_100B;

  //   160    SHOOT: %IF NO OF ARROWS=0 %THEN ->NO ARROWS

U_1005:;
  if (NOOFARROWS != 0) goto L_004E;
  goto U_100F;
L_004E:;

//   161    NO OF ARROWS=NO OF ARROWS-1

  NOOFARROWS = NOOFARROWS - 1;

  //   162    A1=H

  A1 = H;

  //   163    %CYCLE I=1,1,5

  // %for I = 1, 1, 5 %cycle
  {
    I = 0;
  L_004F:
    if (I == 5) goto L_0050;
    I += 1;

    //   164     GET ARROW: PRINTSTRING("Where to?") ; NEWLINE

  U_1010:;
    _imp_PRINTSTRING(_imp_str_literal("Where to?"));
    _imp_NEWLINE();

    //   165     GET REQUEST(J)

    GETREQUEST(/*?*/ &J);

    //   166     %EXITIF J='S'

    if (J != 83) goto L_0052;
    goto L_0050;
  L_0052:;

  //   167     ->BOUNCE %UNLESS J=R(A1,1)  %OR  J=R(A1,2)  %OR  J=R(A1,3)

    if (J == R[A1 - 1][0]) goto L_0053;
    if (J == R[A1 - 1][1]) goto L_0053;
    if (J == R[A1 - 1][2]) goto L_0053;
    goto U_1011;
  L_0053:;

  //   168     ->BOUNCE %UNLESS FNR(10)<10

    if (FNR(10) < 10) goto L_0054;
    goto U_1011;
  L_0054:;

  //   169     A1=J ; %IF A1=W %THEN ->KILL ; %IF A1=H %THEN ->SUICIDE

    A1 = J;
    if (A1 != W) goto L_0055;
    goto U_1012;
  L_0055:;
    if (A1 != H) goto L_0056;
    goto U_1013;
  L_0056:;

  //   170     PRINTSTRING("Missed !!!") ; NEWLINE

    _imp_PRINTSTRING(_imp_str_literal("Missed !!!"));
    _imp_NEWLINE();

    //   171    %REPEAT

    goto L_004F;
  }

L_0050:;

//   172    WAKE WUMPUS: %IF FNR(4)=4 %THEN ->MOVELOOP

U_1014:;
  if (FNR(4) != 4) goto L_0057;
  goto U_1001;
L_0057:;

//   173    BOG(W)=1

  BOG[W - 1] = 1;

  //   174    W=R(W,FNR(3));  BOG(W)=0 ;

  W = R[W - 1][FNR(3) - 1];
  BOG[W - 1] = 0;

  //   175    %IF H#W %THENSTART

  if (H == W) goto L_0058;

    //   176     PRINTSTRING("You've woken the Wumpus!!!")

  _imp_PRINTSTRING(_imp_str_literal("You've woken the Wumpus!!!"));

  //   177     NEWLINE

  _imp_NEWLINE();

  //   178     ->MOVE LOOP

  goto U_1001;

  //   179    %FINISH

L_0058:;

//   180    PRINTSTRING("The Wumpus moved into your room !!!"); NEWLINE

  _imp_PRINTSTRING(_imp_str_literal("The Wumpus moved into your room !!!"));
  _imp_NEWLINE();

  //   181    ->EAT HUNTER

  goto U_1009;

  //   182    SUICIDE: PRINTSTRING("Fool, you shot yourself !!!"); NEWLINE; ->FINISH

U_1013:;
  _imp_PRINTSTRING(_imp_str_literal("Fool, you shot yourself !!!"));
  _imp_NEWLINE();
  goto U_100E;

  //   183    KILL: PRINTSTRING("CONGRATULATIONS, Great White Hunter !!!"); NEWLINE

U_1012:;
  _imp_PRINTSTRING(_imp_str_literal("CONGRATULATIONS, Great White Hunter !!!"));
  _imp_NEWLINE();

  //   184    PRINTSTRING("You slew the dreaded Wumpus !!!"); ->FINISH

  _imp_PRINTSTRING(_imp_str_literal("You slew the dreaded Wumpus !!!"));
  goto U_100E;

  //   185    NO ARROWS: PRINTSTRING("No arrows left !!!");NEWLINE; ->MOVE LOOP

U_100F:;
  _imp_PRINTSTRING(_imp_str_literal("No arrows left !!!"));
  _imp_NEWLINE();
  goto U_1001;

  //   186    TOILET: PRINTSTRING("Whoops! You've landed in Wump-Shit!!!")

U_100C:;
  _imp_PRINTSTRING(_imp_str_literal("Whoops! You've landed in Wump-Shit!!!"));

  //   187    NEWLINE ; ->MOVE LOOP

  _imp_NEWLINE();
  goto U_1001;

  //   188    BOUNCE:

U_1011:;

//   189     %CYCLE K=I,1,5

  // %for K = I, 1, 5 %cycle
  {
    int _initial = I;
    if (invalid_for_loop(_initial, 1, 5)) _imp_signal(5, 1, 0, "Illegal cycle K = I, 1, 5");
    K = _initial - (1);
  L_0059:
    if (K == 5) goto L_005A;
    K += 1;

    //   190      PRINTSTRING("BouNCE!!!")

    _imp_PRINTSTRING(_imp_str_literal("BouNCE!!!"));

    //   191      NEWLINE

    _imp_NEWLINE();

    //   192      A1=R(A1,FNR(3))

    A1 = R[A1 - 1][FNR(3) - 1];

    //   193      %IF A1=H %THEN ->SUICIDE

    if (A1 != H) goto L_005B;
    goto U_1013;
  L_005B:;

  //   194      %IF A1=W %THEN ->KILL

    if (A1 != W) goto L_005C;
    goto U_1012;
  L_005C:;

  //   195     %REPEAT

    goto L_0059;
  }

L_005A:;

//   196    ->WAKE WUMPUS

  goto U_1014;

  //   197    FINISH: NEWLINE

U_100E:;
  _imp_NEWLINE();

  //   198    PRINTSTRING("Another game?")

  _imp_PRINTSTRING(_imp_str_literal("Another game?"));

  //   199    NEWLINE

  _imp_NEWLINE();

  //   200    ANS=GETANS

  ANS = GETANS();

  //   201    %IF ANS='Y' %THEN ANS=FNR(10000) %AND ->BEGIN

  if (ANS != 89) goto L_005D;
  ANS = FNR(10000);
  goto U_1002;
L_005D:;

//   202   %END

  return;
} /* end of WUMPUS */

// ?GETARROW unused
// ?L unused
// ?PARMZZZ unused
//   203
//   204  %begin

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

  //   205    wumpus("")

  WUMPUS(_imp_str_literal(""));

  //   206  %end

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

//   207
//   208  %ENDOFFILE