const char *lvlcol(int lvl) {
  return lvl == 7   ? "\033[30;01m"
         : lvl == 9 ? "\033[34;01m"
         : lvl == 8 ? "\033[07;30;01m"
         : lvl == 6 ? "\033[37;01m"
         : lvl == 5 ? "\033[32;01m"
         : lvl == 4 ? "\033[33;01m"
         : lvl == 2 ? "\033[07;31;01m"
         : lvl == 3 ? "\033[31;01m"
                    : "\033[07;37;01m";
}


x86 assembly (clang, -O0):
<lvlcol>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x7,-0x4(%rbp)
jne    1121 <lvlcol+0x21>
lea    0xee8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1209 <lvlcol+0x109>
cmpl   $0x9,-0x4(%rbp)
jne    113b <lvlcol+0x3b>
lea    0xed7(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1201 <lvlcol+0x101>
cmpl   $0x8,-0x4(%rbp)
jne    1155 <lvlcol+0x55>
lea    0xec6(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11f9 <lvlcol+0xf9>
cmpl   $0x6,-0x4(%rbp)
jne    116f <lvlcol+0x6f>
lea    0xeb8(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11f1 <lvlcol+0xf1>
cmpl   $0x5,-0x4(%rbp)
jne    1189 <lvlcol+0x89>
lea    0xea7(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11e9 <lvlcol+0xe9>
cmpl   $0x4,-0x4(%rbp)
jne    11a3 <lvlcol+0xa3>
lea    0xe96(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    11e1 <lvlcol+0xe1>
cmpl   $0x2,-0x4(%rbp)
jne    11bd <lvlcol+0xbd>
lea    0xe85(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    11d9 <lvlcol+0xd9>
mov    -0x4(%rbp),%edx
lea    0xe87(%rip),%rax
lea    0xe77(%rip),%rcx
cmp    $0x3,%edx
cmove  %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<lvlcol>:
lea    -0x2(%rdi),%eax
cmp    $0x8,%eax
jae    1112 <lvlcol+0x12>
mov    $0xfd,%ecx
bt     %eax,%ecx
jb     1128 <lvlcol+0x28>
cmp    $0x3,%edi
lea    0xf29(%rip),%rcx
lea    0xf2b(%rip),%rax
cmove  %rcx,%rax
ret
cltq
lea    0xf2b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"\1B[30;01m\00"
@.str.1 = [9 x i8] c"\1B[34;01m\00"
@.str.2 = [12 x i8] c"\1B[07;30;01m\00"
@.str.3 = [9 x i8] c"\1B[37;01m\00"
@.str.4 = [9 x i8] c"\1B[32;01m\00"
@.str.5 = [9 x i8] c"\1B[33;01m\00"
@.str.6 = [12 x i8] c"\1B[07;31;01m\00"
@.str.7 = [9 x i8] c"\1B[31;01m\00"
@.str.8 = [12 x i8] c"\1B[07;37;01m\00"
@reltable.lvlcol = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlcol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlcol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlcol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlcol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlcol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlcol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlcol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlcol to i64)) to i32)]
define i8* @lvlcol(i32 %0) {
%2 = add i32 %0, -2
%3 = icmp ult i32 %2, 8
br i1 %3, label %7, label %4
4: ; preds = %7, %1
%5 = icmp eq i32 %0, 3
%6 = select i1 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0)
br label %16
7: ; preds = %1
%8 = trunc i32 %2 to i8
%9 = lshr i8 -3, %8
%10 = and i8 %9, 1
%11 = icmp eq i8 %10, 0
br i1 %11, label %4, label %12
12: ; preds = %7
%13 = sext i32 %2 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.lvlcol to i8*), i64 %14)
br label %16
16: ; preds = %12, %4
%17 = phi i8* [ %6, %4 ], [ %15, %12 ]
ret i8* %17
}