#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 EXIT_FAILURE;
int findmft(char *, unsigned long long *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, unsigned long long);
int main(int argc, char **argv) {
  unsigned long long loc = 0;
  int r;
  while ((r = findmft(argv[1], &loc, 8)) > 0) {
    printf("\nFound at %llu\n", loc);
    loc += 8;
  }
  if (r < 0) {
    perror("Error");
    return EXIT_FAILURE;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1050 <findmft@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jle    1191 <main+0x61>
mov    -0x18(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    114e <main+0x1e>
cmpl   $0x0,-0x1c(%rbp)
jge    11b8 <main+0x88>
lea    0xe6e(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <main+0x8f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movq   $0x0,0x8(%rsp)
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
call   1050 <findmft@plt>
test   %eax,%eax
jle    1198 <main+0x68>
lea    0xe9d(%rip),%r14
lea    0x8(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
addq   $0x8,0x8(%rsp)
mov    0x8(%rbx),%rdi
mov    %r15,%rsi
mov    $0x8,%edx
call   1050 <findmft@plt>
test   %eax,%eax
jg     1170 <main+0x40>
xor    %ecx,%ecx
test   %eax,%eax
js     11aa <main+0x7a>
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe5f(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%ecx
jmp    119e <main+0x6e>

LLVM IR (-O0):
@.str = [16 x i8] c"\0AFound at %llu\0A\00"
@.str.1 = [6 x i8] c"Error\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
br label %8
8: ; preds = %14, %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @findmft(i8* %11, i64* %6, i32 8)
store i32 %12, i32* %7
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %8
%15 = load i64, i64* %6
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i64 %15)
%17 = load i64, i64* %6
%18 = add i64 %17, 8
store i64 %18, i64* %6
br label %8
19: ; preds = %8
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %3
br label %26
25: ; preds = %19
store i32 0, i32* %3
br label %26
26: ; preds = %25, %22
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [16 x i8] c"\0AFound at %llu\0A\00"
@.str.1 = [6 x i8] c"Error\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
store i64 0, i64* %3
%6 = load i8*, i8** %5
%7 = call i32 @findmft(i8* %6, i64* %3, i32 8)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %2, %9
%10 = load i64, i64* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i64 %10)
%12 = load i64, i64* %3
%13 = add i64 %12, 8
store i64 %13, i64* %3
%14 = load i8*, i8** %5
%15 = call i32 @findmft(i8* %14, i64* %3, i32 8)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %9, label %17
17: ; preds = %9, %2
%18 = phi i32 [ %7, %2 ], [ %15, %9 ]
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
br label %23
23: ; preds = %17, %20
%24 = phi i32 [ %22, %20 ], [ 0, %17 ]
ret i32 %24
}