#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 */
typedef int /*<<< orphan*/ chtype;

/* Variables and functions */
int /*<<< orphan*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_BLUE;
int /*<<< orphan*/ COLOR_CYAN;
int /*<<< orphan*/ COLOR_GREEN;
int /*<<< orphan*/ COLOR_MAGENTA;
int /*<<< orphan*/ COLOR_RED;
int /*<<< orphan*/ COLOR_WHITE;
int /*<<< orphan*/ COLOR_YELLOW;
scalar_t__ strcasecmp(char *, char *);
chtype get_color_by_name(char *colorname, chtype default_color) {
  if (strcasecmp(colorname, "red") == 0)
    return COLOR_RED;
  else if (strcasecmp(colorname, "black") == 0)
    return COLOR_BLACK;
  else if (strcasecmp(colorname, "green") == 0)
    return COLOR_GREEN;
  else if (strcasecmp(colorname, "yellow") == 0)
    return COLOR_YELLOW;
  else if (strcasecmp(colorname, "blue") == 0)
    return COLOR_BLUE;
  else if (strcasecmp(colorname, "magenta") == 0)
    return COLOR_MAGENTA;
  else if (strcasecmp(colorname, "cyan") == 0)
    return COLOR_CYAN;
  else if (strcasecmp(colorname, "white") == 0)
    return COLOR_WHITE;
  return default_color;
}


x86 assembly (clang, -O0):
<get_color_by_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed6(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    114a <get_color_by_name+0x3a>
mov    0x2e68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <get_color_by_name+0x190>
mov    -0x10(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1175 <get_color_by_name+0x65>
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <get_color_by_name+0x190>
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11a0 <get_color_by_name+0x90>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <get_color_by_name+0x190>
mov    -0x10(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11cb <get_color_by_name+0xbb>
mov    0x2df7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <get_color_by_name+0x190>
mov    -0x10(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11f6 <get_color_by_name+0xe6>
mov    0x2dc4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <get_color_by_name+0x190>
mov    -0x10(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1221 <get_color_by_name+0x111>
mov    0x2db1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <get_color_by_name+0x190>
mov    -0x10(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    124c <get_color_by_name+0x13c>
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <get_color_by_name+0x190>
mov    -0x10(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1277 <get_color_by_name+0x167>
mov    0x2d53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <get_color_by_name+0x190>
jmp    127c <get_color_by_name+0x16c>
jmp    1281 <get_color_by_name+0x171>
jmp    1286 <get_color_by_name+0x176>
jmp    128b <get_color_by_name+0x17b>
jmp    1290 <get_color_by_name+0x180>
jmp    1295 <get_color_by_name+0x185>
jmp    129a <get_color_by_name+0x18a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_color_by_name>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xee1(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11c6 <get_color_by_name+0xb6>
lea    0xed0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11cf <get_color_by_name+0xbf>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11d8 <get_color_by_name+0xc8>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11e1 <get_color_by_name+0xd1>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11ea <get_color_by_name+0xda>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11f3 <get_color_by_name+0xe3>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11fc <get_color_by_name+0xec>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    1205 <get_color_by_name+0xf5>
mov    0x2dfc(%rip),%rax
jmp    1203 <get_color_by_name+0xf3>
mov    0x2ddb(%rip),%rax
jmp    1203 <get_color_by_name+0xf3>
mov    0x2e12(%rip),%rax
jmp    1203 <get_color_by_name+0xf3>
mov    0x2df9(%rip),%rax
jmp    1203 <get_color_by_name+0xf3>
mov    0x2dd0(%rip),%rax
jmp    1203 <get_color_by_name+0xf3>
mov    0x2dbf(%rip),%rax
jmp    1203 <get_color_by_name+0xf3>
mov    0x2dce(%rip),%rax
jmp    1203 <get_color_by_name+0xf3>
mov    0x2ddd(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"red\00"
@COLOR_RED = global i32 0
@.str.1 = [6 x i8] c"black\00"
@COLOR_BLACK = 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 @get_color_by_name(i8* nocapture %0, i32 %1) {
%3 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = load i32, i32* @COLOR_RED
br label %42
7: ; preds = %2
%8 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = load i32, i32* @COLOR_BLACK
br label %42
12: ; preds = %7
%13 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i32, i32* @COLOR_GREEN
br label %42
17: ; preds = %12
%18 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i32, i32* @COLOR_YELLOW
br label %42
22: ; preds = %17
%23 = tail call i64 @strcasecmp(i8* %0, 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 = %22
%26 = load i32, i32* @COLOR_BLUE
br label %42
27: ; preds = %22
%28 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = load i32, i32* @COLOR_MAGENTA
br label %42
32: ; preds = %27
%33 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = load i32, i32* @COLOR_CYAN
br label %42
37: ; preds = %32
%38 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
%40 = load i32, i32* @COLOR_WHITE
%41 = select i1 %39, i32 %40, i32 %1
br label %42
42: ; preds = %37, %35, %30, %25, %20, %15, %10, %5
%43 = phi i32 [ %6, %5 ], [ %11, %10 ], [ %16, %15 ], [ %21, %20 ], [ %26, %25 ], [ %31, %30 ], [ %36, %35 ], [ %41, %37 ]
ret i32 %43
}