const char *txt_getNameForType(unsigned int t) {
  switch (t) {
  case 0x0004:
    return "ASCII";
  case 0x0008:
    return "UTF-8";
  case ((0x0010) | (0x0001)):
    return "UTF-16 (LE)";
  case ((0x0010) | (0x0002)):
    return "UTF-16 (BE)";
  case ((0x0020) | (0x0001)):
    return "UTF-32 (LE)";
  case ((0x0020) | (0x0002)):
    return "UTF-32 (BE)";
  default:
    return "";
  }
}


x86 assembly (clang, -O0):
<txt_getNameForType>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xfffffffc,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x1e,%eax
ja     1190 <txt_getNameForType+0x90>
mov    -0x18(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf45(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119b <txt_getNameForType+0x9b>
lea    0xf3b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119b <txt_getNameForType+0x9b>
lea    0xf31(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119b <txt_getNameForType+0x9b>
lea    0xf2d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119b <txt_getNameForType+0x9b>
lea    0xf29(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119b <txt_getNameForType+0x9b>
lea    0xf25(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119b <txt_getNameForType+0x9b>
lea    0xf20(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<txt_getNameForType>:
add    $0xfffffffc,%edi
cmp    $0x1e,%edi
ja     1127 <txt_getNameForType+0x27>
lea    0xf6d(%rip),%rax
lea    0xeea(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xf5c(%rip),%rax
ret
lea    0xf89(%rip),%rax
ret
lea    0xf52(%rip),%rax
ret
lea    0xf56(%rip),%rax
ret
lea    0xf5a(%rip),%rax
ret
lea    0xf5e(%rip),%rax
ret

LLVM IR (-O0):
@.str = [6 x i8] c"ASCII\00"
@.str.1 = [6 x i8] c"UTF-8\00"
@.str.2 = [12 x i8] c"UTF-16 (LE)\00"
@.str.3 = [12 x i8] c"UTF-16 (BE)\00"
@.str.4 = [12 x i8] c"UTF-32 (LE)\00"
@.str.5 = [12 x i8] c"UTF-32 (BE)\00"
@.str.6 = [1 x i8] zeroinitializer
define i8* @txt_getNameForType(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %11 [
i32 4, label %5
i32 8, label %6
i32 17, label %7
i32 18, label %8
i32 33, label %9
i32 34, label %10
]
5: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
br label %12
6: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %12
7: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %12
8: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %12
9: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %12
10: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %12
11: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %12
12: ; preds = %11, %10, %9, %8, %7, %6, %5
%13 = load i8*, i8** %2
ret i8* %13
}

LLVM IR (-O2):
@.str = [6 x i8] c"ASCII\00"
@.str.1 = [6 x i8] c"UTF-8\00"
@.str.2 = [12 x i8] c"UTF-16 (LE)\00"
@.str.3 = [12 x i8] c"UTF-16 (BE)\00"
@.str.4 = [12 x i8] c"UTF-32 (LE)\00"
@.str.5 = [12 x i8] c"UTF-32 (BE)\00"
@.str.6 = [1 x i8] zeroinitializer
define i8* @txt_getNameForType(i32 %0) {
switch i32 %0, label %7 [
i32 4, label %8
i32 8, label %2
i32 17, label %3
i32 18, label %4
i32 33, label %5
i32 34, label %6
]
2: ; preds = %1
br label %8
3: ; preds = %1
br label %8
4: ; preds = %1
br label %8
5: ; preds = %1
br label %8
6: ; preds = %1
br label %8
7: ; preds = %1
br label %8
8: ; preds = %1, %7, %6, %5, %4, %3, %2
%9 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %9
}