const char *get_patch_name(int pnum) {
  switch (pnum) {
  case 0:
    return "Acoustic Grand Piano";
  case 5:
    return "Electric Piano 2";
  case 6:
    return "Harpsichord";
  case 10:
    return "Music Box";
  case 46:
    return "Harp";
  case 56:
    return "Trumpet";
  case 65:
    return "Alto Sax";
  case 70:
    return "Bassoon";
  case 12:
    return "Marimba";
  case 42:
    return "Cello";
  default:
    return "Unknown";
  }
}


x86 assembly (clang, -O0):
<get_patch_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x46,%rax
ja     11cc <get_patch_name+0xcc>
mov    -0x18(%rbp),%rax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xfe9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <get_patch_name+0xd7>
lea    0xfee(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <get_patch_name+0xd7>
lea    0xfef(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <get_patch_name+0xd7>
lea    0xfeb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <get_patch_name+0xd7>
lea    0xfe5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <get_patch_name+0xd7>
lea    0xfda(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <get_patch_name+0xd7>
lea    0xfd2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <get_patch_name+0xd7>
lea    0xfcb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <get_patch_name+0xd7>
lea    0xfc3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <get_patch_name+0xd7>
lea    0xfbb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <get_patch_name+0xd7>
lea    0xfb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_patch_name>:
cmp    $0x46,%edi
ja     1126 <get_patch_name+0x26>
lea    0x1010(%rip),%rax
mov    %edi,%ecx
lea    0xeeb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0x100c(%rip),%rax
ret
lea    0x1057(%rip),%rax
ret
lea    0x100d(%rip),%rax
ret
lea    0x1011(%rip),%rax
ret
lea    0x1031(%rip),%rax
ret
lea    0x1031(%rip),%rax
ret
lea    0x1003(%rip),%rax
ret
lea    0x1000(%rip),%rax
ret
lea    0x1000(%rip),%rax
ret
lea    0x1001(%rip),%rax
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Acoustic Grand Piano\00"
@.str.1 = [17 x i8] c"Electric Piano 2\00"
@.str.2 = [12 x i8] c"Harpsichord\00"
@.str.3 = [10 x i8] c"Music Box\00"
@.str.4 = [5 x i8] c"Harp\00"
@.str.5 = [8 x i8] c"Trumpet\00"
@.str.6 = [9 x i8] c"Alto Sax\00"
@.str.7 = [8 x i8] c"Bassoon\00"
@.str.8 = [8 x i8] c"Marimba\00"
@.str.9 = [6 x i8] c"Cello\00"
@.str.10 = [8 x i8] c"Unknown\00"
define i8* @get_patch_name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %15 [
i32 0, label %5
i32 5, label %6
i32 6, label %7
i32 10, label %8
i32 46, label %9
i32 56, label %10
i32 65, label %11
i32 70, label %12
i32 12, label %13
i32 42, label %14
]
5: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %2
br label %16
6: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %16
7: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %16
8: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %16
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %16
10: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %16
11: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %16
12: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %16
13: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %16
14: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %16
15: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %16
16: ; preds = %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%17 = load i8*, i8** %2
ret i8* %17
}

LLVM IR (-O2):
@.str = [21 x i8] c"Acoustic Grand Piano\00"
@.str.1 = [17 x i8] c"Electric Piano 2\00"
@.str.2 = [12 x i8] c"Harpsichord\00"
@.str.3 = [10 x i8] c"Music Box\00"
@.str.4 = [5 x i8] c"Harp\00"
@.str.5 = [8 x i8] c"Trumpet\00"
@.str.6 = [9 x i8] c"Alto Sax\00"
@.str.7 = [8 x i8] c"Bassoon\00"
@.str.8 = [8 x i8] c"Marimba\00"
@.str.9 = [6 x i8] c"Cello\00"
@.str.10 = [8 x i8] c"Unknown\00"
define i8* @get_patch_name(i32 %0) {
switch i32 %0, label %11 [
i32 0, label %12
i32 5, label %2
i32 6, label %3
i32 10, label %4
i32 46, label %5
i32 56, label %6
i32 65, label %7
i32 70, label %8
i32 12, label %9
i32 42, label %10
]
2: ; preds = %1
br label %12
3: ; preds = %1
br label %12
4: ; preds = %1
br label %12
5: ; preds = %1
br label %12
6: ; preds = %1
br label %12
7: ; preds = %1
br label %12
8: ; preds = %1
br label %12
9: ; preds = %1
br label %12
10: ; preds = %1
br label %12
11: ; preds = %1
br label %12
12: ; preds = %1, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%13 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), %10 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([10 x i8], [10 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 ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %13
}