#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char const *, char *);
const char *choose_color(const char *arg) {
  if (!strcmp(arg, "red"))
    return "\033[31m";
  if (!strcmp(arg, "green"))
    return "\033[32m";
  if (!strcmp(arg, "brown"))
    return "\033[33m";
  if (!strcmp(arg, "blue"))
    return "\033[34m";
  if (!strcmp(arg, "magenta"))
    return "\033[35m";
  if (!strcmp(arg, "cyan"))
    return "\033[36m";
  if (!strcmp(arg, "white"))
    return "\033[37m";
  if (!strcmp(arg, "help") || !strcmp(arg, "-h") || !strcmp(arg, "--help")) {
    printf(
        "colorpipe - colorize output\n\n"
        "  Usage: colorpipe <color>\n\n"
        "  Valid colors are: \033[31mred, \033[32mgreen, \033[33mbrown, "
        "\033[34mblue, \033[35mmagenta, \033[36mcyan, \033[37mwhite\033[39m\n");
    exit(0);
  }
  fprintf(stderr,
          "\033[36mcolorpipe \033[31merror: \033[39mInvalid color code.\n");
  exit(22);
}


x86 assembly (clang, -O0):
<choose_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1175 <choose_color+0x35>
lea    0xe98(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <choose_color+0x1a8>
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    119e <choose_color+0x5e>
lea    0xe7b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <choose_color+0x1a8>
mov    -0x10(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11c7 <choose_color+0x87>
lea    0xe5e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <choose_color+0x1a8>
mov    -0x10(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11f0 <choose_color+0xb0>
lea    0xe40(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <choose_color+0x1a8>
mov    -0x10(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1219 <choose_color+0xd9>
lea    0xe25(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <choose_color+0x1a8>
mov    -0x10(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1242 <choose_color+0x102>
lea    0xe07(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <choose_color+0x1a8>
mov    -0x10(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    126b <choose_color+0x12b>
lea    0xdea(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12e8 <choose_color+0x1a8>
mov    -0x10(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     12b6 <choose_color+0x176>
mov    -0x10(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     12b6 <choose_color+0x176>
mov    -0x10(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12c9 <choose_color+0x189>
lea    0xd9f(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x16,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<choose_color>:
push   %rbx
mov    %rdi,%rbx
lea    0xeb5(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11cf <choose_color+0x8f>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11d8 <choose_color+0x98>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11e1 <choose_color+0xa1>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ea <choose_color+0xaa>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11f3 <choose_color+0xb3>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11fc <choose_color+0xbc>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1205 <choose_color+0xc5>
lea    0xe7f(%rip),%rax
pop    %rbx
ret
lea    0xe2e(%rip),%rax
pop    %rbx
ret
lea    0xe31(%rip),%rax
pop    %rbx
ret
lea    0xe34(%rip),%rax
pop    %rbx
ret
lea    0xe36(%rip),%rax
pop    %rbx
ret
lea    0xe3b(%rip),%rax
pop    %rbx
ret
lea    0xe3d(%rip),%rax
pop    %rbx
ret
lea    0xe4b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     123e <choose_color+0xfe>
lea    0xe33(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     123e <choose_color+0xfe>
lea    0xe23(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1251 <choose_color+0x111>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
lea    0xdfb(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x16,%edi
call   1060 <exit@plt>

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"
@.str.14 = [5 x i8] c"help\00"
@.str.15 = [3 x i8] c"-h\00"
@.str.16 = [7 x i8] c"--help\00"
@.str.17 = [164 x i8] c"colorpipe - colorize output\0A\0A Usage: colorpipe <color>\0A\0A Valid colors are: \1B[31mred, \1B[32mgreen, \1B[33mbrown, \1B[34mblue, \1B[35mmagenta, \1B[36mcyan, \1B[37mwhite\1B[39m\0A\00"
@stderr = global i32 0
@.str.18 = [53 x i8] c"\1B[36mcolorpipe \1B[31merror: \1B[39mInvalid color code.\0A\00"
define i8* @choose_color(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %57
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %57
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %57
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %57
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %57
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %28
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %57
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = call i32 @strcmp(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%36 = icmp ne i32 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %33
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %57
38: ; preds = %33
%39 = load i8*, i8** %3
%40 = call i32 @strcmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %50
42: ; preds = %38
%43 = load i8*, i8** %3
%44 = call i32 @strcmp(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i8*, i8** %3
%48 = call i32 @strcmp(i8* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0))
%49 = icmp ne i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %46, %42, %38
%51 = call i32 @printf(i8* getelementptr inbounds ([164 x i8], [164 x i8]* @.str.17, i64 0, i64 0))
%52 = call i32 @exit(i32 0)
unreachable
53: ; preds = %46
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.18, i64 0, i64 0))
%56 = call i32 @exit(i32 22)
unreachable
57: ; preds = %37, %32, %27, %22, %17, %12, %7
%58 = load i8*, i8** %2
ret i8* %58
}

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"
@.str.14 = [5 x i8] c"help\00"
@.str.15 = [3 x i8] c"-h\00"
@.str.16 = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.18 = [53 x i8] c"\1B[36mcolorpipe \1B[31merror: \1B[39mInvalid color code.\0A\00"
@str = [163 x i8] c"colorpipe - colorize output\0A\0A Usage: colorpipe <color>\0A\0A Valid colors are: \1B[31mred, \1B[32mgreen, \1B[33mbrown, \1B[34mblue, \1B[35mmagenta, \1B[36mcyan, \1B[37mwhite\1B[39m\00"
define i8* @choose_color(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 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 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %38, label %7
7: ; preds = %4
%8 = 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))
%9 = icmp eq i32 %8, 0
br i1 %9, label %38, label %10
10: ; preds = %7
%11 = 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))
%12 = icmp eq i32 %11, 0
br i1 %12, label %38, label %13
13: ; preds = %10
%14 = 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))
%15 = icmp eq i32 %14, 0
br i1 %15, label %38, label %16
16: ; preds = %13
%17 = 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))
%18 = icmp eq i32 %17, 0
br i1 %18, label %38, label %19
19: ; preds = %16
%20 = 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))
%21 = icmp eq i32 %20, 0
br i1 %21, label %38, label %22
22: ; preds = %19
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28, %25, %22
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([163 x i8], [163 x i8]* @str, i64 0, i64 0))
%33 = tail call i32 @exit(i32 0)
unreachable
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.18, i64 0, i64 0))
%37 = tail call i32 @exit(i32 22)
unreachable
38: ; preds = %19, %16, %13, %10, %7, %4, %1
%39 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), %10 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), %13 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), %16 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), %19 ]
ret i8* %39
}