#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 isICMPError(const u_char *p, int source) {
  switch (((struct icmp *)(p + 14 + ((struct ip *)(p + 14))->ip_hl * 4))
              ->icmp_type) {
  case 3:
  case 4:
  case 5:
  case 11:
  case 12:
    return source;
  default:
    return !source;
  }
}


x86 assembly (clang, -O0):
<isICMPError>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%ecx
shl    $0x2,%ecx
movslq %ecx,%rcx
mov    0x38(%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
add    $0xfffffffd,%eax
sub    $0x3,%eax
jb     1144 <isICMPError+0x44>
jmp    1130 <isICMPError+0x30>
mov    -0x18(%rbp),%eax
add    $0xfffffff5,%eax
sub    $0x1,%eax
ja     114f <isICMPError+0x4f>
jmp    1144 <isICMPError+0x44>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1160 <isICMPError+0x60>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isICMPError>:
mov    %esi,%eax
movslq 0x38(%rdi),%rcx
shl    $0x4,%rcx
mov    0x38(%rdi,%rcx,1),%ecx
cmp    $0xc,%ecx
ja     111e <isICMPError+0x1e>
mov    $0x1838,%edx
bt     %ecx,%edx
jae    111e <isICMPError+0x1e>
ret
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
ret

LLVM IR (-O0):
%struct.ip = type { i32 }
%struct.icmp = type { i32 }
define i32 @isICMPError(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** %4
%7 = getelementptr inbounds i32, i32* %6, i64 14
%8 = load i32*, i32** %4
%9 = getelementptr inbounds i32, i32* %8, i64 14
%10 = bitcast i32* %9 to %struct.ip*
%11 = getelementptr inbounds %struct.ip, %struct.ip* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = mul nsw i32 %12, 4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %7, i64 %14
%16 = bitcast i32* %15 to %struct.icmp*
%17 = getelementptr inbounds %struct.icmp, %struct.icmp* %16, i32 0, i32 0
%18 = load i32, i32* %17
switch i32 %18, label %21 [
i32 3, label %19
i32 4, label %19
i32 5, label %19
i32 11, label %19
i32 12, label %19
]
19: ; preds = %2, %2, %2, %2, %2
%20 = load i32, i32* %5
store i32 %20, i32* %3
br label %26
21: ; preds = %2
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
%25 = zext i1 %24 to i32
store i32 %25, i32* %3
br label %26
26: ; preds = %21, %19
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @isICMPError(i32* nocapture %0, i32 %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 14
%4 = load i32, i32* %3
%5 = shl nsw i32 %4, 2
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i32, i32* %3, i64 %6
%8 = load i32, i32* %7
switch i32 %8, label %9 [
i32 3, label %12
i32 4, label %12
i32 5, label %12
i32 11, label %12
i32 12, label %12
]
9: ; preds = %2
%10 = icmp eq i32 %1, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %2, %2, %2, %2, %2, %9
%13 = phi i32 [ %11, %9 ], [ %1, %2 ], [ %1, %2 ], [ %1, %2 ], [ %1, %2 ], [ %1, %2 ]
ret i32 %13
}