#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*/ get_sword();
int /*<<< orphan*/ go_east();
int /*<<< orphan*/ go_north();
int /*<<< orphan*/ go_south();
int /*<<< orphan*/ go_west();
int /*<<< orphan*/ printf(char *);
scalar_t__ strcasecmp(char *, char *);
scalar_t__ strcmp(char *, char *);
int handle_input(char *input) {
  if (strcasecmp(input, "hello") == 0) {
    printf("Hello yourself\n");
  } else if (strcmp(input, "north") == 0) {
    go_north();
  } else if (strcmp(input, "south") == 0) {
    go_south();
  } else if (strcmp(input, "east") == 0) {
    go_east();
  } else if (strcmp(input, "west") == 0) {
    go_west();
  } else if (strcmp(input, "get sword") == 0) {
    get_sword();
  } else if (strcmp(input, "quit") == 0) {
    printf("Goodbye\n");
    return 1;
  } else {
    printf("I don't understand.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<handle_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11b7 <handle_input+0x37>
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
jmp    12d1 <handle_input+0x151>
mov    -0x10(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11dd <handle_input+0x5d>
mov    $0x0,%al
call   1090 <go_north@plt>
jmp    12cc <handle_input+0x14c>
mov    -0x10(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <handle_input+0x83>
mov    $0x0,%al
call   10a0 <go_south@plt>
jmp    12c7 <handle_input+0x147>
mov    -0x10(%rbp),%rdi
lea    0xe14(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1229 <handle_input+0xa9>
mov    $0x0,%al
call   1040 <go_east@plt>
jmp    12c2 <handle_input+0x142>
mov    -0x10(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    124f <handle_input+0xcf>
mov    $0x0,%al
call   1060 <go_west@plt>
jmp    12bd <handle_input+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1275 <handle_input+0xf5>
mov    $0x0,%al
call   1080 <get_sword@plt>
jmp    12b8 <handle_input+0x138>
mov    -0x10(%rbp),%rdi
lea    0xdb6(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12a7 <handle_input+0x127>
lea    0xda5(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d8 <handle_input+0x158>
lea    0xd96(%rip),%rdi
call   1050 <printf@plt>
jmp    12b8 <handle_input+0x138>
jmp    12bd <handle_input+0x13d>
jmp    12c2 <handle_input+0x142>
jmp    12c7 <handle_input+0x147>
jmp    12cc <handle_input+0x14c>
jmp    12d1 <handle_input+0x151>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_input>:
push   %rbx
mov    %rdi,%rbx
lea    0xe75(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     121a <handle_input+0x9a>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     122a <handle_input+0xaa>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1235 <handle_input+0xb5>
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1240 <handle_input+0xc0>
lea    0xe3b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     124b <handle_input+0xcb>
lea    0xe2c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1256 <handle_input+0xd6>
lea    0xe22(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1261 <handle_input+0xe1>
lea    0xe13(%rip),%rdi
jmp    1221 <handle_input+0xa1>
lea    0xe26(%rip),%rdi
call   1050 <puts@plt>
xor    %ebx,%ebx
jmp    1272 <handle_input+0xf2>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <go_north@plt>
jmp    1272 <handle_input+0xf2>
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <go_south@plt>
jmp    1272 <handle_input+0xf2>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <go_east@plt>
jmp    1272 <handle_input+0xf2>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <go_west@plt>
jmp    1272 <handle_input+0xf2>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <get_sword@plt>
jmp    1272 <handle_input+0xf2>
lea    0xdd7(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [16 x i8] c"Hello yourself\0A\00"
@.str.2 = [6 x i8] c"north\00"
@.str.3 = [6 x i8] c"south\00"
@.str.4 = [5 x i8] c"east\00"
@.str.5 = [5 x i8] c"west\00"
@.str.6 = [10 x i8] c"get sword\00"
@.str.7 = [5 x i8] c"quit\00"
@.str.8 = [9 x i8] c"Goodbye\0A\00"
@.str.9 = [21 x i8] c"I don't understand.\0A\00"
define i32 @handle_input(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strcasecmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %53
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 (...) @go_north()
br label %52
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (...) @go_south()
br label %51
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 (...) @go_east()
br label %50
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 (...) @go_west()
br label %49
33: ; preds = %27
%34 = load i8*, i8** %3
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 (...) @get_sword()
br label %48
39: ; preds = %33
%40 = load i8*, i8** %3
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %2
br label %54
45: ; preds = %39
%46 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %47
47: ; preds = %45
br label %48
48: ; preds = %47, %37
br label %49
49: ; preds = %48, %31
br label %50
50: ; preds = %49, %25
br label %51
51: ; preds = %50, %19
br label %52
52: ; preds = %51, %13
br label %53
53: ; preds = %52, %7
store i32 0, i32* %2
br label %54
54: ; preds = %53, %43
%55 = load i32, i32* %2
ret i32 %55
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.2 = [6 x i8] c"north\00"
@.str.3 = [6 x i8] c"south\00"
@.str.4 = [5 x i8] c"east\00"
@.str.5 = [5 x i8] c"west\00"
@.str.6 = [10 x i8] c"get sword\00"
@.str.7 = [5 x i8] c"quit\00"
@str = [20 x i8] c"I don't understand.\00"
@str.10 = [8 x i8] c"Goodbye\00"
@str.11 = [15 x i8] c"Hello yourself\00"
define i32 @handle_input(i8* %0) {
%2 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
br label %38
6: ; preds = %1
%7 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (...) @go_north()
br label %38
11: ; preds = %6
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 (...) @go_south()
br label %38
16: ; preds = %11
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 (...) @go_east()
br label %38
21: ; preds = %16
%22 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 (...) @go_west()
br label %38
26: ; preds = %21
%27 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 (...) @get_sword()
br label %38
31: ; preds = %26
%32 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.10, i64 0, i64 0))
br label %38
36: ; preds = %31
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %38
38: ; preds = %4, %14, %24, %36, %29, %19, %9, %34
%39 = phi i32 [ 1, %34 ], [ 0, %9 ], [ 0, %19 ], [ 0, %29 ], [ 0, %36 ], [ 0, %24 ], [ 0, %14 ], [ 0, %4 ]
ret i32 %39
}