#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 ARPHRD_APPLETLK 142
#define ARPHRD_ARCNET 141
#define ARPHRD_ATM 140
#define ARPHRD_AX25 139
#define ARPHRD_CHAOS 138
#define ARPHRD_DLCI 137
#define ARPHRD_EETHER 136
#define ARPHRD_ETHER 135
#define ARPHRD_EUI64 134
#define ARPHRD_IEEE1394 133
#define ARPHRD_IEEE802 132
#define ARPHRD_INFINIBAND 131
#define ARPHRD_METRICOM 130
#define ARPHRD_NETROM 129
#define ARPHRD_PRONET 128
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int htons(int /*<<< orphan*/ const);
int /*<<< orphan*/ stdout;
void arp_print_protocol(const uint16_t protocol) {
  switch (htons(protocol)) {
  case ARPHRD_NETROM:
    fprintf(stdout, "From KA9Q: NET/ROM pseudo");
    break;
  case ARPHRD_ETHER:
    fprintf(stdout, "Ethernet 10/100Mbps");
    break;
  case ARPHRD_EETHER:
    fprintf(stdout, "Experimental Ethernet");
    break;
  case ARPHRD_AX25:
    fprintf(stdout, "AX.25 Level 2");
    break;
  case ARPHRD_PRONET:
    fprintf(stdout, "PROnet token ring");
    break;
  case ARPHRD_CHAOS:
    fprintf(stdout, "Chaosnet");
    break;
  case ARPHRD_IEEE802:
    fprintf(stdout, "IEEE 802.2 Ethernet/TR/TB");
    break;
  case ARPHRD_ARCNET:
    fprintf(stdout, "ARCnet");
    break;
  case ARPHRD_APPLETLK:
    fprintf(stdout, "APPLEtalk");
    break;
  case ARPHRD_DLCI:
    fprintf(stdout, "Frame Relay DLCI");
    break;
  case ARPHRD_ATM:
    fprintf(stdout, "ATM");
    break;
  case ARPHRD_METRICOM:
    fprintf(stdout, "Metricom STRIP (new IANA id)");
    break;
  case ARPHRD_IEEE1394:
    fprintf(stdout, "IEEE 1394 IPv4 - RFC 2734");
    break;
  case ARPHRD_EUI64:
    fprintf(stdout, "EUI-64");
    break;
  case ARPHRD_INFINIBAND:
    fprintf(stdout, "InfiniBand");
    break;
  }
}


x86 assembly (clang, -O0):
<arp_print_protocol>:
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    $0xe,%eax
ja     12da <arp_print_protocol+0x1ba>
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    0xed3(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xed3(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xecd(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xec9(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xebd(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
call   1040 <fprintf@plt>
jmp    12da <arp_print_protocol+0x1ba>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arp_print_protocol>:
push   %rax
call   1030 <htons@plt>
add    $0xffffff80,%eax
cmp    $0xe,%eax
ja     114d <arp_print_protocol+0x2d>
cltq
lea    0xfc1(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    0x2e9b(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fprintf@plt>
pop    %rax
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [26 x i8] c"From KA9Q: NET/ROM pseudo\00"
@.str.1 = [20 x i8] c"Ethernet 10/100Mbps\00"
@.str.2 = [22 x i8] c"Experimental Ethernet\00"
@.str.3 = [14 x i8] c"AX.25 Level 2\00"
@.str.4 = [18 x i8] c"PROnet token ring\00"
@.str.5 = [9 x i8] c"Chaosnet\00"
@.str.6 = [26 x i8] c"IEEE 802.2 Ethernet/TR/TB\00"
@.str.7 = [7 x i8] c"ARCnet\00"
@.str.8 = [10 x i8] c"APPLEtalk\00"
@.str.9 = [17 x i8] c"Frame Relay DLCI\00"
@.str.10 = [4 x i8] c"ATM\00"
@.str.11 = [29 x i8] c"Metricom STRIP (new IANA id)\00"
@.str.12 = [26 x i8] c"IEEE 1394 IPv4 - RFC 2734\00"
@.str.13 = [7 x i8] c"EUI-64\00"
@.str.14 = [11 x i8] c"InfiniBand\00"
define void @arp_print_protocol(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 %50 [
i32 129, label %5
i32 135, label %8
i32 136, label %11
i32 139, label %14
i32 128, label %17
i32 138, label %20
i32 132, label %23
i32 141, label %26
i32 142, label %29
i32 137, label %32
i32 140, label %35
i32 130, label %38
i32 133, label %41
i32 134, label %44
i32 131, label %47
]
5: ; preds = %1
%6 = load i32, i32* @stdout
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %50
8: ; preds = %1
%9 = load i32, i32* @stdout
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %50
11: ; preds = %1
%12 = load i32, i32* @stdout
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %50
14: ; preds = %1
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %50
17: ; preds = %1
%18 = load i32, i32* @stdout
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %50
20: ; preds = %1
%21 = load i32, i32* @stdout
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %50
23: ; preds = %1
%24 = load i32, i32* @stdout
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %50
26: ; preds = %1
%27 = load i32, i32* @stdout
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %50
29: ; preds = %1
%30 = load i32, i32* @stdout
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %50
32: ; preds = %1
%33 = load i32, i32* @stdout
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %50
35: ; preds = %1
%36 = load i32, i32* @stdout
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
br label %50
38: ; preds = %1
%39 = load i32, i32* @stdout
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
br label %50
41: ; preds = %1
%42 = load i32, i32* @stdout
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
br label %50
44: ; preds = %1
%45 = load i32, i32* @stdout
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0))
br label %50
47: ; preds = %1
%48 = load i32, i32* @stdout
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
br label %50
50: ; preds = %1, %47, %44, %41, %38, %35, %32, %29, %26, %23, %20, %17, %14, %11, %8, %5
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [26 x i8] c"From KA9Q: NET/ROM pseudo\00"
@.str.1 = [20 x i8] c"Ethernet 10/100Mbps\00"
@.str.2 = [22 x i8] c"Experimental Ethernet\00"
@.str.3 = [14 x i8] c"AX.25 Level 2\00"
@.str.4 = [18 x i8] c"PROnet token ring\00"
@.str.5 = [9 x i8] c"Chaosnet\00"
@.str.6 = [26 x i8] c"IEEE 802.2 Ethernet/TR/TB\00"
@.str.7 = [7 x i8] c"ARCnet\00"
@.str.8 = [10 x i8] c"APPLEtalk\00"
@.str.9 = [17 x i8] c"Frame Relay DLCI\00"
@.str.10 = [4 x i8] c"ATM\00"
@.str.11 = [29 x i8] c"Metricom STRIP (new IANA id)\00"
@.str.12 = [26 x i8] c"IEEE 1394 IPv4 - RFC 2734\00"
@.str.13 = [7 x i8] c"EUI-64\00"
@.str.14 = [11 x i8] c"InfiniBand\00"
@reltable.arp_print_protocol = [15 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.4 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.11 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.14 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.6 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.12 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.13 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.1 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.2 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.9 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.3 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.8 to i64), i64 ptrtoint ([15 x i32]* @reltable.arp_print_protocol to i64)) to i32)]
define void @arp_print_protocol(i32 %0) {
%2 = tail call i32 @htons(i32 %0)
%3 = add i32 %2, -128
%4 = icmp ult i32 %3, 15
br i1 %4, label %5, label %11
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([15 x i32]* @reltable.arp_print_protocol to i8*), i64 %7)
%9 = load i32, i32* @stdout
%10 = tail call i32 @fprintf(i32 %9, i8* %8)
br label %11
11: ; preds = %1, %5
ret void
}