#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*/ LLVMFuzzerInitialize(int *, char ***);
int LLVMFuzzerTestOneInput(void *, int);
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(void *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
scalar_t__ ftell(int /*<<< orphan*/ *);
void *malloc(int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  LLVMFuzzerInitialize(&argc, &argv);
  if (argc < 2) {
    return LLVMFuzzerTestOneInput(" ", 1);
  } else {
    int nRet = 0;
    void *buf = NULL;
    int nLen = 0;
    FILE *f = fopen(argv[1], "rb");
    if (!f) {
      fprintf(stderr, "%s does not exist.\n", argv[1]);
      exit(1);
    }
    fseek(f, 0, SEEK_END);
    nLen = (int)ftell(f);
    fseek(f, 0, SEEK_SET);
    buf = malloc(nLen);
    if (!buf) {
      fprintf(stderr, "malloc failed.\n");
      fclose(f);
      exit(1);
    }
    if (fread(buf, nLen, 1, f) != 1) {
      fprintf(stderr, "fread failed.\n");
      fclose(f);
      free(buf);
      exit(1);
    }
    fclose(f);
    nRet = LLVMFuzzerTestOneInput(buf, nLen);
    free(buf);
    return nRet;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1090 <LLVMFuzzerInitialize@plt>
cmpl   $0x2,-0x8(%rbp)
jge    11f6 <main+0x46>
lea    0xe1c(%rip),%rdi
mov    $0x1,%esi
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    %eax,-0x4(%rbp)
jmp    1345 <main+0x195>
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde7(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1258 <main+0xa8>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    0x2d85(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2d4d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x24(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12cd <main+0x11d>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
lea    0xd66(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     131e <main+0x16e>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
lea    0xd2e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,0xc(%rsp)
mov    %rsi,0x10(%rsp)
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1090 <LLVMFuzzerInitialize@plt>
cmpl   $0x1,0xc(%rsp)
jg     11f1 <main+0x41>
lea    0xe20(%rip),%rdi
mov    $0x1,%esi
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    %eax,%ebp
jmp    1288 <main+0xd8>
mov    0x10(%rsp),%rax
mov    0x8(%rax),%rdi
lea    0xe01(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1295 <main+0xe5>
mov    %rax,%r14
mov    0x2dcf(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r14,%rdi
call   1080 <ftell@plt>
mov    %rax,%r15
mov    0x2d99(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r15d,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     12bf <main+0x10f>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15d,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    12e8 <main+0x138>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rsp),%rax
mov    0x8(%rax),%rdx
lea    0xd57(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xd4a(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
lea    0xd31(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [20 x i8] c"%s does not exist.\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [16 x i8] c"malloc failed.\0A\00"
@.str.4 = [15 x i8] c"fread failed.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @LLVMFuzzerInitialize(i32* %4, i8*** %5)
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @LLVMFuzzerTestOneInput(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
store i32 %14, i32* %3
br label %72
15: ; preds = %2
store i32 0, i32* %6
store i8* null, i8** %7
store i32 0, i32* %8
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %9
%20 = load i32*, i32** %9
%21 = icmp ne i32* %20, null
br i1 %21, label %29, label %22
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %15
%30 = load i32*, i32** %9
%31 = load i32, i32* @SEEK_END
%32 = call i32 @fseek(i32* %30, i32 0, i32 %31)
%33 = load i32*, i32** %9
%34 = call i64 @ftell(i32* %33)
%35 = trunc i64 %34 to i32
store i32 %35, i32* %8
%36 = load i32*, i32** %9
%37 = load i32, i32* @SEEK_SET
%38 = call i32 @fseek(i32* %36, i32 0, i32 %37)
%39 = load i32, i32* %8
%40 = call i8* @malloc(i32 %39)
store i8* %40, i8** %7
%41 = load i8*, i8** %7
%42 = icmp ne i8* %41, null
br i1 %42, label %49, label %43
43: ; preds = %29
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%46 = load i32*, i32** %9
%47 = call i32 @fclose(i32* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %29
%50 = load i8*, i8** %7
%51 = load i32, i32* %8
%52 = load i32*, i32** %9
%53 = call i32 @fread(i8* %50, i32 %51, i32 1, i32* %52)
%54 = icmp ne i32 %53, 1
br i1 %54, label %55, label %63
55: ; preds = %49
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%58 = load i32*, i32** %9
%59 = call i32 @fclose(i32* %58)
%60 = load i8*, i8** %7
%61 = call i32 @free(i8* %60)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %49
%64 = load i32*, i32** %9
%65 = call i32 @fclose(i32* %64)
%66 = load i8*, i8** %7
%67 = load i32, i32* %8
%68 = call i32 @LLVMFuzzerTestOneInput(i8* %66, i32 %67)
store i32 %68, i32* %6
%69 = load i8*, i8** %7
%70 = call i32 @free(i8* %69)
%71 = load i32, i32* %6
store i32 %71, i32* %3
br label %72
72: ; preds = %63, %13
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [20 x i8] c"%s does not exist.\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [16 x i8] c"malloc failed.\0A\00"
@.str.4 = [15 x i8] c"fread failed.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%5 = call i32 @LLVMFuzzerInitialize(i32* %3, i8*** %4)
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @LLVMFuzzerTestOneInput(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %50
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %10
%24 = load i32, i32* @SEEK_END
%25 = call i32 @fseek(i32* %14, i32 0, i32 %24)
%26 = call i64 @ftell(i32* %14)
%27 = trunc i64 %26 to i32
%28 = load i32, i32* @SEEK_SET
%29 = call i32 @fseek(i32* %14, i32 0, i32 %28)
%30 = call i8* @malloc(i32 %27)
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %37
32: ; preds = %23
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 @fclose(i32* %14)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %23
%38 = call i32 @fread(i8* %30, i32 %27, i32 1, i32* %14)
%39 = icmp eq i32 %38, 1
br i1 %39, label %46, label %40
40: ; preds = %37
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%43 = call i32 @fclose(i32* %14)
%44 = call i32 @free(i8* %30)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %37
%47 = call i32 @fclose(i32* %14)
%48 = call i32 @LLVMFuzzerTestOneInput(i8* %30, i32 %27)
%49 = call i32 @free(i8* %30)
br label %50
50: ; preds = %46, %8
%51 = phi i32 [ %9, %8 ], [ %48, %46 ]
ret i32 %51
}