int compacthdr_type2str(int type, char **hname, int *hlen) {
  switch (type) {
  case 1:
    *hname = "VIA";
    *hlen = (sizeof("VIA") - 1);
    break;
  case (1 << 10):
    *hname = "CONTENT_TYPE";
    *hlen = (sizeof("CONTENT_TYPE") - 1);
    break;
  case (1 << 3):
    *hname = "FROM";
    *hlen = (sizeof("FROM") - 1);
    break;
  case (1 << 5):
    *hname = "CALLID";
    *hlen = (sizeof("CALLID") - 1);
    break;
  case (1 << 15):
    *hname = "SUPPORTED";
    *hlen = (sizeof("SUPPORTED") - 1);
    break;
  case (1 << 11):
    *hname = "CONTENT_LENGTH";
    *hlen = (sizeof("CONTENT_LENGTH") - 1);
    break;
  case (1 << 6):
    *hname = "CONTACT";
    *hlen = (sizeof("CONTACT") - 1);
    break;
  case (1 << 2):
    *hname = "TO";
    *hlen = (sizeof("TO") - 1);
    break;
  case (1 << 19):
    *hname = "EVENT";
    *hlen = (sizeof("EVENT") - 1);
    break;
  default:
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<compacthdr_type2str>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     11b3 <compacthdr_type2str+0xb3>
jmp    1123 <compacthdr_type2str+0x23>
mov    -0x1c(%rbp),%eax
sub    $0x4,%eax
je     127e <compacthdr_type2str+0x17e>
jmp    1134 <compacthdr_type2str+0x34>
mov    -0x1c(%rbp),%eax
sub    $0x8,%eax
je     11ed <compacthdr_type2str+0xed>
jmp    1145 <compacthdr_type2str+0x45>
mov    -0x1c(%rbp),%eax
sub    $0x20,%eax
je     120a <compacthdr_type2str+0x10a>
jmp    1156 <compacthdr_type2str+0x56>
mov    -0x1c(%rbp),%eax
sub    $0x40,%eax
je     1261 <compacthdr_type2str+0x161>
jmp    1167 <compacthdr_type2str+0x67>
mov    -0x1c(%rbp),%eax
sub    $0x400,%eax
je     11d0 <compacthdr_type2str+0xd0>
jmp    117a <compacthdr_type2str+0x7a>
mov    -0x1c(%rbp),%eax
sub    $0x800,%eax
je     1244 <compacthdr_type2str+0x144>
jmp    118d <compacthdr_type2str+0x8d>
mov    -0x1c(%rbp),%eax
sub    $0x8000,%eax
je     1227 <compacthdr_type2str+0x127>
jmp    11a0 <compacthdr_type2str+0xa0>
mov    -0x1c(%rbp),%eax
sub    $0x80000,%eax
je     129b <compacthdr_type2str+0x19b>
jmp    12b8 <compacthdr_type2str+0x1b8>
mov    -0x10(%rbp),%rax
lea    0xe42(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
jmp    12c4 <compacthdr_type2str+0x1c4>
mov    -0x10(%rbp),%rax
lea    0xe29(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0xc,(%rax)
jmp    12c4 <compacthdr_type2str+0x1c4>
mov    -0x10(%rbp),%rax
lea    0xe19(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
jmp    12c4 <compacthdr_type2str+0x1c4>
mov    -0x10(%rbp),%rax
lea    0xe01(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x6,(%rax)
jmp    12c4 <compacthdr_type2str+0x1c4>
mov    -0x10(%rbp),%rax
lea    0xdeb(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x9,(%rax)
jmp    12c4 <compacthdr_type2str+0x1c4>
mov    -0x10(%rbp),%rax
lea    0xdd8(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0xe,(%rax)
jmp    12c4 <compacthdr_type2str+0x1c4>
mov    -0x10(%rbp),%rax
lea    0xdca(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x7,(%rax)
jmp    12c4 <compacthdr_type2str+0x1c4>
mov    -0x10(%rbp),%rax
lea    0xdb5(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
jmp    12c4 <compacthdr_type2str+0x1c4>
mov    -0x10(%rbp),%rax
lea    0xd9b(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x5,(%rax)
jmp    12c4 <compacthdr_type2str+0x1c4>
movl   $0x0,-0x4(%rbp)
jmp    12cb <compacthdr_type2str+0x1cb>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<compacthdr_type2str>:
xor    %eax,%eax
cmp    $0x3ff,%edi
jg     1141 <compacthdr_type2str+0x41>
lea    -0x1(%rdi),%ecx
cmp    $0x1f,%ecx
ja     118b <compacthdr_type2str+0x8b>
mov    $0x3,%r8d
lea    0xf61(%rip),%rdi
lea    0xeda(%rip),%r9
movslq (%r9,%rcx,4),%rcx
add    %r9,%rcx
jmp    *%rcx
mov    $0x2,%r8d
lea    0xf82(%rip),%rdi
jmp    11d9 <compacthdr_type2str+0xd9>
cmp    $0x7fff,%edi
jg     116c <compacthdr_type2str+0x6c>
cmp    $0x400,%edi
je     11bd <compacthdr_type2str+0xbd>
cmp    $0x800,%edi
jne    11e4 <compacthdr_type2str+0xe4>
mov    $0xe,%r8d
lea    0xf3d(%rip),%rdi
jmp    11d9 <compacthdr_type2str+0xd9>
cmp    $0x8000,%edi
je     11cc <compacthdr_type2str+0xcc>
cmp    $0x80000,%edi
jne    11e4 <compacthdr_type2str+0xe4>
mov    $0x5,%r8d
lea    0xf38(%rip),%rdi
jmp    11d9 <compacthdr_type2str+0xd9>
cmp    $0x40,%edi
jne    11e4 <compacthdr_type2str+0xe4>
mov    $0x7,%r8d
lea    0xf19(%rip),%rdi
jmp    11d9 <compacthdr_type2str+0xd9>
mov    $0x4,%r8d
lea    0xee5(%rip),%rdi
jmp    11d9 <compacthdr_type2str+0xd9>
mov    $0x6,%r8d
lea    0xedb(%rip),%rdi
jmp    11d9 <compacthdr_type2str+0xd9>
mov    $0xc,%r8d
lea    0xeba(%rip),%rdi
jmp    11d9 <compacthdr_type2str+0xd9>
mov    $0x9,%r8d
lea    0xec4(%rip),%rdi
mov    %rdi,(%rsi)
mov    %r8d,(%rdx)
mov    $0x1,%eax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"VIA\00"
@.str.1 = [13 x i8] c"CONTENT_TYPE\00"
@.str.2 = [5 x i8] c"FROM\00"
@.str.3 = [7 x i8] c"CALLID\00"
@.str.4 = [10 x i8] c"SUPPORTED\00"
@.str.5 = [15 x i8] c"CONTENT_LENGTH\00"
@.str.6 = [8 x i8] c"CONTACT\00"
@.str.7 = [3 x i8] c"TO\00"
@.str.8 = [6 x i8] c"EVENT\00"
define i32 @compacthdr_type2str(i32 %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
%8 = load i32, i32* %5
switch i32 %8, label %36 [
i32 1, label %9
i32 1024, label %12
i32 8, label %15
i32 32, label %18
i32 32768, label %21
i32 2048, label %24
i32 64, label %27
i32 4, label %30
i32 524288, label %33
]
9: ; preds = %3
%10 = load i8**, i8*** %6
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %10
%11 = load i32*, i32** %7
store i32 3, i32* %11
br label %37
12: ; preds = %3
%13 = load i8**, i8*** %6
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %13
%14 = load i32*, i32** %7
store i32 12, i32* %14
br label %37
15: ; preds = %3
%16 = load i8**, i8*** %6
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %16
%17 = load i32*, i32** %7
store i32 4, i32* %17
br label %37
18: ; preds = %3
%19 = load i8**, i8*** %6
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %19
%20 = load i32*, i32** %7
store i32 6, i32* %20
br label %37
21: ; preds = %3
%22 = load i8**, i8*** %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %22
%23 = load i32*, i32** %7
store i32 9, i32* %23
br label %37
24: ; preds = %3
%25 = load i8**, i8*** %6
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8** %25
%26 = load i32*, i32** %7
store i32 14, i32* %26
br label %37
27: ; preds = %3
%28 = load i8**, i8*** %6
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8** %28
%29 = load i32*, i32** %7
store i32 7, i32* %29
br label %37
30: ; preds = %3
%31 = load i8**, i8*** %6
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %31
%32 = load i32*, i32** %7
store i32 2, i32* %32
br label %37
33: ; preds = %3
%34 = load i8**, i8*** %6
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8** %34
%35 = load i32*, i32** %7
store i32 5, i32* %35
br label %37
36: ; preds = %3
store i32 0, i32* %4
br label %38
37: ; preds = %33, %30, %27, %24, %21, %18, %15, %12, %9
store i32 1, i32* %4
br label %38
38: ; preds = %37, %36
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
@.str = [4 x i8] c"VIA\00"
@.str.1 = [13 x i8] c"CONTENT_TYPE\00"
@.str.2 = [5 x i8] c"FROM\00"
@.str.3 = [7 x i8] c"CALLID\00"
@.str.4 = [10 x i8] c"SUPPORTED\00"
@.str.5 = [15 x i8] c"CONTENT_LENGTH\00"
@.str.6 = [8 x i8] c"CONTACT\00"
@.str.7 = [3 x i8] c"TO\00"
@.str.8 = [6 x i8] c"EVENT\00"
define i32 @compacthdr_type2str(i32 %0, i8** nocapture writeonly %1, i32* nocapture writeonly %2) {
switch i32 %0, label %15 [
i32 1, label %12
i32 1024, label %4
i32 8, label %5
i32 32, label %6
i32 32768, label %7
i32 2048, label %8
i32 64, label %9
i32 4, label %10
i32 524288, label %11
]
4: ; preds = %3
br label %12
5: ; preds = %3
br label %12
6: ; preds = %3
br label %12
7: ; preds = %3
br label %12
8: ; preds = %3
br label %12
9: ; preds = %3
br label %12
10: ; preds = %3
br label %12
11: ; preds = %3
br label %12
12: ; preds = %3, %11, %10, %9, %8, %7, %6, %5, %4
%13 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), %10 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), %11 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %3 ]
%14 = phi i32 [ 12, %4 ], [ 4, %5 ], [ 6, %6 ], [ 9, %7 ], [ 14, %8 ], [ 7, %9 ], [ 2, %10 ], [ 5, %11 ], [ 3, %3 ]
store i8* %13, i8** %1
store i32 %14, i32* %2
br label %15
15: ; preds = %12, %3
%16 = phi i32 [ 0, %3 ], [ 1, %12 ]
ret i32 %16
}