#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__ strncmp(char const *, char *, int);
const char *FmapFind(const char *ptr, size_t size) {
  size_t i;
  for (i = 0; i < size; i += 4) {
    if (0 == strncmp(ptr, "__FMAP__", 8))
      return ptr;
    ptr += 4;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<FmapFind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1183 <FmapFind+0x73>
mov    -0x10(%rbp),%rdi
lea    0xebf(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1166 <FmapFind+0x56>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    118b <FmapFind+0x7b>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <FmapFind+0x18>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FmapFind>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rsi,%rsi
je     1152 <FmapFind+0x42>
mov    %rsi,%r12
mov    %rdi,%r14
lea    0xed5(%rip),%r15
xor    %ebx,%ebx
nopl   (%rax)
lea    (%r14,%rbx,1),%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1155 <FmapFind+0x45>
add    $0x4,%rbx
cmp    %r12,%rbx
jb     1130 <FmapFind+0x20>
xor    %r13d,%r13d
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"__FMAP__\00"
define i8* @FmapFind(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 0, i64* %6
br label %7
7: ; preds = %20, %2
%8 = load i64, i64* %6
%9 = load i64, i64* %5
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = call i64 @strncmp(i8* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%14 = icmp eq i64 0, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load i8*, i8** %4
store i8* %16, i8** %3
br label %24
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 4
store i8* %19, i8** %4
br label %20
20: ; preds = %17
%21 = load i64, i64* %6
%22 = add i64 %21, 4
store i64 %22, i64* %6
br label %7
23: ; preds = %7
store i8* null, i8** %3
br label %24
24: ; preds = %23, %15
%25 = load i8*, i8** %3
ret i8* %25
}

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