#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*/ free(char *);
char *getStringToLower(char *);
scalar_t__ strEqual(char *, char *);
int get_toon_direction(char *direction_string_raw) {
  char *direction_string = getStringToLower(direction_string_raw);
  int direction = (strEqual(direction_string, "left")    ? (1 << 0)
                   : strEqual(direction_string, "right") ? (1 << 1)
                   : strEqual(direction_string, "up")    ? (1 << 2)
                   : strEqual(direction_string, "down")  ? (1 << 3)
                                                         : 0);
  free(direction_string);
  return direction;
}


x86 assembly (clang, -O0):
<get_toon_direction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getStringToLower@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1050 <strEqual@plt>
cmp    $0x0,%rax
je     1170 <get_toon_direction+0x40>
mov    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ee <get_toon_direction+0xbe>
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1050 <strEqual@plt>
cmp    $0x0,%rax
je     1197 <get_toon_direction+0x67>
mov    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e8 <get_toon_direction+0xb8>
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1050 <strEqual@plt>
cmp    $0x0,%rax
je     11be <get_toon_direction+0x8e>
mov    $0x4,%eax
mov    %eax,-0x20(%rbp)
jmp    11e2 <get_toon_direction+0xb2>
mov    -0x10(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1050 <strEqual@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0x8,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_toon_direction>:
push   %rbp
push   %rbx
push   %rax
call   1040 <getStringToLower@plt>
mov    %rax,%rbx
lea    0xebe(%rip),%rsi
mov    %rax,%rdi
call   1050 <strEqual@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    11a1 <get_toon_direction+0x71>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strEqual@plt>
mov    $0x2,%ebp
test   %rax,%rax
jne    11a1 <get_toon_direction+0x71>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strEqual@plt>
mov    $0x4,%ebp
test   %rax,%rax
jne    11a1 <get_toon_direction+0x71>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strEqual@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
shl    $0x3,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"left\00"
@.str.1 = [6 x i8] c"right\00"
@.str.2 = [3 x i8] c"up\00"
@.str.3 = [5 x i8] c"down\00"
define i32 @get_toon_direction(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @getStringToLower(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strEqual(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
br label %31
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i64 @strEqual(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
br label %29
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = call i64 @strEqual(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
br label %27
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = call i64 @strEqual(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 8, i32 0
br label %27
27: ; preds = %21, %20
%28 = phi i32 [ 4, %20 ], [ %26, %21 ]
br label %29
29: ; preds = %27, %15
%30 = phi i32 [ 2, %15 ], [ %28, %27 ]
br label %31
31: ; preds = %29, %10
%32 = phi i32 [ 1, %10 ], [ %30, %29 ]
store i32 %32, i32* %4
%33 = load i8*, i8** %3
%34 = call i32 @free(i8* %33)
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@.str = [5 x i8] c"left\00"
@.str.1 = [6 x i8] c"right\00"
@.str.2 = [3 x i8] c"up\00"
@.str.3 = [5 x i8] c"down\00"
define i32 @get_toon_direction(i8* %0) {
%2 = tail call i8* @getStringToLower(i8* %0)
%3 = tail call i64 @strEqual(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = tail call i64 @strEqual(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = tail call i64 @strEqual(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call i64 @strEqual(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i32 0, i32 8
br label %15
15: ; preds = %5, %8, %11, %1
%16 = phi i32 [ 1, %1 ], [ 2, %5 ], [ %14, %11 ], [ 4, %8 ]
%17 = tail call i32 @free(i8* %2)
ret i32 %16
}