#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*/ str_cmp(char *, char *);
int get_direction(char *arg) {
  if (!str_cmp(arg, "n") || !str_cmp(arg, "north"))
    return 0;
  if (!str_cmp(arg, "e") || !str_cmp(arg, "east"))
    return 1;
  if (!str_cmp(arg, "s") || !str_cmp(arg, "south"))
    return 2;
  if (!str_cmp(arg, "w") || !str_cmp(arg, "west"))
    return 3;
  if (!str_cmp(arg, "u") || !str_cmp(arg, "up"))
    return 4;
  if (!str_cmp(arg, "d") || !str_cmp(arg, "down"))
    return 5;
  return -1;
}


x86 assembly (clang, -O0):
<get_direction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeff(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
je     114e <get_direction+0x3e>
mov    -0x10(%rbp),%rdi
lea    0xec0(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
jne    115a <get_direction+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    1297 <get_direction+0x187>
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
je     118c <get_direction+0x7c>
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
jne    1198 <get_direction+0x88>
movl   $0x1,-0x4(%rbp)
jmp    1297 <get_direction+0x187>
mov    -0x10(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
je     11ca <get_direction+0xba>
mov    -0x10(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
jne    11d6 <get_direction+0xc6>
movl   $0x2,-0x4(%rbp)
jmp    1297 <get_direction+0x187>
mov    -0x10(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
je     1208 <get_direction+0xf8>
mov    -0x10(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
jne    1214 <get_direction+0x104>
movl   $0x3,-0x4(%rbp)
jmp    1297 <get_direction+0x187>
mov    -0x10(%rbp),%rdi
lea    0xdfd(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
je     1246 <get_direction+0x136>
mov    -0x10(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
jne    1252 <get_direction+0x142>
movl   $0x4,-0x4(%rbp)
jmp    1297 <get_direction+0x187>
mov    -0x10(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
je     1284 <get_direction+0x174>
mov    -0x10(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   1030 <str_cmp@plt>
cmp    $0x0,%eax
jne    1290 <get_direction+0x180>
movl   $0x5,-0x4(%rbp)
jmp    1297 <get_direction+0x187>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_direction>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xf09(%rip),%rsi
call   1030 <str_cmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     122f <get_direction+0x11f>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
test   %eax,%eax
je     122f <get_direction+0x11f>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     122f <get_direction+0x11f>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
test   %eax,%eax
je     122f <get_direction+0x11f>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
mov    $0x2,%ebp
test   %eax,%eax
je     122f <get_direction+0x11f>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
test   %eax,%eax
je     122f <get_direction+0x11f>
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
mov    $0x3,%ebp
test   %eax,%eax
je     122f <get_direction+0x11f>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
test   %eax,%eax
je     122f <get_direction+0x11f>
lea    0xe41(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
mov    $0x4,%ebp
test   %eax,%eax
je     122f <get_direction+0x11f>
lea    0xe2b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
test   %eax,%eax
je     122f <get_direction+0x11f>
lea    0xe1b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
test   %eax,%eax
je     122a <get_direction+0x11a>
lea    0xe0a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <str_cmp@plt>
neg    %eax
sbb    %ebp,%ebp
or     $0x5,%ebp
jmp    122f <get_direction+0x11f>
mov    $0x5,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"n\00"
@.str.1 = [6 x i8] c"north\00"
@.str.2 = [2 x i8] c"e\00"
@.str.3 = [5 x i8] c"east\00"
@.str.4 = [2 x i8] c"s\00"
@.str.5 = [6 x i8] c"south\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [5 x i8] c"west\00"
@.str.8 = [2 x i8] c"u\00"
@.str.9 = [3 x i8] c"up\00"
@.str.10 = [2 x i8] c"d\00"
@.str.11 = [5 x i8] c"down\00"
define i32 @get_direction(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @str_cmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @str_cmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7, %1
store i32 0, i32* %2
br label %58
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i32 @str_cmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i32 @str_cmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %16, %12
store i32 1, i32* %2
br label %58
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = call i32 @str_cmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i8*, i8** %3
%27 = call i32 @str_cmp(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %25, %21
store i32 2, i32* %2
br label %58
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = call i32 @str_cmp(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i8*, i8** %3
%36 = call i32 @str_cmp(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %34, %30
store i32 3, i32* %2
br label %58
39: ; preds = %34
%40 = load i8*, i8** %3
%41 = call i32 @str_cmp(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load i8*, i8** %3
%45 = call i32 @str_cmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
br i1 %46, label %48, label %47
47: ; preds = %43, %39
store i32 4, i32* %2
br label %58
48: ; preds = %43
%49 = load i8*, i8** %3
%50 = call i32 @str_cmp(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load i8*, i8** %3
%54 = call i32 @str_cmp(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%55 = icmp ne i32 %54, 0
br i1 %55, label %57, label %56
56: ; preds = %52, %48
store i32 5, i32* %2
br label %58
57: ; preds = %52
store i32 -1, i32* %2
br label %58
58: ; preds = %57, %56, %47, %38, %29, %20, %11
%59 = load i32, i32* %2
ret i32 %59
}

LLVM IR (-O2):
@.str = [2 x i8] c"n\00"
@.str.1 = [6 x i8] c"north\00"
@.str.2 = [2 x i8] c"e\00"
@.str.3 = [5 x i8] c"east\00"
@.str.4 = [2 x i8] c"s\00"
@.str.5 = [6 x i8] c"south\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [5 x i8] c"west\00"
@.str.8 = [2 x i8] c"u\00"
@.str.9 = [3 x i8] c"up\00"
@.str.10 = [2 x i8] c"d\00"
@.str.11 = [5 x i8] c"down\00"
define i32 @get_direction(i8* %0) {
%2 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %38, label %4
4: ; preds = %1
%5 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %38, label %7
7: ; preds = %4
%8 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %38, label %10
10: ; preds = %7
%11 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %38, label %13
13: ; preds = %10
%14 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %38, label %16
16: ; preds = %13
%17 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %38, label %19
19: ; preds = %16
%20 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %38, label %22
22: ; preds = %19
%23 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %38, label %25
25: ; preds = %22
%26 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %38, label %28
28: ; preds = %25
%29 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %38, label %31
31: ; preds = %28
%32 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %31
%35 = tail call i32 @str_cmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i32 5, i32 -1
br label %38
38: ; preds = %34, %31, %25, %28, %19, %22, %13, %16, %7, %10, %1, %4
%39 = phi i32 [ 0, %4 ], [ 0, %1 ], [ 1, %10 ], [ 1, %7 ], [ 2, %16 ], [ 2, %13 ], [ 3, %22 ], [ 3, %19 ], [ 4, %28 ], [ 4, %25 ], [ 5, %31 ], [ %37, %34 ]
ret i32 %39
}