#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*/ c_printf(char *, char *, char);
int /*<<< orphan*/ exit(int);
const char *c_key(char k) {
  switch (k) {
  case 'r':
    return "\x1b[31m";
  case 'g':
    return "\x1b[32m";
  case 'y':
    return "\x1b[33m";
  case 'b':
    return "\x1b[34m";
  case 'm':
    return "\x1b[35m";
  case 'c':
    return "\x1b[36m";
  case 'n':
    return "\x1b[0m";
  default:
    c_printf("[r]%s[-]%c\n", " - ERROR: invalid key for color: ", k);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<c_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x17,%eax
ja     11c8 <c_key+0xa8>
mov    -0x18(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf01(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e9 <c_key+0xc9>
lea    0xef7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e9 <c_key+0xc9>
lea    0xeed(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e9 <c_key+0xc9>
lea    0xee3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e9 <c_key+0xc9>
lea    0xed9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e9 <c_key+0xc9>
lea    0xecf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e9 <c_key+0xc9>
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e9 <c_key+0xc9>
lea    0xeba(%rip),%rdi
lea    0xebf(%rip),%rsi
movsbl -0x9(%rbp),%edx
call   1030 <c_printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_key>:
push   %rax
lea    -0x62(%rdi),%ecx
cmp    $0x17,%ecx
ja     1176 <c_key+0x56>
lea    0xf30(%rip),%rax
lea    0xec9(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf2b(%rip),%rax
pop    %rcx
ret
lea    0xf2e(%rip),%rax
pop    %rcx
ret
lea    0xf0d(%rip),%rax
pop    %rcx
ret
lea    0xf16(%rip),%rax
pop    %rcx
ret
lea    0xf19(%rip),%rax
pop    %rcx
ret
lea    0xef8(%rip),%rax
pop    %rcx
ret
movsbl %dil,%edx
lea    0xf08(%rip),%rdi
lea    0xf0d(%rip),%rsi
call   1030 <c_printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\1B[31m\00"
@.str.1 = [6 x i8] c"\1B[32m\00"
@.str.2 = [6 x i8] c"\1B[33m\00"
@.str.3 = [6 x i8] c"\1B[34m\00"
@.str.4 = [6 x i8] c"\1B[35m\00"
@.str.5 = [6 x i8] c"\1B[36m\00"
@.str.6 = [5 x i8] c"\1B[0m\00"
@.str.7 = [12 x i8] c"[r]%s[-]%c\0A\00"
@.str.8 = [34 x i8] c" - ERROR: invalid key for color: \00"
define i8* @c_key(i8 signext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %13 [
i32 114, label %6
i32 103, label %7
i32 121, label %8
i32 98, label %9
i32 109, label %10
i32 99, label %11
i32 110, label %12
]
6: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
br label %17
7: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %17
8: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %17
9: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %17
10: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %17
11: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %17
12: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %17
13: ; preds = %1
%14 = load i8, i8* %3
%15 = call i32 @c_printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i8 signext %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %12, %11, %10, %9, %8, %7, %6
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
@.str = [6 x i8] c"\1B[31m\00"
@.str.1 = [6 x i8] c"\1B[32m\00"
@.str.2 = [6 x i8] c"\1B[33m\00"
@.str.3 = [6 x i8] c"\1B[34m\00"
@.str.4 = [6 x i8] c"\1B[35m\00"
@.str.5 = [6 x i8] c"\1B[36m\00"
@.str.6 = [5 x i8] c"\1B[0m\00"
@.str.7 = [12 x i8] c"[r]%s[-]%c\0A\00"
@.str.8 = [34 x i8] c" - ERROR: invalid key for color: \00"
define i8* @c_key(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %9 [
i32 114, label %12
i32 103, label %3
i32 121, label %4
i32 98, label %5
i32 109, label %6
i32 99, label %7
i32 110, label %8
]
3: ; preds = %1
br label %12
4: ; preds = %1
br label %12
5: ; preds = %1
br label %12
6: ; preds = %1
br label %12
7: ; preds = %1
br label %12
8: ; preds = %1
br label %12
9: ; preds = %1
%10 = tail call i32 @c_printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0), i8 signext %0)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %1, %8, %7, %6, %5, %4, %3
%13 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %8 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %13
}