const char *usiopttypestr(int type) {
  const char *list[] = {"check",  "spin",   "combo",
                        "button", "string", "filename"};
  const int n = sizeof(list) / sizeof(list[0]);
  if (type < 0 || type >= n)
    return "-";
  return list[type];
}


x86 assembly (clang, -O0):
<usiopttypestr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0xc(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
lea    0xece(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xec9(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xebe(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xeb6(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x6,-0x44(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1188 <usiopttypestr+0x78>
cmpl   $0x6,-0xc(%rbp)
jl     1198 <usiopttypestr+0x88>
lea    0xe99(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <usiopttypestr+0x95>
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usiopttypestr>:
lea    0xef9(%rip),%rax
mov    %rax,-0x38(%rsp)
lea    0xef3(%rip),%rax
mov    %rax,-0x30(%rsp)
lea    0xeec(%rip),%rax
mov    %rax,-0x28(%rsp)
lea    0xee6(%rip),%rax
mov    %rax,-0x20(%rsp)
lea    0xee1(%rip),%rax
mov    %rax,-0x18(%rsp)
lea    0xedc(%rip),%rax
mov    %rax,-0x10(%rsp)
cmp    $0x5,%edi
jbe    1155 <usiopttypestr+0x55>
lea    0xed4(%rip),%rax
ret
mov    %edi,%eax
mov    -0x38(%rsp,%rax,8),%rax
ret

LLVM IR (-O0):
@.str = [6 x i8] c"check\00"
@.str.1 = [5 x i8] c"spin\00"
@.str.2 = [6 x i8] c"combo\00"
@.str.3 = [7 x i8] c"button\00"
@.str.4 = [7 x i8] c"string\00"
@.str.5 = [9 x i8] c"filename\00"
@.str.6 = [2 x i8] c"-\00"
define i8* @usiopttypestr(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [6 x i8*]
%5 = alloca i32
store i32 %0, i32* %3
%6 = bitcast [6 x i8*]* %4 to i8*
%7 = bitcast i8* %6 to [6 x i8*]*
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i32 0, i32 5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i8** %13
store i32 6, i32* %5
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %1
%17 = load i32, i32* %3
%18 = icmp sge i32 %17, 6
br i1 %18, label %19, label %20
19: ; preds = %16, %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %25
20: ; preds = %16
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 %22
%24 = load i8*, i8** %23
store i8* %24, i8** %2
br label %25
25: ; preds = %20, %19
%26 = load i8*, i8** %2
ret i8* %26
}

LLVM IR (-O2):
@.str = [6 x i8] c"check\00"
@.str.1 = [5 x i8] c"spin\00"
@.str.2 = [6 x i8] c"combo\00"
@.str.3 = [7 x i8] c"button\00"
@.str.4 = [7 x i8] c"string\00"
@.str.5 = [9 x i8] c"filename\00"
@.str.6 = [2 x i8] c"-\00"
define i8* @usiopttypestr(i32 %0) {
%2 = alloca [6 x i8*]
%3 = bitcast [6 x i8*]* %2 to i8*
%4 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %9
%10 = icmp ugt i32 %0, 5
br i1 %10, label %15, label %11
11: ; preds = %1
%12 = zext i32 %0 to i64
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 %12
%14 = load i8*, i8** %13
br label %15
15: ; preds = %1, %11
%16 = phi i8* [ %14, %11 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), %1 ]
ret i8* %16
}