const char *lvlnam(int lvl) {
  return lvl == 7   ? "DBG"
         : lvl == 9 ? "TRC"
         : lvl == 8 ? "VIV"
         : lvl == 6 ? "INF"
         : lvl == 5 ? "NOT"
         : lvl == 4 ? "WRN"
         : lvl == 2 ? "CRT"
         : lvl == 3 ? "ERR"
                    : "???";
}


x86 assembly (clang, -O0):
<lvlnam>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x7,-0x4(%rbp)
jne    1121 <lvlnam+0x21>
lea    0xee8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1209 <lvlnam+0x109>
cmpl   $0x9,-0x4(%rbp)
jne    113b <lvlnam+0x3b>
lea    0xed2(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1201 <lvlnam+0x101>
cmpl   $0x8,-0x4(%rbp)
jne    1155 <lvlnam+0x55>
lea    0xebc(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11f9 <lvlnam+0xf9>
cmpl   $0x6,-0x4(%rbp)
jne    116f <lvlnam+0x6f>
lea    0xea6(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11f1 <lvlnam+0xf1>
cmpl   $0x5,-0x4(%rbp)
jne    1189 <lvlnam+0x89>
lea    0xe90(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11e9 <lvlnam+0xe9>
cmpl   $0x4,-0x4(%rbp)
jne    11a3 <lvlnam+0xa3>
lea    0xe7a(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    11e1 <lvlnam+0xe1>
cmpl   $0x2,-0x4(%rbp)
jne    11bd <lvlnam+0xbd>
lea    0xe64(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    11d9 <lvlnam+0xd9>
mov    -0x4(%rbp),%edx
lea    0xe59(%rip),%rax
lea    0xe4e(%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):
<lvlnam>:
lea    -0x2(%rdi),%eax
cmp    $0x8,%eax
jae    1112 <lvlnam+0x12>
mov    $0xfd,%ecx
bt     %eax,%ecx
jb     1128 <lvlnam+0x28>
cmp    $0x3,%edi
lea    0xf00(%rip),%rcx
lea    0xefd(%rip),%rax
cmove  %rcx,%rax
ret
cltq
lea    0xef3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"DBG\00"
@.str.1 = [4 x i8] c"TRC\00"
@.str.2 = [4 x i8] c"VIV\00"
@.str.3 = [4 x i8] c"INF\00"
@.str.4 = [4 x i8] c"NOT\00"
@.str.5 = [4 x i8] c"WRN\00"
@.str.6 = [4 x i8] c"CRT\00"
@.str.7 = [4 x i8] c"ERR\00"
@.str.8 = [4 x i8] c"???\00"
define i8* @lvlnam(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 ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0)
br label %35
35: ; preds = %30, %29
%36 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), %29 ], [ %34, %30 ]
br label %37
37: ; preds = %35, %25
%38 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), %25 ], [ %36, %35 ]
br label %39
39: ; preds = %37, %21
%40 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %21 ], [ %38, %37 ]
br label %41
41: ; preds = %39, %17
%42 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %17 ], [ %40, %39 ]
br label %43
43: ; preds = %41, %13
%44 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %13 ], [ %42, %41 ]
br label %45
45: ; preds = %43, %9
%46 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %9 ], [ %44, %43 ]
br label %47
47: ; preds = %45, %5
%48 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %5 ], [ %46, %45 ]
ret i8* %48
}

LLVM IR (-O2):
@.str = [4 x i8] c"DBG\00"
@.str.1 = [4 x i8] c"TRC\00"
@.str.2 = [4 x i8] c"VIV\00"
@.str.3 = [4 x i8] c"INF\00"
@.str.4 = [4 x i8] c"NOT\00"
@.str.5 = [4 x i8] c"WRN\00"
@.str.6 = [4 x i8] c"CRT\00"
@.str.7 = [4 x i8] c"ERR\00"
@.str.8 = [4 x i8] c"???\00"
@reltable.lvlnam = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlnam to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlnam to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlnam to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlnam to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlnam to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlnam to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlnam to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.lvlnam to i64)) to i32)]
define i8* @lvlnam(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 ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 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.lvlnam to i8*), i64 %14)
br label %16
16: ; preds = %12, %4
%17 = phi i8* [ %6, %4 ], [ %15, %12 ]
ret i8* %17
}