#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*/ printf(char *);
void color(int i) {
  switch (i) {
  case 30:
    printf("\e[0;30m");
    break;
  case 31:
    printf("\e[0;31m");
    break;
  case 32:
    printf("\e[0;32m");
    break;
  case 33:
    printf("\e[1;33m");
    break;
  case 34:
    printf("\e[1;34m");
    break;
  case 35:
    printf("\e[1;31m");
    break;
  case 36:
    printf("\e[0;36m");
    break;
  case 37:
    printf("\e[1;37m");
    break;
  case 38:
    printf("\e[0;33m");
    break;
  case 39:
    printf("\e[1;35m");
    break;
  default:
    printf("\e[0;m");
    break;
  }
}


x86 assembly (clang, -O0):
<color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffe2,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x9,%eax
ja     11ee <color+0xde>
mov    -0x10(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <color+0xea>
lea    0xed4(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <color+0xea>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <color+0xea>
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <color+0xea>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <color+0xea>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <color+0xea>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <color+0xea>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <color+0xea>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <color+0xea>
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
jmp    11fa <color+0xea>
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<color>:
add    $0xffffffe2,%edi
cmp    $0x9,%edi
ja     112e <color+0x1e>
movslq %edi,%rax
lea    0xf36(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1030 <printf@plt>
lea    0xf1b(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"\1B[0;30m\00"
@.str.1 = [8 x i8] c"\1B[0;31m\00"
@.str.2 = [8 x i8] c"\1B[0;32m\00"
@.str.3 = [8 x i8] c"\1B[1;33m\00"
@.str.4 = [8 x i8] c"\1B[1;34m\00"
@.str.5 = [8 x i8] c"\1B[1;31m\00"
@.str.6 = [8 x i8] c"\1B[0;36m\00"
@.str.7 = [8 x i8] c"\1B[1;37m\00"
@.str.8 = [8 x i8] c"\1B[0;33m\00"
@.str.9 = [8 x i8] c"\1B[1;35m\00"
@.str.10 = [6 x i8] c"\1B[0;m\00"
define void @color(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %24 [
i32 30, label %4
i32 31, label %6
i32 32, label %8
i32 33, label %10
i32 34, label %12
i32 35, label %14
i32 36, label %16
i32 37, label %18
i32 38, label %20
i32 39, label %22
]
4: ; preds = %1
%5 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %26
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %26
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %26
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %26
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %26
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %26
16: ; preds = %1
%17 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %26
18: ; preds = %1
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %26
20: ; preds = %1
%21 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %26
22: ; preds = %1
%23 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
br label %26
24: ; preds = %1
%25 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %26
26: ; preds = %24, %22, %20, %18, %16, %14, %12, %10, %8, %6, %4
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"\1B[0;30m\00"
@.str.1 = [8 x i8] c"\1B[0;31m\00"
@.str.2 = [8 x i8] c"\1B[0;32m\00"
@.str.3 = [8 x i8] c"\1B[1;33m\00"
@.str.4 = [8 x i8] c"\1B[1;34m\00"
@.str.5 = [8 x i8] c"\1B[1;31m\00"
@.str.6 = [8 x i8] c"\1B[0;36m\00"
@.str.7 = [8 x i8] c"\1B[1;37m\00"
@.str.8 = [8 x i8] c"\1B[0;33m\00"
@.str.9 = [8 x i8] c"\1B[1;35m\00"
@.str.10 = [6 x i8] c"\1B[0;m\00"
@reltable.color = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.color to i64)) to i32)]
define void @color(i32 %0) {
%2 = add i32 %0, -30
%3 = icmp ult i32 %2, 10
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.color to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), %1 ]
%10 = tail call i32 @printf(i8* dereferenceable(1) %9)
ret void
}