const char *v2_func_name(int func) {
  switch (func) {
  case 1:
    return "ANNOUNCE";
  case 2:
    return "REGISTER";
  case 3:
    return "REG_CONF";
  case 4:
    return "FILESEG";
  case 5:
    return "DONE";
  case 6:
    return "STATUS";
  case 7:
    return "DONE_CONF";
  case 99:
    return "ABORT";
  default:
    return "UNKNOWN";
  }
}


x86 assembly (clang, -O0):
<v2_func_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     1192 <v2_func_name+0x92>
jmp    111b <v2_func_name+0x1b>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11a2 <v2_func_name+0xa2>
jmp    112c <v2_func_name+0x2c>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
je     11b2 <v2_func_name+0xb2>
jmp    113d <v2_func_name+0x3d>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
je     11c2 <v2_func_name+0xc2>
jmp    114e <v2_func_name+0x4e>
mov    -0x10(%rbp),%eax
sub    $0x5,%eax
je     11d2 <v2_func_name+0xd2>
jmp    115f <v2_func_name+0x5f>
mov    -0x10(%rbp),%eax
sub    $0x6,%eax
je     11e2 <v2_func_name+0xe2>
jmp    1170 <v2_func_name+0x70>
mov    -0x10(%rbp),%eax
sub    $0x7,%eax
je     11f2 <v2_func_name+0xf2>
jmp    1181 <v2_func_name+0x81>
mov    -0x10(%rbp),%eax
sub    $0x63,%eax
je     1202 <v2_func_name+0x102>
jmp    1212 <v2_func_name+0x112>
lea    0xe67(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121d <v2_func_name+0x11d>
lea    0xe60(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121d <v2_func_name+0x11d>
lea    0xe59(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121d <v2_func_name+0x11d>
lea    0xe52(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121d <v2_func_name+0x11d>
lea    0xe4a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121d <v2_func_name+0x11d>
lea    0xe3f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121d <v2_func_name+0x11d>
lea    0xe36(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121d <v2_func_name+0x11d>
lea    0xe30(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    121d <v2_func_name+0x11d>
lea    0xe26(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<v2_func_name>:
lea    -0x1(%rdi),%ecx
cmp    $0x6,%ecx
ja     1127 <v2_func_name+0x27>
lea    0xf0d(%rip),%rax
lea    0xeea(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xeff(%rip),%rax
ret
cmp    $0x63,%edi
jne    115c <v2_func_name+0x5c>
lea    0xf22(%rip),%rax
ret
lea    0xef3(%rip),%rax
ret
lea    0xef4(%rip),%rax
ret
lea    0xef4(%rip),%rax
ret
lea    0xef1(%rip),%rax
ret
lea    0xef0(%rip),%rax
ret
lea    0xef8(%rip),%rax
ret

LLVM IR (-O0):
@.str = [9 x i8] c"ANNOUNCE\00"
@.str.1 = [9 x i8] c"REGISTER\00"
@.str.2 = [9 x i8] c"REG_CONF\00"
@.str.3 = [8 x i8] c"FILESEG\00"
@.str.4 = [5 x i8] c"DONE\00"
@.str.5 = [7 x i8] c"STATUS\00"
@.str.6 = [10 x i8] c"DONE_CONF\00"
@.str.7 = [6 x i8] c"ABORT\00"
@.str.8 = [8 x i8] c"UNKNOWN\00"
define i8* @v2_func_name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %13 [
i32 1, label %5
i32 2, label %6
i32 3, label %7
i32 4, label %8
i32 5, label %9
i32 6, label %10
i32 7, label %11
i32 99, label %12
]
5: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %2
br label %14
6: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %14
7: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %14
8: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %14
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %14
10: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %14
11: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %14
12: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %14
13: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %14
14: ; preds = %13, %12, %11, %10, %9, %8, %7, %6, %5
%15 = load i8*, i8** %2
ret i8* %15
}

LLVM IR (-O2):
@.str = [9 x i8] c"ANNOUNCE\00"
@.str.1 = [9 x i8] c"REGISTER\00"
@.str.2 = [9 x i8] c"REG_CONF\00"
@.str.3 = [8 x i8] c"FILESEG\00"
@.str.4 = [5 x i8] c"DONE\00"
@.str.5 = [7 x i8] c"STATUS\00"
@.str.6 = [10 x i8] c"DONE_CONF\00"
@.str.7 = [6 x i8] c"ABORT\00"
@.str.8 = [8 x i8] c"UNKNOWN\00"
define i8* @v2_func_name(i32 %0) {
switch i32 %0, label %9 [
i32 1, label %10
i32 2, label %2
i32 3, label %3
i32 4, label %4
i32 5, label %5
i32 6, label %6
i32 7, label %7
i32 99, label %8
]
2: ; preds = %1
br label %10
3: ; preds = %1
br label %10
4: ; preds = %1
br label %10
5: ; preds = %1
br label %10
6: ; preds = %1
br label %10
7: ; preds = %1
br label %10
8: ; preds = %1
br label %10
9: ; preds = %1
br label %10
10: ; preds = %1, %9, %8, %7, %6, %5, %4, %3, %2
%11 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([7 x i8], [7 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 ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %11
}