#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int shoot(int num_arrows, int x, int y, int dx, int dy, char map[7][7]) {
  x = x + dx;
  y = y + dy;
  if (num_arrows > 0) {
    printf("You shoot your arrow into the dark...\n");
    if (map[x][y] == 'W') {
      printf("\a You have slain a Wumpus!\n");
      return -1;
    } else {
      printf("And, you can hear it fall to the ground in the next room \n");
      return 0;
    }
  } else {
    printf("You dont have any more arrows!\n");
    return 0;
  }
}


x86 assembly (clang, -O0):
<shoot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11a4 <shoot+0x94>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x7,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x57,%eax
jne    118c <shoot+0x7c>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <shoot+0xa7>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <shoot+0xa7>
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shoot>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
jle    1165 <shoot+0x55>
mov    %r9,%r14
mov    %r8d,%ebp
mov    %ecx,%ebx
add    %edx,%ebp
add    %esi,%ebx
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
movslq %ebx,%rax
movslq %ebp,%rcx
lea    0x0(,%rax,8),%rdx
sub    %rax,%rdx
add    %rdx,%r14
xor    %ebp,%ebp
cmpb   $0x57,(%rcx,%r14,1)
sete   %bpl
lea    0xf29(%rip),%rax
lea    0xee8(%rip),%rdi
cmove  %rax,%rdi
neg    %ebp
jmp    116e <shoot+0x5e>
xor    %ebp,%ebp
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"You shoot your arrow into the dark...\0A\00"
@.str.1 = [28 x i8] c"\07 You have slain a Wumpus!\0A\00"
@.str.2 = [59 x i8] c"And, you can hear it fall to the ground in the next room \0A\00"
@.str.3 = [32 x i8] c"You dont have any more arrows!\0A\00"
define i32 @shoot(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, [7 x i8]* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [7 x i8]*
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store [7 x i8]* %5, [7 x i8]** %13
%14 = load i32, i32* %9
%15 = load i32, i32* %11
%16 = add nsw i32 %14, %15
store i32 %16, i32* %9
%17 = load i32, i32* %10
%18 = load i32, i32* %12
%19 = add nsw i32 %17, %18
store i32 %19, i32* %10
%20 = load i32, i32* %8
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %38
22: ; preds = %6
%23 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%24 = load [7 x i8]*, [7 x i8]** %13
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [7 x i8], [7 x i8]* %24, i64 %26
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [7 x i8], [7 x i8]* %27, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 87
br i1 %33, label %34, label %36
34: ; preds = %22
%35 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
br label %40
36: ; preds = %22
%37 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %40
38: ; preds = %6
%39 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %40
40: ; preds = %38, %36, %34
%41 = load i32, i32* %7
ret i32 %41
}

LLVM IR (-O2):
@str = [31 x i8] c"You dont have any more arrows!\00"
@str.4 = [38 x i8] c"You shoot your arrow into the dark...\00"
@str.5 = [58 x i8] c"And, you can hear it fall to the ground in the next room \00"
@str.6 = [27 x i8] c"\07 You have slain a Wumpus!\00"
define i32 @shoot(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, [7 x i8]* nocapture %5) {
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %19
8: ; preds = %6
%9 = add nsw i32 %4, %2
%10 = add nsw i32 %3, %1
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.4, i64 0, i64 0))
%12 = sext i32 %10 to i64
%13 = sext i32 %9 to i64
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 %12, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 87
%17 = select i1 %16, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([58 x i8], [58 x i8]* @str.5, i64 0, i64 0)
%18 = sext i1 %16 to i32
br label %19
19: ; preds = %6, %8
%20 = phi i8* [ %17, %8 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0), %6 ]
%21 = phi i32 [ %18, %8 ], [ 0, %6 ]
%22 = tail call i32 @puts(i8* dereferenceable(1) %20)
ret i32 %21
}