char *commandName(unsigned char command) {
  switch (command) {
  case 0x1:
    return "lock";
  case 0x2:
    return "unlock";
  case 0xb:
    return "trunk";
  case 0xa:
    return "panic";
  default:
    return "unknown";
  }
}


x86 assembly (clang, -O0):
<commandName>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xa,%eax
ja     1174 <commandName+0x74>
mov    -0x18(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <commandName+0x7f>
lea    0xee1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <commandName+0x7f>
lea    0xed8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <commandName+0x7f>
lea    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117f <commandName+0x7f>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<commandName>:
add    $0xff,%dil
cmp    $0xa,%dil
ja     112d <commandName+0x2d>
lea    0xf1d(%rip),%rax
movzbl %dil,%ecx
lea    0xee4(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf00(%rip),%rax
ret
lea    0xf0b(%rip),%rax
ret
lea    0xefd(%rip),%rax
ret
lea    0xeef(%rip),%rax
ret

LLVM IR (-O0):
@.str = [5 x i8] c"lock\00"
@.str.1 = [7 x i8] c"unlock\00"
@.str.2 = [6 x i8] c"trunk\00"
@.str.3 = [6 x i8] c"panic\00"
@.str.4 = [8 x i8] c"unknown\00"
define i8* @commandName(i8 zeroext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
switch i32 %5, label %10 [
i32 1, label %6
i32 2, label %7
i32 11, label %8
i32 10, label %9
]
6: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
br label %11
7: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 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 ([8 x i8], [8 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 = [5 x i8] c"lock\00"
@.str.1 = [7 x i8] c"unlock\00"
@.str.2 = [6 x i8] c"trunk\00"
@.str.3 = [6 x i8] c"panic\00"
@.str.4 = [8 x i8] c"unknown\00"
define i8* @commandName(i8 zeroext %0) {
switch i8 %0, label %5 [
i8 1, label %6
i8 2, label %2
i8 11, label %3
i8 10, label %4
]
2: ; preds = %1
br label %6
3: ; preds = %1
br label %6
4: ; preds = %1
br label %6
5: ; preds = %1
br label %6
6: ; preds = %1, %5, %4, %3, %2
%7 = phi i8* [ getelementptr inbounds ([8 x i8], [8 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 ([7 x i8], [7 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* %7
}