#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ LLVMFuzzerTestOneInput(unsigned char *, size_t);
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(unsigned char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  FILE *f;
  long tell_result;
  size_t n_read, len;
  unsigned char *buf;
  if (argc < 2)
    return 1;
  f = fopen(argv[1], "r");
  assert(f);
  fseek(f, 0, SEEK_END);
  tell_result = ftell(f);
  assert(tell_result >= 0);
  len = (size_t)tell_result;
  fseek(f, 0, SEEK_SET);
  buf = (unsigned char *)malloc(len);
  n_read = fread(buf, 1, len, f);
  assert(n_read == len);
  LLVMFuzzerTestOneInput(buf, len);
  free(buf);
  fclose(f);
  printf("Done!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11cc <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    12ac <main+0x10c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe25(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,%edi
call   1080 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dee(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1090 <ftell@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2da3(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <LLVMFuzzerTestOneInput@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xd62(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r14d
cmp    $0x2,%edi
jl     1267 <main+0xc7>
mov    0x8(%rsi),%rdi
lea    0xe3f(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r15
mov    %r15d,%edi
call   1080 <assert@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
mov    %r15,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r15,%rdi
call   1090 <ftell@plt>
mov    %rax,%rbp
mov    %rax,%rdi
shr    $0x3f,%rdi
xor    $0x1,%edi
call   1080 <assert@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %rbp,%rdi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %r15,%rcx
call   1050 <fread@plt>
xor    %edi,%edi
cmp    %rbp,%rax
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <LLVMFuzzerTestOneInput@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
lea    0xda0(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [7 x i8] c"Done!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 1, i32* %3
br label %55
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i32*, i32** %6
%20 = ptrtoint i32* %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32*, i32** %6
%23 = load i32, i32* @SEEK_END
%24 = call i32 @fseek(i32* %22, i32 0, i32 %23)
%25 = load i32*, i32** %6
%26 = call i64 @ftell(i32* %25)
store i64 %26, i64* %7
%27 = load i64, i64* %7
%28 = icmp sge i64 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i64, i64* %7
store i64 %31, i64* %9
%32 = load i32*, i32** %6
%33 = load i32, i32* @SEEK_SET
%34 = call i32 @fseek(i32* %32, i32 0, i32 %33)
%35 = load i64, i64* %9
%36 = call i64 @malloc(i64 %35)
%37 = inttoptr i64 %36 to i8*
store i8* %37, i8** %10
%38 = load i8*, i8** %10
%39 = load i64, i64* %9
%40 = load i32*, i32** %6
%41 = call i64 @fread(i8* %38, i32 1, i64 %39, i32* %40)
store i64 %41, i64* %8
%42 = load i64, i64* %8
%43 = load i64, i64* %9
%44 = icmp eq i64 %42, %43
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = load i8*, i8** %10
%48 = load i64, i64* %9
%49 = call i32 @LLVMFuzzerTestOneInput(i8* %47, i64 %48)
%50 = load i8*, i8** %10
%51 = call i32 @free(i8* %50)
%52 = load i32*, i32** %6
%53 = call i32 @fclose(i32* %52)
%54 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %55
55: ; preds = %14, %13
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@str = [6 x i8] c"Done!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %30, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = ptrtoint i32* %7 to i64
%9 = trunc i64 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = load i32, i32* @SEEK_END
%12 = tail call i32 @fseek(i32* %7, i32 0, i32 %11)
%13 = tail call i64 @ftell(i32* %7)
%14 = lshr i64 %13, 63
%15 = trunc i64 %14 to i32
%16 = xor i32 %15, 1
%17 = tail call i32 @assert(i32 %16)
%18 = load i32, i32* @SEEK_SET
%19 = tail call i32 @fseek(i32* %7, i32 0, i32 %18)
%20 = tail call i64 @malloc(i64 %13)
%21 = inttoptr i64 %20 to i8*
%22 = tail call i64 @fread(i8* %21, i32 1, i64 %13, i32* %7)
%23 = icmp eq i64 %22, %13
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i32 @LLVMFuzzerTestOneInput(i8* %21, i64 %13)
%27 = tail call i32 @free(i8* %21)
%28 = tail call i32 @fclose(i32* %7)
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %30
30: ; preds = %2, %4
%31 = phi i32 [ 0, %4 ], [ 1, %2 ]
ret i32 %31
}