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

/* Variables and functions */
#define ETHERTYPE_AARP 138
#define ETHERTYPE_ARP 137
#define ETHERTYPE_AT 136
#define ETHERTYPE_IP 135
#define ETHERTYPE_IPV6 134
#define ETHERTYPE_IPX 133
#define ETHERTYPE_LOOPBACK 132
#define ETHERTYPE_PUP 131
#define ETHERTYPE_REVARP 130
#define ETHERTYPE_SPRITE 129
#define ETHERTYPE_VLAN 128
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int htons(int /*<<< orphan*/ const);
int /*<<< orphan*/ stdout;
void ethernet_print_type(const uint16_t ether_type) {
  switch (htons(ether_type)) {
  case ETHERTYPE_PUP:
    fprintf(stdout, "PUP");
    break;
  case ETHERTYPE_SPRITE:
    fprintf(stdout, "Sprite");
    break;
  case ETHERTYPE_IP:
    fprintf(stdout, "IPv4");
    break;
  case ETHERTYPE_ARP:
    fprintf(stdout, "ARP");
    break;
  case ETHERTYPE_REVARP:
    fprintf(stdout, "RARP");
    break;
  case ETHERTYPE_AT:
    fprintf(stdout, "AT");
    break;
  case ETHERTYPE_AARP:
    fprintf(stdout, "AARP");
    break;
  case ETHERTYPE_VLAN:
    fprintf(stdout, "VLAN");
    break;
  case ETHERTYPE_IPX:
    fprintf(stdout, "IPX");
    break;
  case ETHERTYPE_IPV6:
    fprintf(stdout, "IPv6");
    break;
  case ETHERTYPE_LOOPBACK:
    fprintf(stdout, "Test");
    break;
  default:
    fprintf(stdout, "????");
    break;
  }
}


x86 assembly (clang, -O0):
<ethernet_print_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <htons@plt>
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xa,%eax
ja     1277 <ethernet_print_type+0x157>
mov    -0x10(%rbp),%rax
lea    0xeb0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xec3(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xead(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
call   1040 <fprintf@plt>
jmp    128c <ethernet_print_type+0x16c>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xdd5(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ethernet_print_type>:
push   %rax
call   1030 <htons@plt>
add    $0xffffff80,%eax
cmp    $0xa,%eax
ja     1140 <ethernet_print_type+0x20>
cltq
lea    0xf01(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    1147 <ethernet_print_type+0x27>
lea    0xee9(%rip),%rsi
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [4 x i8] c"PUP\00"
@.str.1 = [7 x i8] c"Sprite\00"
@.str.2 = [5 x i8] c"IPv4\00"
@.str.3 = [4 x i8] c"ARP\00"
@.str.4 = [5 x i8] c"RARP\00"
@.str.5 = [3 x i8] c"AT\00"
@.str.6 = [5 x i8] c"AARP\00"
@.str.7 = [5 x i8] c"VLAN\00"
@.str.8 = [4 x i8] c"IPX\00"
@.str.9 = [5 x i8] c"IPv6\00"
@.str.10 = [5 x i8] c"Test\00"
@.str.11 = [5 x i8] c"????\00"
define void @ethernet_print_type(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @htons(i32 %3)
switch i32 %4, label %38 [
i32 131, label %5
i32 129, label %8
i32 135, label %11
i32 137, label %14
i32 130, label %17
i32 136, label %20
i32 138, label %23
i32 128, label %26
i32 133, label %29
i32 134, label %32
i32 132, label %35
]
5: ; preds = %1
%6 = load i32, i32* @stdout
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %41
8: ; preds = %1
%9 = load i32, i32* @stdout
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %41
11: ; preds = %1
%12 = load i32, i32* @stdout
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %41
14: ; preds = %1
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %41
17: ; preds = %1
%18 = load i32, i32* @stdout
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %41
20: ; preds = %1
%21 = load i32, i32* @stdout
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %41
23: ; preds = %1
%24 = load i32, i32* @stdout
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %41
26: ; preds = %1
%27 = load i32, i32* @stdout
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %41
29: ; preds = %1
%30 = load i32, i32* @stdout
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %41
32: ; preds = %1
%33 = load i32, i32* @stdout
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %41
35: ; preds = %1
%36 = load i32, i32* @stdout
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %41
38: ; preds = %1
%39 = load i32, i32* @stdout
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %41
41: ; preds = %38, %35, %32, %29, %26, %23, %20, %17, %14, %11, %8, %5
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [4 x i8] c"PUP\00"
@.str.1 = [7 x i8] c"Sprite\00"
@.str.2 = [5 x i8] c"IPv4\00"
@.str.3 = [4 x i8] c"ARP\00"
@.str.4 = [5 x i8] c"RARP\00"
@.str.5 = [3 x i8] c"AT\00"
@.str.6 = [5 x i8] c"AARP\00"
@.str.7 = [5 x i8] c"VLAN\00"
@.str.8 = [4 x i8] c"IPX\00"
@.str.9 = [5 x i8] c"IPv6\00"
@.str.10 = [5 x i8] c"Test\00"
@.str.11 = [5 x i8] c"????\00"
@reltable.ethernet_print_type = [11 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.10 to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.8 to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.9 to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.5 to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([11 x i32]* @reltable.ethernet_print_type to i64)) to i32)]
define void @ethernet_print_type(i32 %0) {
%2 = tail call i32 @htons(i32 %0)
%3 = add i32 %2, -128
%4 = icmp ult i32 %3, 11
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([11 x i32]* @reltable.ethernet_print_type to i8*), i64 %7)
br label %9
9: ; preds = %1, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), %1 ]
%11 = load i32, i32* @stdout
%12 = tail call i32 @fprintf(i32 %11, i8* %10)
ret void
}