#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_all_dc(const unsigned char *payload, const int plen,
                   int payload_len) {
  if ((payload_len == plen) && payload[0] == 0x24 &&
      payload[plen - 1] == 0x7c) {
    const unsigned char *t = &payload[1];
    if (memcmp(t, "Lock ", 5) == 0)
      return ((5 * 100) + 1);
    if (memcmp(t, "MyNick ", 7) == 0)
      return ((5 * 100) + 38);
  }
  return 0;
}


x86 assembly (clang, -O0):
<_search_all_dc>:
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    11bf <_search_all_dc+0xaf>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x24,%eax
jne    11bf <_search_all_dc+0xaf>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7c,%eax
jne    11bf <_search_all_dc+0xaf>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe91(%rip),%rsi
mov    $0x5,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    118f <_search_all_dc+0x7f>
movl   $0x1f5,-0x4(%rbp)
jmp    11c6 <_search_all_dc+0xb6>
mov    -0x20(%rbp),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x7,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    11ba <_search_all_dc+0xaa>
movl   $0x21a,-0x4(%rbp)
jmp    11c6 <_search_all_dc+0xb6>
jmp    11bf <_search_all_dc+0xaf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_search_all_dc>:
push   %rbx
cmp    %esi,%edx
jne    115d <_search_all_dc+0x4d>
mov    %rdi,%rbx
cmpb   $0x24,(%rdi)
jne    115d <_search_all_dc+0x4d>
movslq %edx,%rax
cmpb   $0x7c,-0x1(%rax,%rbx,1)
jne    115d <_search_all_dc+0x4d>
add    $0x1,%rbx
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     1161 <_search_all_dc+0x51>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     1168 <_search_all_dc+0x58>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1f5,%eax
pop    %rbx
ret
mov    $0x21a,%eax
pop    %rbx
ret

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