#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*/ u_char;
struct ip {
  int ip_hl;
};
struct icmp {
  int icmp_type;
};

/* Variables and functions */
int isICMPRequest(const u_char *p, int source) {
  if (source)
    switch (((struct icmp *)(p + 14 + ((struct ip *)(p + 14))->ip_hl * 4))
                ->icmp_type) {
    case 8:
    case 10:
    case 13:
    case 15:
    case 17:
      return 1;
    default:
      return 0;
    }
  else
    switch (((struct icmp *)(p + 14 + ((struct ip *)(p + 14))->ip_hl * 4))
                ->icmp_type) {
    case 0:
    case 9:
    case 14:
    case 16:
    case 18:
      return 1;
    default:
      return 0;
    }
}


x86 assembly (clang, -O0):
<isICMPRequest>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1193 <isICMPRequest+0x93>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%ecx
shl    $0x2,%ecx
movslq %ecx,%rcx
mov    0x38(%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
sub    $0x8,%eax
je     117b <isICMPRequest+0x7b>
jmp    1137 <isICMPRequest+0x37>
mov    -0x18(%rbp),%eax
sub    $0xa,%eax
je     117b <isICMPRequest+0x7b>
jmp    1148 <isICMPRequest+0x48>
mov    -0x18(%rbp),%eax
sub    $0xd,%eax
je     117b <isICMPRequest+0x7b>
jmp    1159 <isICMPRequest+0x59>
mov    -0x18(%rbp),%eax
sub    $0xf,%eax
je     117b <isICMPRequest+0x7b>
jmp    116a <isICMPRequest+0x6a>
mov    -0x18(%rbp),%eax
sub    $0x11,%eax
jne    1187 <isICMPRequest+0x87>
jmp    117b <isICMPRequest+0x7b>
movl   $0x1,-0x4(%rbp)
jmp    120b <isICMPRequest+0x10b>
movl   $0x0,-0x4(%rbp)
jmp    120b <isICMPRequest+0x10b>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%ecx
shl    $0x2,%ecx
movslq %ecx,%rcx
mov    0x38(%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     11f8 <isICMPRequest+0xf8>
jmp    11b4 <isICMPRequest+0xb4>
mov    -0x1c(%rbp),%eax
sub    $0x9,%eax
je     11f8 <isICMPRequest+0xf8>
jmp    11c5 <isICMPRequest+0xc5>
mov    -0x1c(%rbp),%eax
sub    $0xe,%eax
je     11f8 <isICMPRequest+0xf8>
jmp    11d6 <isICMPRequest+0xd6>
mov    -0x1c(%rbp),%eax
sub    $0x10,%eax
je     11f8 <isICMPRequest+0xf8>
jmp    11e7 <isICMPRequest+0xe7>
mov    -0x1c(%rbp),%eax
sub    $0x12,%eax
jne    1204 <isICMPRequest+0x104>
jmp    11f8 <isICMPRequest+0xf8>
movl   $0x1,-0x4(%rbp)
jmp    120b <isICMPRequest+0x10b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isICMPRequest>:
movslq 0x38(%rdi),%rax
shl    $0x4,%rax
mov    0x38(%rdi,%rax,1),%ecx
test   %esi,%esi
je     1128 <isICMPRequest+0x28>
add    $0xfffffff8,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
jae    113c <isICMPRequest+0x3c>
movslq %ecx,%rax
lea    0xedc(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret
cmp    $0x12,%ecx
ja     113d <isICMPRequest+0x3d>
mov    $0x1,%eax
mov    $0x54201,%edx
bt     %ecx,%edx
jae    113d <isICMPRequest+0x3d>
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.ip = type { i32 }
%struct.icmp = type { i32 }
define i32 @isICMPRequest(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %2
%9 = load i32*, i32** %4
%10 = getelementptr inbounds i32, i32* %9, i64 14
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 14
%13 = bitcast i32* %12 to %struct.ip*
%14 = getelementptr inbounds %struct.ip, %struct.ip* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = mul nsw i32 %15, 4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %10, i64 %17
%19 = bitcast i32* %18 to %struct.icmp*
%20 = getelementptr inbounds %struct.icmp, %struct.icmp* %19, i32 0, i32 0
%21 = load i32, i32* %20
switch i32 %21, label %23 [
i32 8, label %22
i32 10, label %22
i32 13, label %22
i32 15, label %22
i32 17, label %22
]
22: ; preds = %8, %8, %8, %8, %8
store i32 1, i32* %3
br label %40
23: ; preds = %8
store i32 0, i32* %3
br label %40
24: ; preds = %2
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i64 14
%27 = load i32*, i32** %4
%28 = getelementptr inbounds i32, i32* %27, i64 14
%29 = bitcast i32* %28 to %struct.ip*
%30 = getelementptr inbounds %struct.ip, %struct.ip* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = mul nsw i32 %31, 4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %26, i64 %33
%35 = bitcast i32* %34 to %struct.icmp*
%36 = getelementptr inbounds %struct.icmp, %struct.icmp* %35, i32 0, i32 0
%37 = load i32, i32* %36
switch i32 %37, label %39 [
i32 0, label %38
i32 9, label %38
i32 14, label %38
i32 16, label %38
i32 18, label %38
]
38: ; preds = %24, %24, %24, %24, %24
store i32 1, i32* %3
br label %40
39: ; preds = %24
store i32 0, i32* %3
br label %40
40: ; preds = %39, %38, %23, %22
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@switch.table.isICMPRequest = [10 x i32] [i32 1, i32 0, i32 1, i32 0, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1]
define i32 @isICMPRequest(i32* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
%4 = getelementptr inbounds i32, i32* %0, i64 14
%5 = load i32, i32* %4
%6 = shl nsw i32 %5, 2
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i32, i32* %4, i64 %7
%9 = load i32, i32* %8
br i1 %3, label %13, label %10
10: ; preds = %2
%11 = add i32 %9, -8
%12 = icmp ult i32 %11, 10
br i1 %12, label %15, label %19
13: ; preds = %2
switch i32 %9, label %14 [
i32 0, label %19
i32 9, label %19
i32 14, label %19
i32 16, label %19
i32 18, label %19
]
14: ; preds = %13
br label %19
15: ; preds = %10
%16 = sext i32 %11 to i64
%17 = getelementptr inbounds [10 x i32], [10 x i32]* @switch.table.isICMPRequest, i64 0, i64 %16
%18 = load i32, i32* %17
br label %19
19: ; preds = %10, %15, %13, %13, %13, %13, %13, %14
%20 = phi i32 [ 0, %14 ], [ 1, %13 ], [ 1, %13 ], [ 1, %13 ], [ 1, %13 ], [ 1, %13 ], [ %18, %15 ], [ 0, %10 ]
ret i32 %20
}