#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 */
int /*<<< orphan*/ memcmp(char *, char *, int);
scalar_t__ strlen(char *);
int CheckSignatures(void *ptr, size_t size) {
  char *tmp = (char *)ptr;
  if (!memcmp(tmp, "(D)(M).\0", ((int)(strlen("(D)(M).\0") + 1))) &&
      !memcmp(tmp + ((int)(strlen("(D)(M).\0") + 1)) + size, "(D)(M).\0",
              ((int)(strlen("(D)(M).\0") + 1))))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<CheckSignatures>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xeb9(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    $0x1,%rax
mov    %eax,%edx
lea    0xea3(%rip),%rsi
call   1040 <memcmp@plt>
cmp    $0x0,%eax
jne    11cf <CheckSignatures+0xaf>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe86(%rip),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    $0x1,%rcx
movslq %ecx,%rcx
add    %rcx,%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xe61(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
add    $0x1,%rax
mov    %eax,%edx
lea    0xe4b(%rip),%rsi
call   1040 <memcmp@plt>
cmp    $0x0,%eax
jne    11cf <CheckSignatures+0xaf>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <CheckSignatures+0xb6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckSignatures>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rsi
mov    $0x8,%edx
call   1030 <memcmp@plt>
test   %eax,%eax
jne    114c <CheckSignatures+0x3c>
lea    (%rbx,%r14,1),%rdi
add    $0x8,%rdi
lea    0xec2(%rip),%rsi
mov    $0x8,%edx
call   1030 <memcmp@plt>
test   %eax,%eax
je     1156 <CheckSignatures+0x46>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%eax
jmp    114e <CheckSignatures+0x3e>

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

LLVM IR (-O2):
@.str = [9 x i8] c"(D)(M).\00\00"
define i32 @CheckSignatures(i8* %0, i64 %1) {
%3 = tail call i32 @memcmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 8
%7 = getelementptr inbounds i8, i8* %6, i64 %1
%8 = tail call i32 @memcmp(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%9 = icmp eq i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %5, %2
br label %11
11: ; preds = %5, %10
%12 = phi i32 [ 0, %10 ], [ 1, %5 ]
ret i32 %12
}