#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 */
#define ARPHRD_ARCNET 159
#define ARPHRD_ATM 158
#define ARPHRD_AX25 157
#define ARPHRD_CAN 156
#define ARPHRD_CHAOS 155
#define ARPHRD_CISCO 154
#define ARPHRD_CSLIP 153
#define ARPHRD_CSLIP6 152
#define ARPHRD_DLCI 151
#define ARPHRD_ECONET 150
#define ARPHRD_EETHER 149
#define ARPHRD_ETHER 148
#define ARPHRD_FDDI 147
#define ARPHRD_IEEE802 146
#define ARPHRD_IEEE80211 145
#define ARPHRD_IEEE80211_PRISM 144
#define ARPHRD_IEEE80211_RADIOTAP 143
#define ARPHRD_IEEE802154 142
#define ARPHRD_IEEE802_TR 141
#define ARPHRD_INFINIBAND 140
#define ARPHRD_IPDDP 139
#define ARPHRD_IPGRE 138
#define ARPHRD_IRDA 137
#define ARPHRD_LOOPBACK 136
#define ARPHRD_PPP 135
#define ARPHRD_PRONET 134
#define ARPHRD_RAWHDLC 133
#define ARPHRD_SIT 132
#define ARPHRD_SLIP 131
#define ARPHRD_SLIP6 130
#define ARPHRD_TUNNEL 129
#define ARPHRD_TUNNEL6 128
int device_type(char const *);
int pcap_devtype_to_linktype(const char *ifname) {
  switch (device_type(ifname)) {
  case ARPHRD_TUNNEL:
  case ARPHRD_TUNNEL6:
  case ARPHRD_LOOPBACK:
  case ARPHRD_SIT:
  case ARPHRD_IPDDP:
  case ARPHRD_IPGRE:
  case 823:
  case ARPHRD_ETHER:
    return 1;
  case ARPHRD_IEEE80211_PRISM:
  case ARPHRD_IEEE80211_RADIOTAP:
  case ARPHRD_IEEE80211:
    return 105;
  case 824:
    return 253;
  case ARPHRD_EETHER:
    return 2;
  case ARPHRD_AX25:
    return 3;
  case ARPHRD_CHAOS:
    return 5;
  case ARPHRD_PRONET:
    return 4;
  case ARPHRD_IEEE802_TR:
  case ARPHRD_IEEE802:
    return 6;
  case ARPHRD_INFINIBAND:
    return 247;
  case ARPHRD_ATM:
    return 19;
  case ARPHRD_DLCI:
    return 107;
  case ARPHRD_ARCNET:
    return 129;
  case ARPHRD_CSLIP:
  case ARPHRD_CSLIP6:
  case ARPHRD_SLIP6:
  case ARPHRD_SLIP:
    return 8;
  case ARPHRD_PPP:
    return 9;
  case ARPHRD_CAN:
    return 190;
  case ARPHRD_ECONET:
    return 115;
  case ARPHRD_RAWHDLC:
  case ARPHRD_CISCO:
    return 104;
  case ARPHRD_FDDI:
    return 10;
  case 805:
  case ARPHRD_IEEE802154:
    return 191;
  case ARPHRD_IRDA:
    return 144;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<pcap_devtype_to_linktype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <device_type@plt>
mov    %eax,%ecx
mov    %ecx,%eax
add    $0xffffff80,%eax
mov    %ecx,-0x14(%rbp)
sub    $0x2,%eax
jb     135d <pcap_devtype_to_linktype+0x24d>
jmp    113d <pcap_devtype_to_linktype+0x2d>
mov    -0x14(%rbp),%eax
add    $0xffffff7e,%eax
sub    $0x2,%eax
jb     13ed <pcap_devtype_to_linktype+0x2dd>
jmp    1153 <pcap_devtype_to_linktype+0x43>
mov    -0x14(%rbp),%eax
sub    $0x84,%eax
je     135d <pcap_devtype_to_linktype+0x24d>
jmp    1166 <pcap_devtype_to_linktype+0x56>
mov    -0x14(%rbp),%eax
sub    $0x85,%eax
je     141d <pcap_devtype_to_linktype+0x30d>
jmp    1179 <pcap_devtype_to_linktype+0x69>
mov    -0x14(%rbp),%eax
sub    $0x86,%eax
je     13a5 <pcap_devtype_to_linktype+0x295>
jmp    118c <pcap_devtype_to_linktype+0x7c>
mov    -0x14(%rbp),%eax
sub    $0x87,%eax
je     13f9 <pcap_devtype_to_linktype+0x2e9>
jmp    119f <pcap_devtype_to_linktype+0x8f>
mov    -0x14(%rbp),%eax
sub    $0x88,%eax
je     135d <pcap_devtype_to_linktype+0x24d>
jmp    11b2 <pcap_devtype_to_linktype+0xa2>
mov    -0x14(%rbp),%eax
sub    $0x89,%eax
je     1441 <pcap_devtype_to_linktype+0x331>
jmp    11c5 <pcap_devtype_to_linktype+0xb5>
mov    -0x14(%rbp),%eax
add    $0xffffff76,%eax
sub    $0x2,%eax
jb     135d <pcap_devtype_to_linktype+0x24d>
jmp    11db <pcap_devtype_to_linktype+0xcb>
mov    -0x14(%rbp),%eax
sub    $0x8c,%eax
je     13bd <pcap_devtype_to_linktype+0x2ad>
jmp    11ee <pcap_devtype_to_linktype+0xde>
mov    -0x14(%rbp),%eax
sub    $0x8d,%eax
je     13b1 <pcap_devtype_to_linktype+0x2a1>
jmp    1201 <pcap_devtype_to_linktype+0xf1>
mov    -0x14(%rbp),%eax
sub    $0x8e,%eax
je     1435 <pcap_devtype_to_linktype+0x325>
jmp    1214 <pcap_devtype_to_linktype+0x104>
mov    -0x14(%rbp),%eax
add    $0xffffff71,%eax
sub    $0x3,%eax
jb     1369 <pcap_devtype_to_linktype+0x259>
jmp    122a <pcap_devtype_to_linktype+0x11a>
mov    -0x14(%rbp),%eax
sub    $0x92,%eax
je     13b1 <pcap_devtype_to_linktype+0x2a1>
jmp    123d <pcap_devtype_to_linktype+0x12d>
mov    -0x14(%rbp),%eax
sub    $0x93,%eax
je     1429 <pcap_devtype_to_linktype+0x319>
jmp    1250 <pcap_devtype_to_linktype+0x140>
mov    -0x14(%rbp),%eax
sub    $0x94,%eax
je     135d <pcap_devtype_to_linktype+0x24d>
jmp    1263 <pcap_devtype_to_linktype+0x153>
mov    -0x14(%rbp),%eax
sub    $0x95,%eax
je     1381 <pcap_devtype_to_linktype+0x271>
jmp    1276 <pcap_devtype_to_linktype+0x166>
mov    -0x14(%rbp),%eax
sub    $0x96,%eax
je     1411 <pcap_devtype_to_linktype+0x301>
jmp    1289 <pcap_devtype_to_linktype+0x179>
mov    -0x14(%rbp),%eax
sub    $0x97,%eax
je     13d5 <pcap_devtype_to_linktype+0x2c5>
jmp    129c <pcap_devtype_to_linktype+0x18c>
mov    -0x14(%rbp),%eax
add    $0xffffff68,%eax
sub    $0x2,%eax
jb     13ed <pcap_devtype_to_linktype+0x2dd>
jmp    12b2 <pcap_devtype_to_linktype+0x1a2>
mov    -0x14(%rbp),%eax
sub    $0x9a,%eax
je     141d <pcap_devtype_to_linktype+0x30d>
jmp    12c5 <pcap_devtype_to_linktype+0x1b5>
mov    -0x14(%rbp),%eax
sub    $0x9b,%eax
je     1399 <pcap_devtype_to_linktype+0x289>
jmp    12d8 <pcap_devtype_to_linktype+0x1c8>
mov    -0x14(%rbp),%eax
sub    $0x9c,%eax
je     1405 <pcap_devtype_to_linktype+0x2f5>
jmp    12eb <pcap_devtype_to_linktype+0x1db>
mov    -0x14(%rbp),%eax
sub    $0x9d,%eax
je     138d <pcap_devtype_to_linktype+0x27d>
jmp    12fe <pcap_devtype_to_linktype+0x1ee>
mov    -0x14(%rbp),%eax
sub    $0x9e,%eax
je     13c9 <pcap_devtype_to_linktype+0x2b9>
jmp    1311 <pcap_devtype_to_linktype+0x201>
mov    -0x14(%rbp),%eax
sub    $0x9f,%eax
je     13e1 <pcap_devtype_to_linktype+0x2d1>
jmp    1324 <pcap_devtype_to_linktype+0x214>
mov    -0x14(%rbp),%eax
sub    $0x325,%eax
je     1435 <pcap_devtype_to_linktype+0x325>
jmp    1337 <pcap_devtype_to_linktype+0x227>
mov    -0x14(%rbp),%eax
sub    $0x337,%eax
je     135d <pcap_devtype_to_linktype+0x24d>
jmp    134a <pcap_devtype_to_linktype+0x23a>
mov    -0x14(%rbp),%eax
sub    $0x338,%eax
je     1375 <pcap_devtype_to_linktype+0x265>
jmp    144d <pcap_devtype_to_linktype+0x33d>
movl   $0x1,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x69,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0xfd,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x2,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x3,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x5,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x4,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x6,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0xf7,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x13,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x6b,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x81,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x8,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x9,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0xbe,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x73,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x68,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0xa,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0xbf,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x90,-0x4(%rbp)
jmp    1454 <pcap_devtype_to_linktype+0x344>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcap_devtype_to_linktype>:
push   %rax
call   1030 <device_type@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x324,%ecx
jg     114a <pcap_devtype_to_linktype+0x3a>
add    $0xffffff80,%ecx
cmp    $0x1f,%ecx
ja     11e0 <pcap_devtype_to_linktype+0xd0>
lea    0xec8(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
pop    %rcx
ret
mov    $0x8,%eax
pop    %rcx
ret
cmp    $0x325,%ecx
je     117e <pcap_devtype_to_linktype+0x6e>
cmp    $0x337,%ecx
je     1141 <pcap_devtype_to_linktype+0x31>
cmp    $0x338,%ecx
jne    11e0 <pcap_devtype_to_linktype+0xd0>
mov    $0xfd,%eax
pop    %rcx
ret
mov    $0x69,%eax
pop    %rcx
ret
mov    $0x68,%eax
pop    %rcx
ret
mov    $0x6,%eax
pop    %rcx
ret
mov    $0xbf,%eax
pop    %rcx
ret
mov    $0x4,%eax
pop    %rcx
ret
mov    $0x9,%eax
pop    %rcx
ret
mov    $0x90,%eax
pop    %rcx
ret
mov    $0xf7,%eax
pop    %rcx
ret
mov    $0xa,%eax
pop    %rcx
ret
mov    $0x2,%eax
pop    %rcx
ret
mov    $0x73,%eax
pop    %rcx
ret
mov    $0x6b,%eax
pop    %rcx
ret
mov    $0x5,%eax
pop    %rcx
ret
mov    $0xbe,%eax
pop    %rcx
ret
mov    $0x3,%eax
pop    %rcx
ret
mov    $0x13,%eax
pop    %rcx
ret
mov    $0x81,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @pcap_devtype_to_linktype(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @device_type(i8* %4)
switch i32 %5, label %26 [
i32 129, label %6
i32 128, label %6
i32 136, label %6
i32 132, label %6
i32 139, label %6
i32 138, label %6
i32 823, label %6
i32 148, label %6
i32 144, label %7
i32 143, label %7
i32 145, label %7
i32 824, label %8
i32 149, label %9
i32 157, label %10
i32 155, label %11
i32 134, label %12
i32 141, label %13
i32 146, label %13
i32 140, label %14
i32 158, label %15
i32 151, label %16
i32 159, label %17
i32 153, label %18
i32 152, label %18
i32 130, label %18
i32 131, label %18
i32 135, label %19
i32 156, label %20
i32 150, label %21
i32 133, label %22
i32 154, label %22
i32 147, label %23
i32 805, label %24
i32 142, label %24
i32 137, label %25
]
6: ; preds = %1, %1, %1, %1, %1, %1, %1, %1
store i32 1, i32* %2
br label %27
7: ; preds = %1, %1, %1
store i32 105, i32* %2
br label %27
8: ; preds = %1
store i32 253, i32* %2
br label %27
9: ; preds = %1
store i32 2, i32* %2
br label %27
10: ; preds = %1
store i32 3, i32* %2
br label %27
11: ; preds = %1
store i32 5, i32* %2
br label %27
12: ; preds = %1
store i32 4, i32* %2
br label %27
13: ; preds = %1, %1
store i32 6, i32* %2
br label %27
14: ; preds = %1
store i32 247, i32* %2
br label %27
15: ; preds = %1
store i32 19, i32* %2
br label %27
16: ; preds = %1
store i32 107, i32* %2
br label %27
17: ; preds = %1
store i32 129, i32* %2
br label %27
18: ; preds = %1, %1, %1, %1
store i32 8, i32* %2
br label %27
19: ; preds = %1
store i32 9, i32* %2
br label %27
20: ; preds = %1
store i32 190, i32* %2
br label %27
21: ; preds = %1
store i32 115, i32* %2
br label %27
22: ; preds = %1, %1
store i32 104, i32* %2
br label %27
23: ; preds = %1
store i32 10, i32* %2
br label %27
24: ; preds = %1, %1
store i32 191, i32* %2
br label %27
25: ; preds = %1
store i32 144, i32* %2
br label %27
26: ; preds = %1
store i32 0, i32* %2
br label %27
27: ; preds = %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
define i32 @pcap_devtype_to_linktype(i8* %0) {
%2 = tail call i32 @device_type(i8* %0)
switch i32 %2, label %22 [
i32 129, label %23
i32 128, label %23
i32 136, label %23
i32 132, label %23
i32 139, label %23
i32 138, label %23
i32 823, label %23
i32 148, label %23
i32 144, label %3
i32 143, label %3
i32 145, label %3
i32 824, label %4
i32 149, label %5
i32 157, label %6
i32 155, label %7
i32 134, label %8
i32 141, label %9
i32 146, label %9
i32 140, label %10
i32 158, label %11
i32 151, label %12
i32 159, label %13
i32 153, label %14
i32 152, label %14
i32 130, label %14
i32 131, label %14
i32 135, label %15
i32 156, label %16
i32 150, label %17
i32 133, label %18
i32 154, label %18
i32 147, label %19
i32 805, label %20
i32 142, label %20
i32 137, label %21
]
3: ; preds = %1, %1, %1
br label %23
4: ; preds = %1
br label %23
5: ; preds = %1
br label %23
6: ; preds = %1
br label %23
7: ; preds = %1
br label %23
8: ; preds = %1
br label %23
9: ; preds = %1, %1
br label %23
10: ; preds = %1
br label %23
11: ; preds = %1
br label %23
12: ; preds = %1
br label %23
13: ; preds = %1
br label %23
14: ; preds = %1, %1, %1, %1
br label %23
15: ; preds = %1
br label %23
16: ; preds = %1
br label %23
17: ; preds = %1
br label %23
18: ; preds = %1, %1
br label %23
19: ; preds = %1
br label %23
20: ; preds = %1, %1
br label %23
21: ; preds = %1
br label %23
22: ; preds = %1
br label %23
23: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3
%24 = phi i32 [ 0, %22 ], [ 144, %21 ], [ 191, %20 ], [ 10, %19 ], [ 104, %18 ], [ 115, %17 ], [ 190, %16 ], [ 9, %15 ], [ 8, %14 ], [ 129, %13 ], [ 107, %12 ], [ 19, %11 ], [ 247, %10 ], [ 6, %9 ], [ 4, %8 ], [ 5, %7 ], [ 3, %6 ], [ 2, %5 ], [ 253, %4 ], [ 105, %3 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ], [ 1, %1 ]
ret i32 %24
}