#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_gnu(const unsigned char *payload, const int plen, int payload_len) {
  if ((payload_len == plen) && (payload[plen - 2] == 0x0d) &&
      (payload[plen - 1] == 0x0a)) {
    if (memcmp(payload, "GET /get/", 9) == 0)
      return ((6 * 100) + 1);
    if (memcmp(payload, "GET /uri-res/", 13) == 0)
      return ((6 * 100) + 2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<search_gnu>:
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    11bd <search_gnu+0xad>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    11bd <search_gnu+0xad>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11bd <search_gnu+0xad>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x9,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    118d <search_gnu+0x7d>
movl   $0x259,-0x4(%rbp)
jmp    11c4 <search_gnu+0xb4>
mov    -0x10(%rbp),%rdi
lea    0xe72(%rip),%rsi
mov    $0xd,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    11b8 <search_gnu+0xa8>
movl   $0x25a,-0x4(%rbp)
jmp    11c4 <search_gnu+0xb4>
jmp    11bd <search_gnu+0xad>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_gnu>:
push   %rbx
cmp    %esi,%edx
jne    115b <search_gnu+0x4b>
mov    %rdi,%rbx
movslq %edx,%rax
cmpb   $0xd,-0x2(%rax,%rdi,1)
jne    115b <search_gnu+0x4b>
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    115b <search_gnu+0x4b>
lea    0xed0(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     115f <search_gnu+0x4f>
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
mov    $0xd,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     1166 <search_gnu+0x56>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x259,%eax
pop    %rbx
ret
mov    $0x25a,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"GET /get/\00"
@.str.1 = [14 x i8] c"GET /uri-res/\00"
define i32 @search_gnu(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 %40
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 %40
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 %40
29: ; preds = %20
%30 = load i8*, i8** %5
%31 = call i64 @memcmp(i8* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 601, i32* %4
br label %41
34: ; preds = %29
%35 = load i8*, i8** %5
%36 = call i64 @memcmp(i8* %35, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 13)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 602, i32* %4
br label %41
39: ; preds = %34
br label %40
40: ; preds = %39, %20, %11, %3
store i32 0, i32* %4
br label %41
41: ; preds = %40, %38, %33
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
@.str = [10 x i8] c"GET /get/\00"
@.str.1 = [14 x i8] c"GET /uri-res/\00"
define i32 @search_gnu(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, %1
br i1 %4, label %5, label %23
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 %23
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 %23
17: ; preds = %11
%18 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 13)
%22 = icmp eq i64 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %20, %11, %5, %3
br label %24
24: ; preds = %20, %17, %23
%25 = phi i32 [ 0, %23 ], [ 601, %17 ], [ 602, %20 ]
ret i32 %25
}