#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
void printColored(int col, char c) {
  switch (col) {
  case 1:
    printf("\x1b[31m"
           "%c");
    break;
  case 2:
    printf("\x1b[32m"
           "%c");
    break;
  case 3:
    printf("\x1b[33m"
           "%c");
    break;
  case 4:
    printf("\x1b[34m"
           "%c");
    break;
  case 5:
    printf("\x1b[35m"
           "%c");
    break;
  case 6:
    printf("\x1b[36m"
           "%c");
    break;
  default:
    printf("%c");
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<printColored>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     11c0 <printColored+0xa0>
mov    -0x10(%rbp),%rax
lea    0xeaf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
jmp    11cc <printColored+0xac>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
jmp    11cc <printColored+0xac>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    11cc <printColored+0xac>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
jmp    11cc <printColored+0xac>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    11cc <printColored+0xac>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
jmp    11cc <printColored+0xac>
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printColored>:
push   %rax
add    $0xffffffff,%edi
cmp    $0x5,%edi
ja     113c <printColored+0x1c>
movslq %edi,%rax
lea    0xefd(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1143 <printColored+0x23>
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fflush@plt>

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

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