#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 COLOR_BLACK;
int COLOR_BLUE;
int COLOR_CYAN;
int COLOR_GREEN;
int COLOR_MAGENTA;
int COLOR_RED;
int COLOR_WHITE;
int COLOR_YELLOW;
scalar_t__ strcmp(char const *, char *);
int str_to_color(const char *str) {
  if (strcmp(str, "black") == 0)
    return COLOR_BLACK;
  else if (strcmp(str, "red") == 0)
    return COLOR_RED;
  else if (strcmp(str, "green") == 0)
    return COLOR_GREEN;
  else if (strcmp(str, "yellow") == 0)
    return COLOR_YELLOW;
  else if (strcmp(str, "blue") == 0)
    return COLOR_BLUE;
  else if (strcmp(str, "magenta") == 0)
    return COLOR_MAGENTA;
  else if (strcmp(str, "cyan") == 0)
    return COLOR_CYAN;
  else if (strcmp(str, "white") == 0)
    return COLOR_WHITE;
  return COLOR_BLACK;
}


x86 assembly (clang, -O0):
<str_to_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1147 <str_to_color+0x37>
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <str_to_color+0x193>
mov    -0x10(%rbp),%rdi
lea    0xeb4(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1172 <str_to_color+0x62>
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <str_to_color+0x193>
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119d <str_to_color+0x8d>
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <str_to_color+0x193>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c8 <str_to_color+0xb8>
mov    0x2dfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <str_to_color+0x193>
mov    -0x10(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11f3 <str_to_color+0xe3>
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <str_to_color+0x193>
mov    -0x10(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    121e <str_to_color+0x10e>
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <str_to_color+0x193>
mov    -0x10(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1249 <str_to_color+0x139>
mov    0x2da1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <str_to_color+0x193>
mov    -0x10(%rbp),%rdi
lea    0xdd5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1274 <str_to_color+0x164>
mov    0x2d56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a3 <str_to_color+0x193>
jmp    1279 <str_to_color+0x169>
jmp    127e <str_to_color+0x16e>
jmp    1283 <str_to_color+0x173>
jmp    1288 <str_to_color+0x178>
jmp    128d <str_to_color+0x17d>
jmp    1292 <str_to_color+0x182>
jmp    1297 <str_to_color+0x187>
mov    0x2d4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_to_color>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c2 <str_to_color+0xb2>
lea    0xed6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11cb <str_to_color+0xbb>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d4 <str_to_color+0xc4>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11dd <str_to_color+0xcd>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e6 <str_to_color+0xd6>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ef <str_to_color+0xdf>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f8 <str_to_color+0xe8>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11c2 <str_to_color+0xb2>
mov    0x2e00(%rip),%rax
jmp    11ff <str_to_color+0xef>
mov    0x2e1f(%rip),%rax
jmp    11ff <str_to_color+0xef>
mov    0x2dd6(%rip),%rax
jmp    11ff <str_to_color+0xef>
mov    0x2dfd(%rip),%rax
jmp    11ff <str_to_color+0xef>
mov    0x2dd4(%rip),%rax
jmp    11ff <str_to_color+0xef>
mov    0x2dc3(%rip),%rax
jmp    11ff <str_to_color+0xef>
mov    0x2dd2(%rip),%rax
jmp    11ff <str_to_color+0xef>
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"black\00"
@COLOR_BLACK = global i32 0
@.str.1 = [4 x i8] c"red\00"
@COLOR_RED = global i32 0
@.str.2 = [6 x i8] c"green\00"
@COLOR_GREEN = global i32 0
@.str.3 = [7 x i8] c"yellow\00"
@COLOR_YELLOW = global i32 0
@.str.4 = [5 x i8] c"blue\00"
@COLOR_BLUE = global i32 0
@.str.5 = [8 x i8] c"magenta\00"
@COLOR_MAGENTA = global i32 0
@.str.6 = [5 x i8] c"cyan\00"
@COLOR_CYAN = global i32 0
@.str.7 = [6 x i8] c"white\00"
@COLOR_WHITE = global i32 0
define i32 @str_to_color(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strcmp(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 = load i32, i32* @COLOR_BLACK
store i32 %8, i32* %2
br label %60
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i32, i32* @COLOR_RED
store i32 %14, i32* %2
br label %60
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i32, i32* @COLOR_GREEN
store i32 %20, i32* %2
br label %60
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load i32, i32* @COLOR_YELLOW
store i32 %26, i32* %2
br label %60
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = load i32, i32* @COLOR_BLUE
store i32 %32, i32* %2
br label %60
33: ; preds = %27
%34 = load i8*, i8** %3
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load i32, i32* @COLOR_MAGENTA
store i32 %38, i32* %2
br label %60
39: ; preds = %33
%40 = load i8*, i8** %3
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = load i32, i32* @COLOR_CYAN
store i32 %44, i32* %2
br label %60
45: ; preds = %39
%46 = load i8*, i8** %3
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = load i32, i32* @COLOR_WHITE
store i32 %50, i32* %2
br label %60
51: ; preds = %45
br label %52
52: ; preds = %51
br label %53
53: ; preds = %52
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54
br label %56
56: ; preds = %55
br label %57
57: ; preds = %56
br label %58
58: ; preds = %57
%59 = load i32, i32* @COLOR_BLACK
store i32 %59, i32* %2
br label %60
60: ; preds = %58, %49, %43, %37, %31, %25, %19, %13, %7
%61 = load i32, i32* %2
ret i32 %61
}

LLVM IR (-O2):
@.str = [6 x i8] c"black\00"
@COLOR_BLACK = global i32 0
@.str.1 = [4 x i8] c"red\00"
@COLOR_RED = global i32 0
@.str.2 = [6 x i8] c"green\00"
@COLOR_GREEN = global i32 0
@.str.3 = [7 x i8] c"yellow\00"
@COLOR_YELLOW = global i32 0
@.str.4 = [5 x i8] c"blue\00"
@COLOR_BLUE = global i32 0
@.str.5 = [8 x i8] c"magenta\00"
@COLOR_MAGENTA = global i32 0
@.str.6 = [5 x i8] c"cyan\00"
@COLOR_CYAN = global i32 0
@.str.7 = [6 x i8] c"white\00"
@COLOR_WHITE = global i32 0
define i32 @str_to_color(i8* %0) {
%2 = tail call i64 @strcmp(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 %26, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %26, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %26, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, i32* @COLOR_WHITE, i32* @COLOR_BLACK
br label %26
26: ; preds = %22, %19, %16, %13, %10, %7, %4, %1
%27 = phi i32* [ @COLOR_BLACK, %1 ], [ @COLOR_RED, %4 ], [ @COLOR_GREEN, %7 ], [ @COLOR_YELLOW, %10 ], [ @COLOR_BLUE, %13 ], [ @COLOR_MAGENTA, %16 ], [ @COLOR_CYAN, %19 ], [ %25, %22 ]
%28 = load i32, i32* %27
ret i32 %28
}