#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 */
scalar_t__ memcmp(unsigned char const *, char *, int);
int search_apple(const unsigned char *payload, const int plen,
                 int payload_len) {
  if ((payload_len > 7) && (plen > 7) && (payload[6] == 0x0d) &&
      (payload[7] == 0x0a) && (memcmp(payload, "ajprot", 6) == 0))
    return (10 * 100);
  return 0;
}


x86 assembly (clang, -O0):
<search_apple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpl   $0x7,-0x18(%rbp)
jle    1183 <search_apple+0x73>
cmpl   $0x7,-0x14(%rbp)
jle    1183 <search_apple+0x73>
mov    -0x10(%rbp),%rax
movzbl 0x6(%rax),%eax
cmp    $0xd,%eax
jne    1183 <search_apple+0x73>
mov    -0x10(%rbp),%rax
movzbl 0x7(%rax),%eax
cmp    $0xa,%eax
jne    1183 <search_apple+0x73>
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x6,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    1183 <search_apple+0x73>
movl   $0x3e8,-0x4(%rbp)
jmp    118a <search_apple+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_apple>:
push   %rax
cmp    $0x8,%esi
jl     113d <search_apple+0x2d>
cmp    $0x8,%edx
jl     113d <search_apple+0x2d>
cmpb   $0xd,0x6(%rdi)
jne    113d <search_apple+0x2d>
cmpb   $0xa,0x7(%rdi)
jne    113d <search_apple+0x2d>
lea    0xed2(%rip),%rsi
mov    $0x6,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     1141 <search_apple+0x31>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x3e8,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"ajprot\00"
define i32 @search_apple(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = icmp sgt i32 %8, 7
br i1 %9, label %10, label %30
10: ; preds = %3
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 7
br i1 %12, label %13, label %30
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 6
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = icmp eq i32 %17, 13
br i1 %18, label %19, label %30
19: ; preds = %13
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 7
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = icmp eq i32 %23, 10
br i1 %24, label %25, label %30
25: ; preds = %19
%26 = load i8*, i8** %5
%27 = call i64 @memcmp(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 1000, i32* %4
br label %31
30: ; preds = %25, %19, %13, %10, %3
store i32 0, i32* %4
br label %31
31: ; preds = %30, %29
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@.str = [7 x i8] c"ajprot\00"
define i32 @search_apple(i8* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 7
%5 = icmp sgt i32 %1, 7
%6 = and i1 %5, %4
br i1 %6, label %7, label %18
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %0, i64 6
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 13
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %0, i64 7
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 10
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%17 = icmp eq i64 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %15, %11, %7, %3
br label %19
19: ; preds = %15, %18
%20 = phi i32 [ 0, %18 ], [ 1000, %15 ]
ret i32 %20
}