const char *stun_msg2str(int msg) {
  switch (msg) {
  case 0x0001:
    return "Binding Request";
  case 0x0101:
    return "Binding Response";
  case 0x0111:
    return "Binding Error Response";
  case 0x0002:
    return "Shared Secret Request";
  case 0x0102:
    return "Shared Secret Response";
  case 0x0112:
    return "Shared Secret Error Response";
  }
  return "Non-RFC3489 Message";
}


x86 assembly (clang, -O0):
<stun_msg2str>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     1178 <stun_msg2str+0x78>
jmp    111b <stun_msg2str+0x1b>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11a8 <stun_msg2str+0xa8>
jmp    112c <stun_msg2str+0x2c>
mov    -0x10(%rbp),%eax
sub    $0x101,%eax
je     1188 <stun_msg2str+0x88>
jmp    113f <stun_msg2str+0x3f>
mov    -0x10(%rbp),%eax
sub    $0x102,%eax
je     11b8 <stun_msg2str+0xb8>
jmp    1152 <stun_msg2str+0x52>
mov    -0x10(%rbp),%eax
sub    $0x111,%eax
je     1198 <stun_msg2str+0x98>
jmp    1165 <stun_msg2str+0x65>
mov    -0x10(%rbp),%eax
sub    $0x112,%eax
je     11c8 <stun_msg2str+0xc8>
jmp    11d8 <stun_msg2str+0xd8>
lea    0xe81(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <stun_msg2str+0xe3>
lea    0xe81(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <stun_msg2str+0xe3>
lea    0xe82(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <stun_msg2str+0xe3>
lea    0xe89(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <stun_msg2str+0xe3>
lea    0xe8f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <stun_msg2str+0xe3>
lea    0xe96(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <stun_msg2str+0xe3>
lea    0xea3(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<stun_msg2str>:
lea    -0x101(%rdi),%eax
cmp    $0x11,%eax
ja     1123 <stun_msg2str+0x23>
lea    0xeee(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf36(%rip),%rax
ret
cmp    $0x1,%edi
je     1155 <stun_msg2str+0x55>
cmp    $0x2,%edi
jne    1135 <stun_msg2str+0x35>
lea    0xf4c(%rip),%rax
ret
lea    0xf8e(%rip),%rax
ret
lea    0xf52(%rip),%rax
ret
lea    0xf1d(%rip),%rax
ret
lea    0xf59(%rip),%rax
ret
lea    0xeec(%rip),%rax
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Binding Request\00"
@.str.1 = [17 x i8] c"Binding Response\00"
@.str.2 = [23 x i8] c"Binding Error Response\00"
@.str.3 = [22 x i8] c"Shared Secret Request\00"
@.str.4 = [23 x i8] c"Shared Secret Response\00"
@.str.5 = [29 x i8] c"Shared Secret Error Response\00"
@.str.6 = [20 x i8] c"Non-RFC3489 Message\00"
define i8* @stun_msg2str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %11 [
i32 1, label %5
i32 257, label %6
i32 273, label %7
i32 2, label %8
i32 258, label %9
i32 274, label %10
]
5: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %2
br label %12
6: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %12
7: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %12
8: ; preds = %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %12
9: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %12
10: ; preds = %1
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %12
11: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %12
12: ; preds = %11, %10, %9, %8, %7, %6, %5
%13 = load i8*, i8** %2
ret i8* %13
}

LLVM IR (-O2):
@.str = [16 x i8] c"Binding Request\00"
@.str.1 = [17 x i8] c"Binding Response\00"
@.str.2 = [23 x i8] c"Binding Error Response\00"
@.str.3 = [22 x i8] c"Shared Secret Request\00"
@.str.4 = [23 x i8] c"Shared Secret Response\00"
@.str.5 = [29 x i8] c"Shared Secret Error Response\00"
@.str.6 = [20 x i8] c"Non-RFC3489 Message\00"
define i8* @stun_msg2str(i32 %0) {
switch i32 %0, label %7 [
i32 1, label %8
i32 257, label %2
i32 273, label %3
i32 2, label %4
i32 258, label %5
i32 274, label %6
]
2: ; preds = %1
br label %8
3: ; preds = %1
br label %8
4: ; preds = %1
br label %8
5: ; preds = %1
br label %8
6: ; preds = %1
br label %8
7: ; preds = %1
br label %8
8: ; preds = %1, %7, %6, %5, %4, %3, %2
%9 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([23 x i8], [23 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 ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %9
}