#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ descbuf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned int);
const char *twopence_protocol_packet_type_to_string(unsigned int type) {
  static char descbuf[64];
  switch (type) {
  case 'h':
    return "hello";
  case 'i':
    return "inject";
  case 'e':
    return "extract";
  case 'c':
    return "command";
  case 'q':
    return "quit";
  case 'D':
    return "data";
  case 'E':
    return "eof";
  case 'I':
    return "intr";
  case 'M':
    return "major";
  case 'm':
    return "minor";
  case 'T':
    return "timeout";
  case 'K':
    return "keepalive";
  default:
    snprintf(descbuf, sizeof(descbuf), "trans-type-%d", type);
    return descbuf;
  }
}


x86 assembly (clang, -O0):
<twopence_protocol_packet_type_to_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x2d,%eax
ja     1204 <twopence_protocol_packet_type_to_string+0xf4>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf6d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf63(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf5a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf52(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf4a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf3f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf34(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf28(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf1d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf13(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf09(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
lea    0xf01(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <twopence_protocol_packet_type_to_string+0x11a>
mov    -0xc(%rbp),%ecx
lea    0x2e32(%rip),%rdi
mov    $0x40,%esi
lea    0xeec(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2e1a(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<twopence_protocol_packet_type_to_string>:
push   %rbx
mov    %edi,%ecx
lea    -0x44(%rcx),%eax
cmp    $0x2d,%eax
ja     1144 <twopence_protocol_packet_type_to_string+0x34>
lea    0xf96(%rip),%rbx
lea    0xed7(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
lea    0xfa1(%rip),%rbx
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0xf9d(%rip),%rbx
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0x2ef5(%rip),%rbx
lea    0xfb4(%rip),%rdx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1030 <snprintf@plt>
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0xf7b(%rip),%rbx
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0xf8b(%rip),%rbx
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0xf6e(%rip),%rbx
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0xf71(%rip),%rbx
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0xf41(%rip),%rbx
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0xf30(%rip),%rbx
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0xf20(%rip),%rbx
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0xf47(%rip),%rbx
jmp    11b0 <twopence_protocol_packet_type_to_string+0xa0>
lea    0xf25(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@twopence_protocol_packet_type_to_string.descbuf = internal global [64 x i8] zeroinitializer
@.str = [6 x i8] c"hello\00"
@.str.1 = [7 x i8] c"inject\00"
@.str.2 = [8 x i8] c"extract\00"
@.str.3 = [8 x i8] c"command\00"
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [5 x i8] c"data\00"
@.str.6 = [4 x i8] c"eof\00"
@.str.7 = [5 x i8] c"intr\00"
@.str.8 = [6 x i8] c"major\00"
@.str.9 = [6 x i8] c"minor\00"
@.str.10 = [8 x i8] c"timeout\00"
@.str.11 = [10 x i8] c"keepalive\00"
@.str.12 = [14 x i8] c"trans-type-%d\00"
define i8* @twopence_protocol_packet_type_to_string(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %17 [
i32 104, label %5
i32 105, label %6
i32 101, label %7
i32 99, label %8
i32 113, label %9
i32 68, label %10
i32 69, label %11
i32 73, label %12
i32 77, label %13
i32 109, label %14
i32 84, label %15
i32 75, label %16
]
5: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
br label %20
6: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %20
7: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %20
8: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %20
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %20
10: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %20
11: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %20
12: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %20
13: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %20
14: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %20
15: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %20
16: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %20
17: ; preds = %1
%18 = load i32, i32* %3
%19 = call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @twopence_protocol_packet_type_to_string.descbuf, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i32 %18)
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @twopence_protocol_packet_type_to_string.descbuf, i64 0, i64 0), i8** %2
br label %20
20: ; preds = %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@twopence_protocol_packet_type_to_string.descbuf = internal global [64 x i8] zeroinitializer
@.str = [6 x i8] c"hello\00"
@.str.1 = [7 x i8] c"inject\00"
@.str.2 = [8 x i8] c"extract\00"
@.str.3 = [8 x i8] c"command\00"
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [5 x i8] c"data\00"
@.str.6 = [4 x i8] c"eof\00"
@.str.7 = [5 x i8] c"intr\00"
@.str.8 = [6 x i8] c"major\00"
@.str.9 = [6 x i8] c"minor\00"
@.str.10 = [8 x i8] c"timeout\00"
@.str.11 = [10 x i8] c"keepalive\00"
@.str.12 = [14 x i8] c"trans-type-%d\00"
define i8* @twopence_protocol_packet_type_to_string(i32 %0) {
switch i32 %0, label %13 [
i32 104, label %15
i32 105, label %2
i32 101, label %3
i32 99, label %4
i32 113, label %5
i32 68, label %6
i32 69, label %7
i32 73, label %8
i32 77, label %9
i32 109, label %10
i32 84, label %11
i32 75, label %12
]
2: ; preds = %1
br label %15
3: ; preds = %1
br label %15
4: ; preds = %1
br label %15
5: ; preds = %1
br label %15
6: ; preds = %1
br label %15
7: ; preds = %1
br label %15
8: ; preds = %1
br label %15
9: ; preds = %1
br label %15
10: ; preds = %1
br label %15
11: ; preds = %1
br label %15
12: ; preds = %1
br label %15
13: ; preds = %1
%14 = tail call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @twopence_protocol_packet_type_to_string.descbuf, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i32 %0)
br label %15
15: ; preds = %1, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%16 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @twopence_protocol_packet_type_to_string.descbuf, i64 0, i64 0), %13 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), %12 ], [ 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 ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([5 x i8], [5 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 ([8 x i8], [8 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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %16
}