char *severity_str(char c) {
  switch (c) {
  case 'I':
    return "informational";
  case 'W':
    return "warning";
  case 'E':
    return "error";
  case 'F':
    return "fatal";
  }
  return "?";
}


x86 assembly (clang, -O0):
<severity_str>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffbb,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x12,%eax
ja     1174 <severity_str+0x74>
mov    -0x18(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf11(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <severity_str+0x7f>
lea    0xf0f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <severity_str+0x7f>
lea    0xf07(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <severity_str+0x7f>
lea    0xefd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <severity_str+0x7f>
lea    0xef3(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<severity_str>:
add    $0xffffffbb,%edi
cmp    $0x12,%edi
ja     112f <severity_str+0x2f>
lea    0xf3d(%rip),%rax
lea    0xeea(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xf3c(%rip),%rax
ret
lea    0xf3a(%rip),%rax
ret
lea    0xf38(%rip),%rax
ret
lea    0xf1c(%rip),%rax
ret

LLVM IR (-O0):
@.str = [14 x i8] c"informational\00"
@.str.1 = [8 x i8] c"warning\00"
@.str.2 = [6 x i8] c"error\00"
@.str.3 = [6 x i8] c"fatal\00"
@.str.4 = [2 x i8] c"?\00"
define i8* @severity_str(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 %10 [
i32 73, label %6
i32 87, label %7
i32 69, label %8
i32 70, label %9
]
6: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
br label %11
7: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %11
8: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %11
9: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %11
10: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %11
11: ; preds = %10, %9, %8, %7, %6
%12 = load i8*, i8** %2
ret i8* %12
}

LLVM IR (-O2):
@.str = [14 x i8] c"informational\00"
@.str.1 = [8 x i8] c"warning\00"
@.str.2 = [6 x i8] c"error\00"
@.str.3 = [6 x i8] c"fatal\00"
@.str.4 = [2 x i8] c"?\00"
define i8* @severity_str(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %6 [
i32 73, label %7
i32 87, label %3
i32 69, label %4
i32 70, label %5
]
3: ; preds = %1
br label %7
4: ; preds = %1
br label %7
5: ; preds = %1
br label %7
6: ; preds = %1
br label %7
7: ; preds = %1, %6, %5, %4, %3
%8 = phi i8* [ getelementptr inbounds ([2 x i8], [2 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 ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %8
}