#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 */
unsigned int PCAP32(unsigned int, unsigned char const *);
unsigned smells_like_valid_packet(const unsigned char *px, unsigned length,
                                  unsigned byte_order, unsigned link_type) {
  unsigned secs, usecs, original_length, captured_length;
  if (length < 16)
    return 0;
  secs = PCAP32(byte_order, px + 0);
  usecs = PCAP32(byte_order, px + 4);
  captured_length = PCAP32(byte_order, px + 8);
  original_length = PCAP32(byte_order, px + 12);
  if (secs > 0x50000000)
    return 0;
  if (secs < 0x26000000)
    return 0;
  if (usecs > 1000000)
    return 0;
  if (captured_length > 10000)
    return 0;
  if (captured_length < 16)
    return 0;
  if (original_length < captured_length)
    return 0;
  if (original_length > 10000)
    return 0;
  if (captured_length + 16 < length) {
    unsigned secs2, usecs2, original_length2, captured_length2;
    const unsigned char *px2 = px + captured_length + 16;
    secs2 = PCAP32(byte_order, px2 + 0);
    usecs2 = PCAP32(byte_order, px2 + 4);
    captured_length2 = PCAP32(byte_order, px2 + 8);
    original_length2 = PCAP32(byte_order, px2 + 12);
    if (secs2 > 0x50000000)
      return 0;
    if (secs2 < 0x26000000)
      return 0;
    if (usecs2 > 1000000)
      return 0;
    if (captured_length2 > 10000)
      return 0;
    if (captured_length2 < 16)
      return 0;
    if (original_length2 < captured_length2)
      return 0;
    if (original_length2 > 10000)
      return 0;
    return 1;
  } else
    switch (link_type) {
    case 1:
      if (px[12] == 0x08 && px[13] == 0x00 && px[13] == 0x45)
        return 1;
    }
  return 0;
}


