#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*/ strcmp(char *, char *);
int choose_color(char *colorname, char const **colorcode) {
  if (!strcmp(colorname, "red")) {
    *colorcode = "\033[31m";
    return 0;
  }
  if (!strcmp(colorname, "green")) {
    *colorcode = "\033[32m";
    return 0;
  }
  if (!strcmp(colorname, "brown")) {
    *colorcode = "\033[33m";
    return 0;
  }
  if (!strcmp(colorname, "blue")) {
    *colorcode = "\033[34m";
    return 0;
  }
  if (!strcmp(colorname, "magenta")) {
    *colorcode = "\033[35m";
    return 0;
  }
  if (!strcmp(colorname, "cyan")) {
    *colorcode = "\033[36m";
    return 0;
  }
  if (!strcmp(colorname, "white")) {
    *colorcode = "\033[37m";
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<choose_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1153 <choose_color+0x43>
mov    -0x18(%rbp),%rax
lea    0xec0(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    128c <choose_color+0x17c>
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1186 <choose_color+0x76>
mov    -0x18(%rbp),%rax
lea    0xe99(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    128c <choose_color+0x17c>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11b9 <choose_color+0xa9>
mov    -0x18(%rbp),%rax
lea    0xe72(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    128c <choose_color+0x17c>
mov    -0x10(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11ec <choose_color+0xdc>
mov    -0x18(%rbp),%rax
lea    0xe4a(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    128c <choose_color+0x17c>
mov    -0x10(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    121f <choose_color+0x10f>
mov    -0x18(%rbp),%rax
lea    0xe25(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    128c <choose_color+0x17c>
mov    -0x10(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1252 <choose_color+0x142>
mov    -0x18(%rbp),%rax
lea    0xdfd(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    128c <choose_color+0x17c>
mov    -0x10(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1285 <choose_color+0x175>
mov    -0x18(%rbp),%rax
lea    0xdd6(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    128c <choose_color+0x17c>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<choose_color>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b0 <choose_color+0xa0>
lea    0xed5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b9 <choose_color+0xa9>
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11c2 <choose_color+0xb2>
lea    0xec7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11cb <choose_color+0xbb>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11d4 <choose_color+0xc4>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11dd <choose_color+0xcd>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
jne    11e9 <choose_color+0xd9>
lea    0xe9e(%rip),%rax
jmp    11e4 <choose_color+0xd4>
lea    0xe4d(%rip),%rax
jmp    11e4 <choose_color+0xd4>
lea    0xe50(%rip),%rax
jmp    11e4 <choose_color+0xd4>
lea    0xe53(%rip),%rax
jmp    11e4 <choose_color+0xd4>
lea    0xe55(%rip),%rax
jmp    11e4 <choose_color+0xd4>
lea    0xe5a(%rip),%rax
jmp    11e4 <choose_color+0xd4>
lea    0xe5c(%rip),%rax
mov    %rax,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"red\00"
@.str.1 = [6 x i8] c"\1B[31m\00"
@.str.2 = [6 x i8] c"green\00"
@.str.3 = [6 x i8] c"\1B[32m\00"
@.str.4 = [6 x i8] c"brown\00"
@.str.5 = [6 x i8] c"\1B[33m\00"
@.str.6 = [5 x i8] c"blue\00"
@.str.7 = [6 x i8] c"\1B[34m\00"
@.str.8 = [8 x i8] c"magenta\00"
@.str.9 = [6 x i8] c"\1B[35m\00"
@.str.10 = [5 x i8] c"cyan\00"
@.str.11 = [6 x i8] c"\1B[36m\00"
@.str.12 = [6 x i8] c"white\00"
@.str.13 = [6 x i8] c"\1B[37m\00"
define i32 @choose_color(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
%6 = load i8*, i8** %4
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = load i8**, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %10
store i32 0, i32* %3
br label %48
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = load i8**, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %16
store i32 0, i32* %3
br label %48
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = load i8**, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %22
store i32 0, i32* %3
br label %48
23: ; preds = %17
%24 = load i8*, i8** %4
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %23
%28 = load i8**, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8** %28
store i32 0, i32* %3
br label %48
29: ; preds = %23
%30 = load i8*, i8** %4
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %29
%34 = load i8**, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8** %34
store i32 0, i32* %3
br label %48
35: ; preds = %29
%36 = load i8*, i8** %4
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %35
%40 = load i8**, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8** %40
store i32 0, i32* %3
br label %48
41: ; preds = %35
%42 = load i8*, i8** %4
%43 = call i32 @strcmp(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%44 = icmp ne i32 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %41
%46 = load i8**, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8** %46
store i32 0, i32* %3
br label %48
47: ; preds = %41
store i32 -1, i32* %3
br label %48
48: ; preds = %47, %45, %39, %33, %27, %21, %15, %9
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [4 x i8] c"red\00"
@.str.1 = [6 x i8] c"\1B[31m\00"
@.str.2 = [6 x i8] c"green\00"
@.str.3 = [6 x i8] c"\1B[32m\00"
@.str.4 = [6 x i8] c"brown\00"
@.str.5 = [6 x i8] c"\1B[33m\00"
@.str.6 = [5 x i8] c"blue\00"
@.str.7 = [6 x i8] c"\1B[34m\00"
@.str.8 = [8 x i8] c"magenta\00"
@.str.9 = [6 x i8] c"\1B[35m\00"
@.str.10 = [5 x i8] c"cyan\00"
@.str.11 = [6 x i8] c"\1B[36m\00"
@.str.12 = [6 x i8] c"white\00"
@.str.13 = [6 x i8] c"\1B[37m\00"
define i32 @choose_color(i8* nocapture %0, i8** nocapture writeonly %1) {
%3 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %23, label %5
5: ; preds = %2
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %23, label %8
8: ; preds = %5
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %23, label %11
11: ; preds = %8
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %11
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20, %17, %14, %11, %8, %5, %2
%24 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), %11 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), %17 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), %20 ]
store i8* %24, i8** %1
br label %25
25: ; preds = %23, %20
%26 = phi i32 [ -1, %20 ], [ 0, %23 ]
ret i32 %26
}