#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 */

/* Variables and functions */
int /*<<< orphan*/ strcpy(char *, char *);
void resolve_packet(int packet, char *packet_type) {
  switch (packet) {
  case 0:
    strcpy(packet_type, "SCHEDULE");
    break;
  case 1:
    strcpy(packet_type, "SCHEDULE_ELEMENT");
    break;
  case 2:
    strcpy(packet_type, "DATA");
    break;
  case 3:
    strcpy(packet_type, "JOIN_REQUEST");
    break;
  case 4:
    strcpy(packet_type, "FLOW_REQUEST");
    break;
  case 5:
    strcpy(packet_type, "BW_REQUEST");
    break;
  case 6:
    strcpy(packet_type, "TEAR_DOWN");
    break;
  case 7:
    strcpy(packet_type, "LINK_LEVEL_ACK");
    break;
  case 8:
    strcpy(packet_type, "CONTENTION_FORWARD");
    break;
  case 9:
    strcpy(packet_type, "VOICE_FLOW_REQUEST");
    break;
  case 10:
    strcpy(packet_type, "TOPOLOGY_UPDATE");
    break;
  case 11:
    strcpy(packet_type, "EXPECTED_FRAGMENT");
    break;
  case 12:
    strcpy(packet_type, "MOBILE_DIRECTION");
    break;
  }
}


x86 assembly (clang, -O0):
<resolve_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0xc,%rax
ja     1250 <resolve_packet+0x140>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xee5(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xefa(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1250 <resolve_packet+0x140>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resolve_packet>:
cmp    $0xc,%edi
ja     1131 <resolve_packet+0x21>
movslq %edi,%rax
lea    0xf8d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
jmp    1030 <strcpy@plt>
ret

LLVM IR (-O0):
@.str = [9 x i8] c"SCHEDULE\00"
@.str.1 = [17 x i8] c"SCHEDULE_ELEMENT\00"
@.str.2 = [5 x i8] c"DATA\00"
@.str.3 = [13 x i8] c"JOIN_REQUEST\00"
@.str.4 = [13 x i8] c"FLOW_REQUEST\00"
@.str.5 = [11 x i8] c"BW_REQUEST\00"
@.str.6 = [10 x i8] c"TEAR_DOWN\00"
@.str.7 = [15 x i8] c"LINK_LEVEL_ACK\00"
@.str.8 = [19 x i8] c"CONTENTION_FORWARD\00"
@.str.9 = [19 x i8] c"VOICE_FLOW_REQUEST\00"
@.str.10 = [16 x i8] c"TOPOLOGY_UPDATE\00"
@.str.11 = [18 x i8] c"EXPECTED_FRAGMENT\00"
@.str.12 = [17 x i8] c"MOBILE_DIRECTION\00"
define void @resolve_packet(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
switch i32 %5, label %45 [
i32 0, label %6
i32 1, label %9
i32 2, label %12
i32 3, label %15
i32 4, label %18
i32 5, label %21
i32 6, label %24
i32 7, label %27
i32 8, label %30
i32 9, label %33
i32 10, label %36
i32 11, label %39
i32 12, label %42
]
6: ; preds = %2
%7 = load i8*, i8** %4
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %45
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %45
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %45
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %45
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %45
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %45
24: ; preds = %2
%25 = load i8*, i8** %4
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
br label %45
27: ; preds = %2
%28 = load i8*, i8** %4
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %45
30: ; preds = %2
%31 = load i8*, i8** %4
%32 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
br label %45
33: ; preds = %2
%34 = load i8*, i8** %4
%35 = call i32 @strcpy(i8* %34, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
br label %45
36: ; preds = %2
%37 = load i8*, i8** %4
%38 = call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %45
39: ; preds = %2
%40 = load i8*, i8** %4
%41 = call i32 @strcpy(i8* %40, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %45
42: ; preds = %2
%43 = load i8*, i8** %4
%44 = call i32 @strcpy(i8* %43, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
br label %45
45: ; preds = %2, %42, %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %6
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"SCHEDULE\00"
@.str.1 = [17 x i8] c"SCHEDULE_ELEMENT\00"
@.str.2 = [5 x i8] c"DATA\00"
@.str.3 = [13 x i8] c"JOIN_REQUEST\00"
@.str.4 = [13 x i8] c"FLOW_REQUEST\00"
@.str.5 = [11 x i8] c"BW_REQUEST\00"
@.str.6 = [10 x i8] c"TEAR_DOWN\00"
@.str.7 = [15 x i8] c"LINK_LEVEL_ACK\00"
@.str.8 = [19 x i8] c"CONTENTION_FORWARD\00"
@.str.9 = [19 x i8] c"VOICE_FLOW_REQUEST\00"
@.str.10 = [16 x i8] c"TOPOLOGY_UPDATE\00"
@.str.11 = [18 x i8] c"EXPECTED_FRAGMENT\00"
@.str.12 = [17 x i8] c"MOBILE_DIRECTION\00"
@reltable.resolve_packet = [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.1 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.8 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.9 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.10 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.11 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.12 to i64), i64 ptrtoint ([13 x i32]* @reltable.resolve_packet to i64)) to i32)]
define void @resolve_packet(i32 %0, i8* %1) {
%3 = icmp ult i32 %0, 13
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = sext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.resolve_packet to i8*), i64 %6)
%8 = tail call i32 @strcpy(i8* %1, i8* %7)
br label %9
9: ; preds = %2, %4
ret void
}