const char *size_name(int size) {
  switch (size) {
  case 1:
    return "byte";
  case 2:
    return "word";
  case 4:
    return "dword";
  case 8:
    return "qword";
  case 10:
    return "tword";
  case 16:
    return "oword";
  case 32:
    return "yword";
  default:
    return "???";
  }
}


x86 assembly (clang, -O0):
<size_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x1f,%eax
ja     11a0 <size_name+0xa0>
mov    -0x18(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf49(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <size_name+0xab>
lea    0xf3f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <size_name+0xab>
lea    0xf2e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <size_name+0xab>
lea    0xf24(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <size_name+0xab>
lea    0xf1a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <size_name+0xab>
lea    0xf10(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <size_name+0xab>
lea    0xf06(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <size_name+0xab>
lea    0xefc(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<size_name>:
add    $0xffffffff,%edi
cmp    $0x1f,%edi
ja     1127 <size_name+0x27>
lea    0xf71(%rip),%rax
lea    0xeea(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xf60(%rip),%rax
ret
lea    0xf75(%rip),%rax
ret
lea    0xf4f(%rip),%rax
ret
lea    0xf4d(%rip),%rax
ret
lea    0xf51(%rip),%rax
ret
lea    0xf4f(%rip),%rax
ret
lea    0xf3b(%rip),%rax
ret

LLVM IR (-O0):
@.str = [5 x i8] c"byte\00"
@.str.1 = [5 x i8] c"word\00"
@.str.2 = [6 x i8] c"dword\00"
@.str.3 = [6 x i8] c"qword\00"
@.str.4 = [6 x i8] c"tword\00"
@.str.5 = [6 x i8] c"oword\00"
@.str.6 = [6 x i8] c"yword\00"
@.str.7 = [4 x i8] c"???\00"
define i8* @size_name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %12 [
i32 1, label %5
i32 2, label %6
i32 4, label %7
i32 8, label %8
i32 10, label %9
i32 16, label %10
i32 32, label %11
]
5: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
br label %13
6: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %13
7: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %13
8: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %13
9: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %13
10: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %13
11: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %13
12: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %13
13: ; preds = %12, %11, %10, %9, %8, %7, %6, %5
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@.str = [5 x i8] c"byte\00"
@.str.1 = [5 x i8] c"word\00"
@.str.2 = [6 x i8] c"dword\00"
@.str.3 = [6 x i8] c"qword\00"
@.str.4 = [6 x i8] c"tword\00"
@.str.5 = [6 x i8] c"oword\00"
@.str.6 = [6 x i8] c"yword\00"
@.str.7 = [4 x i8] c"???\00"
define i8* @size_name(i32 %0) {
switch i32 %0, label %8 [
i32 1, label %9
i32 2, label %2
i32 4, label %3
i32 8, label %4
i32 10, label %5
i32 16, label %6
i32 32, label %7
]
2: ; preds = %1
br label %9
3: ; preds = %1
br label %9
4: ; preds = %1
br label %9
5: ; preds = %1
br label %9
6: ; preds = %1
br label %9
7: ; preds = %1
br label %9
8: ; preds = %1
br label %9
9: ; preds = %1, %8, %7, %6, %5, %4, %3, %2
%10 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %10
}