x86 assembly (clang, -O0):
<smells_like_valid_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x10,-0x14(%rbp)
jae    113b <smells_like_valid_packet+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <PCAP32@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x4,%rsi
call   1030 <PCAP32@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1030 <PCAP32@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0xc,%rsi
call   1030 <PCAP32@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x50000000,-0x20(%rbp)
jbe    119c <smells_like_valid_packet+0x8c>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
cmpl   $0x26000000,-0x20(%rbp)
jae    11b5 <smells_like_valid_packet+0xa5>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
cmpl   $0xf4240,-0x24(%rbp)
jbe    11ce <smells_like_valid_packet+0xbe>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
cmpl   $0x2710,-0x2c(%rbp)
jbe    11e7 <smells_like_valid_packet+0xd7>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
cmpl   $0x10,-0x2c(%rbp)
jae    11fd <smells_like_valid_packet+0xed>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jae    1215 <smells_like_valid_packet+0x105>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
cmpl   $0x2710,-0x28(%rbp)
jbe    122e <smells_like_valid_packet+0x11e>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
mov    -0x2c(%rbp),%eax
add    $0x10,%eax
cmp    -0x14(%rbp),%eax
jae    134e <smells_like_valid_packet+0x23e>
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    %rcx,%rax
add    $0x10,%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x48(%rbp),%rsi
call   1030 <PCAP32@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x48(%rbp),%rsi
add    $0x4,%rsi
call   1030 <PCAP32@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x48(%rbp),%rsi
add    $0x8,%rsi
call   1030 <PCAP32@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x48(%rbp),%rsi
add    $0xc,%rsi
call   1030 <PCAP32@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x50000000,-0x30(%rbp)
jbe    12b0 <smells_like_valid_packet+0x1a0>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
cmpl   $0x26000000,-0x30(%rbp)
jae    12c9 <smells_like_valid_packet+0x1b9>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
cmpl   $0xf4240,-0x34(%rbp)
jbe    12e2 <smells_like_valid_packet+0x1d2>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
cmpl   $0x2710,-0x3c(%rbp)
jbe    12fb <smells_like_valid_packet+0x1eb>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
cmpl   $0x10,-0x3c(%rbp)
jae    1311 <smells_like_valid_packet+0x201>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
mov    -0x38(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jae    1329 <smells_like_valid_packet+0x219>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
cmpl   $0x2710,-0x38(%rbp)
jbe    1342 <smells_like_valid_packet+0x232>
movl   $0x0,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
movl   $0x1,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
jne    13a3 <smells_like_valid_packet+0x293>
jmp    135f <smells_like_valid_packet+0x24f>
mov    -0x10(%rbp),%rax
movzbl 0xc(%rax),%eax
cmp    $0x8,%eax
jne    139e <smells_like_valid_packet+0x28e>
mov    -0x10(%rbp),%rax
movzbl 0xd(%rax),%eax
cmp    $0x0,%eax
jne    139e <smells_like_valid_packet+0x28e>
mov    -0x10(%rbp),%rax
movzbl 0xd(%rax),%eax
cmp    $0x45,%eax
jne    139e <smells_like_valid_packet+0x28e>
movl   $0x1,-0x4(%rbp)
jmp    13af <smells_like_valid_packet+0x29f>
jmp    13a3 <smells_like_valid_packet+0x293>
jmp    13a8 <smells_like_valid_packet+0x298>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smells_like_valid_packet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ecx,%ecx
cmp    $0x10,%esi
jb     1245 <smells_like_valid_packet+0x135>
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%rbx
mov    %edx,%edi
mov    %rbx,%rsi
call   1030 <PCAP32@plt>
mov    %eax,%r14d
lea    0x4(%rbx),%rsi
mov    %r12d,%edi
call   1030 <PCAP32@plt>
mov    %eax,%r13d
lea    0x8(%rbx),%rsi
mov    %r12d,%edi
call   1030 <PCAP32@plt>
mov    %eax,%ebp
lea    0xc(%rbx),%rsi
mov    %r12d,%edi
call   1030 <PCAP32@plt>
add    $0xda000000,%r14d
cmp    $0x2a000000,%r14d
ja     1243 <smells_like_valid_packet+0x133>
cmp    $0xf4240,%r13d
ja     1243 <smells_like_valid_packet+0x133>
cmp    $0x2710,%ebp
ja     1243 <smells_like_valid_packet+0x133>
cmp    $0x10,%ebp
jb     1243 <smells_like_valid_packet+0x133>
cmp    %ebp,%eax
jb     1243 <smells_like_valid_packet+0x133>
cmp    $0x2710,%eax
ja     1243 <smells_like_valid_packet+0x133>
lea    0x10(%rbp),%eax
cmp    %r15d,%eax
jae    1243 <smells_like_valid_packet+0x133>
mov    %ebp,%ebp
lea    (%rbx,%rbp,1),%rsi
add    $0x10,%rsi
mov    %r12d,%edi
call   1030 <PCAP32@plt>
mov    %eax,%r13d
lea    (%rbx,%rbp,1),%rsi
add    $0x14,%rsi
mov    %r12d,%edi
call   1030 <PCAP32@plt>
mov    %eax,%r15d
lea    (%rbx,%rbp,1),%rsi
add    $0x18,%rsi
mov    %r12d,%edi
call   1030 <PCAP32@plt>
mov    %eax,%r14d
lea    (%rbx,%rbp,1),%rsi
add    $0x1c,%rsi
mov    %r12d,%edi
call   1030 <PCAP32@plt>
add    $0xafffffff,%r13d
cmp    $0xd5ffffff,%r13d
jb     1243 <smells_like_valid_packet+0x133>
cmp    $0xf4240,%r15d
mov    $0x0,%ecx
ja     1245 <smells_like_valid_packet+0x135>
cmp    $0x2710,%r14d
ja     1245 <smells_like_valid_packet+0x135>
cmp    $0x10,%r14d
jb     1245 <smells_like_valid_packet+0x135>
cmp    %r14d,%eax
jb     1245 <smells_like_valid_packet+0x135>
xor    %ecx,%ecx
cmp    $0x2711,%eax
setb   %cl
jmp    1245 <smells_like_valid_packet+0x135>
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @smells_like_valid_packet(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%19 = load i32, i32* %7
%20 = icmp ult i32 %19, 16
br i1 %20, label %21, label %22
21: ; preds = %4
store i32 0, i32* %5
br label %147
22: ; preds = %4
%23 = load i32, i32* %8
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = call i32 @PCAP32(i32 %23, i8* %25)
store i32 %26, i32* %10
%27 = load i32, i32* %8
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i64 4
%30 = call i32 @PCAP32(i32 %27, i8* %29)
store i32 %30, i32* %11
%31 = load i32, i32* %8
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i64 8
%34 = call i32 @PCAP32(i32 %31, i8* %33)
store i32 %34, i32* %13
%35 = load i32, i32* %8
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i64 12
%38 = call i32 @PCAP32(i32 %35, i8* %37)
store i32 %38, i32* %12
%39 = load i32, i32* %10
%40 = icmp ugt i32 %39, 1342177280
br i1 %40, label %41, label %42
41: ; preds = %22
store i32 0, i32* %5
br label %147
42: ; preds = %22
%43 = load i32, i32* %10
%44 = icmp ult i32 %43, 637534208
br i1 %44, label %45, label %46
45: ; preds = %42
store i32 0, i32* %5
br label %147
46: ; preds = %42
%47 = load i32, i32* %11
%48 = icmp ugt i32 %47, 1000000
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 0, i32* %5
br label %147
50: ; preds = %46
%51 = load i32, i32* %13
%52 = icmp ugt i32 %51, 10000
br i1 %52, label %53, label %54
53: ; preds = %50
store i32 0, i32* %5
br label %147
54: ; preds = %50
%55 = load i32, i32* %13
%56 = icmp ult i32 %55, 16
br i1 %56, label %57, label %58
57: ; preds = %54
store i32 0, i32* %5
br label %147
58: ; preds = %54
%59 = load i32, i32* %12
%60 = load i32, i32* %13
%61 = icmp ult i32 %59, %60
br i1 %61, label %62, label %63
62: ; preds = %58
store i32 0, i32* %5
br label %147
63: ; preds = %58
%64 = load i32, i32* %12
%65 = icmp ugt i32 %64, 10000
br i1 %65, label %66, label %67
66: ; preds = %63
store i32 0, i32* %5
br label %147
67: ; preds = %63
%68 = load i32, i32* %13
%69 = add i32 %68, 16
%70 = load i32, i32* %7
%71 = icmp ult i32 %69, %70
br i1 %71, label %72, label %123
72: ; preds = %67
%73 = load i8*, i8** %6
%74 = load i32, i32* %13
%75 = zext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
%77 = getelementptr inbounds i8, i8* %76, i64 16
store i8* %77, i8** %18
%78 = load i32, i32* %8
%79 = load i8*, i8** %18
%80 = getelementptr inbounds i8, i8* %79, i64 0
%81 = call i32 @PCAP32(i32 %78, i8* %80)
store i32 %81, i32* %14
%82 = load i32, i32* %8
%83 = load i8*, i8** %18
%84 = getelementptr inbounds i8, i8* %83, i64 4
%85 = call i32 @PCAP32(i32 %82, i8* %84)
store i32 %85, i32* %15
%86 = load i32, i32* %8
%87 = load i8*, i8** %18
%88 = getelementptr inbounds i8, i8* %87, i64 8
%89 = call i32 @PCAP32(i32 %86, i8* %88)
store i32 %89, i32* %17
%90 = load i32, i32* %8
%91 = load i8*, i8** %18
%92 = getelementptr inbounds i8, i8* %91, i64 12
%93 = call i32 @PCAP32(i32 %90, i8* %92)
store i32 %93, i32* %16
%94 = load i32, i32* %14
%95 = icmp ugt i32 %94, 1342177280
br i1 %95, label %96, label %97
96: ; preds = %72
store i32 0, i32* %5
br label %147
97: ; preds = %72
%98 = load i32, i32* %14
%99 = icmp ult i32 %98, 637534208
br i1 %99, label %100, label %101
100: ; preds = %97
store i32 0, i32* %5
br label %147
101: ; preds = %97
%102 = load i32, i32* %15
%103 = icmp ugt i32 %102, 1000000
br i1 %103, label %104, label %105
104: ; preds = %101
store i32 0, i32* %5
br label %147
105: ; preds = %101
%106 = load i32, i32* %17
%107 = icmp ugt i32 %106, 10000
br i1 %107, label %108, label %109
108: ; preds = %105
store i32 0, i32* %5
br label %147
109: ; preds = %105
%110 = load i32, i32* %17
%111 = icmp ult i32 %110, 16
br i1 %111, label %112, label %113
112: ; preds = %109
store i32 0, i32* %5
br label %147
113: ; preds = %109
%114 = load i32, i32* %16
%115 = load i32, i32* %17
%116 = icmp ult i32 %114, %115
br i1 %116, label %117, label %118
117: ; preds = %113
store i32 0, i32* %5
br label %147
118: ; preds = %113
%119 = load i32, i32* %16
%120 = icmp ugt i32 %119, 10000
br i1 %120, label %121, label %122
121: ; preds = %118
store i32 0, i32* %5
br label %147
122: ; preds = %118
store i32 1, i32* %5
br label %147
123: ; preds = %67
%124 = load i32, i32* %9
switch i32 %124, label %145 [
i32 1, label %125
]
125: ; preds = %123
%126 = load i8*, i8** %6
%127 = getelementptr inbounds i8, i8* %126, i64 12
%128 = load i8, i8* %127
%129 = zext i8 %128 to i32
%130 = icmp eq i32 %129, 8
br i1 %130, label %131, label %144
131: ; preds = %125
%132 = load i8*, i8** %6
%133 = getelementptr inbounds i8, i8* %132, i64 13
%134 = load i8, i8* %133
%135 = zext i8 %134 to i32
%136 = icmp eq i32 %135, 0
br i1 %136, label %137, label %144
137: ; preds = %131
%138 = load i8*, i8** %6
%139 = getelementptr inbounds i8, i8* %138, i64 13
%140 = load i8, i8* %139
%141 = zext i8 %140 to i32
%142 = icmp eq i32 %141, 69
br i1 %142, label %143, label %144
143: ; preds = %137
store i32 1, i32* %5
br label %147
144: ; preds = %137, %131, %125
br label %145
145: ; preds = %144, %123
br label %146
146: ; preds = %145
store i32 0, i32* %5
br label %147
147: ; preds = %146, %143, %122, %121, %117, %112, %108, %104, %100, %96, %66, %62, %57, %53, %49, %45, %41, %21
%148 = load i32, i32* %5
ret i32 %148
}

LLVM IR (-O2):
define i32 @smells_like_valid_packet(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp ult i32 %1, 16
br i1 %5, label %53, label %6
6: ; preds = %4
%7 = tail call i32 @PCAP32(i32 %2, i8* %0)
%8 = getelementptr inbounds i8, i8* %0, i64 4
%9 = tail call i32 @PCAP32(i32 %2, i8* %8)
%10 = getelementptr inbounds i8, i8* %0, i64 8
%11 = tail call i32 @PCAP32(i32 %2, i8* %10)
%12 = getelementptr inbounds i8, i8* %0, i64 12
%13 = tail call i32 @PCAP32(i32 %2, i8* %12)
%14 = add i32 %7, -637534208
%15 = icmp ult i32 %14, 704643073
%16 = icmp ult i32 %9, 1000001
%17 = select i1 %15, i1 %16, i1 false
%18 = icmp ult i32 %11, 10001
%19 = select i1 %17, i1 %18, i1 false
%20 = icmp ugt i32 %11, 15
%21 = select i1 %19, i1 %20, i1 false
%22 = icmp uge i32 %13, %11
%23 = select i1 %21, i1 %22, i1 false
%24 = icmp ult i32 %13, 10001
%25 = select i1 %23, i1 %24, i1 false
%26 = add i32 %11, 16
%27 = icmp ult i32 %26, %1
%28 = select i1 %25, i1 %27, i1 false
br i1 %28, label %29, label %53
29: ; preds = %6
%30 = zext i32 %11 to i64
%31 = getelementptr inbounds i8, i8* %0, i64 %30
%32 = getelementptr inbounds i8, i8* %31, i64 16
%33 = tail call i32 @PCAP32(i32 %2, i8* %32)
%34 = getelementptr inbounds i8, i8* %32, i64 4
%35 = tail call i32 @PCAP32(i32 %2, i8* %34)
%36 = getelementptr inbounds i8, i8* %32, i64 8
%37 = tail call i32 @PCAP32(i32 %2, i8* %36)
%38 = getelementptr inbounds i8, i8* %32, i64 12
%39 = tail call i32 @PCAP32(i32 %2, i8* %38)
%40 = add i32 %33, -1342177281
%41 = icmp ult i32 %40, -704643073
%42 = icmp ugt i32 %35, 1000000
%43 = select i1 %41, i1 true, i1 %42
%44 = icmp ugt i32 %37, 10000
%45 = select i1 %43, i1 true, i1 %44
%46 = icmp ult i32 %37, 16
%47 = select i1 %45, i1 true, i1 %46
%48 = icmp ult i32 %39, %37
%49 = select i1 %47, i1 true, i1 %48
br i1 %49, label %53, label %50
50: ; preds = %29
%51 = icmp ult i32 %39, 10001
%52 = zext i1 %51 to i32
br label %53
53: ; preds = %29, %50, %6, %4
%54 = phi i32 [ 0, %4 ], [ 0, %6 ], [ 0, %29 ], [ %52, %50 ]
ret i32 %54
}