#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_kazaa(const unsigned char *payload, const int plen,
                 int payload_len) {
  if ((payload_len == plen) && (payload[plen - 2] == 0x0d) &&
      (payload[plen - 1] == 0x0a) && memcmp(payload, "GET /.hash=", 11) == 0)
    return (2 * 100);
  return 0;
}


x86 assembly (clang, -O0):
<search_kazaa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    118d <search_kazaa+0x7d>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    118d <search_kazaa+0x7d>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    118d <search_kazaa+0x7d>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0xb,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    118d <search_kazaa+0x7d>
movl   $0xc8,-0x4(%rbp)
jmp    1194 <search_kazaa+0x84>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_kazaa>:
push   %rax
cmp    %esi,%edx
jne    113c <search_kazaa+0x2c>
movslq %edx,%rax
cmpb   $0xd,-0x2(%rax,%rdi,1)
jne    113c <search_kazaa+0x2c>
cmpb   $0xa,-0x1(%rax,%rdi,1)
jne    113c <search_kazaa+0x2c>
lea    0xed3(%rip),%rsi
mov    $0xb,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     1140 <search_kazaa+0x30>
xor    %eax,%eax
pop    %rcx
ret
mov    $0xc8,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"GET /.hash=\00"
define i32 @search_kazaa(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 = load i32, i32* %6
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %34
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = sub nsw i32 %13, 2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = icmp eq i32 %18, 13
br i1 %19, label %20, label %34
20: ; preds = %11
%21 = load i8*, i8** %5
%22 = load i32, i32* %6
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %34
29: ; preds = %20
%30 = load i8*, i8** %5
%31 = call i64 @memcmp(i8* %30, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 200, i32* %4
br label %35
34: ; preds = %29, %20, %11, %3
store i32 0, i32* %4
br label %35
35: ; preds = %34, %33
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@.str = [12 x i8] c"GET /.hash=\00"
define i32 @search_kazaa(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, %1
br i1 %4, label %5, label %20
5: ; preds = %3
%6 = add nsw i32 %2, -2
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 13
br i1 %10, label %11, label %20
11: ; preds = %5
%12 = add nsw i32 %2, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%19 = icmp eq i64 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %17, %11, %5, %3
br label %21
21: ; preds = %17, %20
%22 = phi i32 [ 0, %20 ], [ 200, %17 ]
ret i32 %22
}