#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 move(int x, int y, int dx, int dy, char map[7][7]) {
  x = x + dx;
  y = y + dy;
  if (map[x][y] == '#') {
    printf("You try to move in that direction,");
    printf("but you bump into that wall.\n");
    return 0;
  } else if (map[x][y] == 'P') {
    printf("Yikes! You have fallen into a bottomless pit!");
    printf("Better Luck next time.\n");
    return -1;
  } else if (map[x][y] == 'W') {
    printf("Munch..Munch..\n");
    printf("The Wumpus has just had you for Lunch.\n");
    return -1;
  } else
    return 1;
}


x86 assembly (clang, -O0):
<move>:
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    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   $0x7,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
jne    117e <move+0x6e>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    120d <move+0xfd>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   $0x7,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x50,%eax
jne    11c2 <move+0xb2>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120d <move+0xfd>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   $0x7,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x57,%eax
jne    1206 <move+0xf6>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120d <move+0xfd>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move>:
push   %rbx
add    %edx,%edi
add    %ecx,%esi
movslq %edi,%rax
movslq %esi,%rcx
lea    0x0(,%rax,8),%rdx
sub    %rax,%rdx
add    %r8,%rdx
mov    (%rcx,%rdx,1),%al
cmp    $0x57,%al
je     1164 <move+0x44>
cmp    $0x50,%al
je     117e <move+0x5e>
mov    $0x1,%ebx
cmp    $0x23,%al
jne    119b <move+0x7b>
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
xor    %ebx,%ebx
lea    0xf3c(%rip),%rdi
jmp    1196 <move+0x76>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
lea    0xee4(%rip),%rdi
jmp    1196 <move+0x76>
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%ebx
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"You try to move in that direction,\00"
@.str.1 = [30 x i8] c"but you bump into that wall.\0A\00"
@.str.2 = [46 x i8] c"Yikes! You have fallen into a bottomless pit!\00"
@.str.3 = [24 x i8] c"Better Luck next time.\0A\00"
@.str.4 = [16 x i8] c"Munch..Munch..\0A\00"
@.str.5 = [40 x i8] c"The Wumpus has just had you for Lunch.\0A\00"
define i32 @move(i32 %0, i32 %1, i32 %2, i32 %3, [7 x i8]* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [7 x i8]*
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store [7 x i8]* %4, [7 x i8]** %11
%12 = load i32, i32* %7
%13 = load i32, i32* %9
%14 = add nsw i32 %12, %13
store i32 %14, i32* %7
%15 = load i32, i32* %8
%16 = load i32, i32* %10
%17 = add nsw i32 %15, %16
store i32 %17, i32* %8
%18 = load [7 x i8]*, [7 x i8]** %11
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [7 x i8], [7 x i8]* %18, i64 %20
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [7 x i8], [7 x i8]* %21, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 35
br i1 %27, label %28, label %31
28: ; preds = %5
%29 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %60
31: ; preds = %5
%32 = load [7 x i8]*, [7 x i8]** %11
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [7 x i8], [7 x i8]* %32, i64 %34
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [7 x i8], [7 x i8]* %35, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 80
br i1 %41, label %42, label %45
42: ; preds = %31
%43 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %6
br label %60
45: ; preds = %31
%46 = load [7 x i8]*, [7 x i8]** %11
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [7 x i8], [7 x i8]* %46, i64 %48
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [7 x i8], [7 x i8]* %49, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 87
br i1 %55, label %56, label %59
56: ; preds = %45
%57 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%58 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %6
br label %60
59: ; preds = %45
store i32 1, i32* %6
br label %60
60: ; preds = %59, %56, %42, %28
%61 = load i32, i32* %6
ret i32 %61
}

LLVM IR (-O2):
@.str = [35 x i8] c"You try to move in that direction,\00"
@.str.2 = [46 x i8] c"Yikes! You have fallen into a bottomless pit!\00"
@str = [15 x i8] c"Munch..Munch..\00"
@str.6 = [39 x i8] c"The Wumpus has just had you for Lunch.\00"
@str.7 = [23 x i8] c"Better Luck next time.\00"
@str.8 = [29 x i8] c"but you bump into that wall.\00"
define i32 @move(i32 %0, i32 %1, i32 %2, i32 %3, [7 x i8]* nocapture %4) {
%6 = add nsw i32 %2, %0
%7 = add nsw i32 %3, %1
%8 = sext i32 %6 to i64
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 %8, i64 %9
%11 = load i8, i8* %10
switch i8 %11, label %22 [
i8 35, label %12
i8 80, label %14
i8 87, label %16
]
12: ; preds = %5
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %18
14: ; preds = %5
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
br label %18
16: ; preds = %5
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %12, %14, %16
%19 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.6, i64 0, i64 0), %16 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.7, i64 0, i64 0), %14 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0), %12 ]
%20 = phi i32 [ -1, %16 ], [ -1, %14 ], [ 0, %12 ]
%21 = tail call i32 @puts(i8* dereferenceable(1) %19)
br label %22
22: ; preds = %18, %5
%23 = phi i32 [ 1, %5 ], [ %20, %18 ]
ret i32 %23
}