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

/* Variables and functions */
int /*<<< orphan*/ LLVMFuzzerTestOneInput(int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(int /*<<< orphan*/ *, size_t, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fuzz_openFile(char *);
int /*<<< orphan*/ *malloc(size_t);
int main(int argc, char **argv) {
  FILE *fp;
  uint8_t *Data;
  size_t Size;
  if (argc == 3) {
    fuzz_openFile(argv[2]);
  } else if (argc != 2) {
    return 1;
  }
  fp = fopen(argv[1], "rb");
  if (fp == NULL) {
    return 2;
  }
  if (fseek(fp, 0L, SEEK_END) != 0) {
    fclose(fp);
    return 2;
  }
  Size = ftell(fp);
  if (Size == (size_t)-1) {
    fclose(fp);
    return 2;
  }
  if (fseek(fp, 0L, SEEK_SET) != 0) {
    fclose(fp);
    return 2;
  }
  Data = malloc(Size);
  if (Data == NULL) {
    fclose(fp);
    return 2;
  }
  if (fread(Data, Size, 1, fp) != 1) {
    fclose(fp);
    free(Data);
    return 2;
  }
  LLVMFuzzerTestOneInput(Data, Size);
  free(Data);
  fclose(fp);
  return 0;
}


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)
cmpl   $0x3,-0x8(%rbp)
jne    11c2 <main+0x32>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <fuzz_openFile@plt>
jmp    11dd <main+0x4d>
cmpl   $0x2,-0x8(%rbp)
je     11d8 <main+0x48>
movl   $0x1,-0x4(%rbp)
jmp    1333 <main+0x1a3>
jmp    11dd <main+0x4d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe14(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    120c <main+0x7c>
movl   $0x2,-0x4(%rbp)
jmp    1333 <main+0x1a3>
mov    -0x18(%rbp),%rdi
mov    0x2dd1(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <fseek@plt>
cmp    $0x0,%rax
je     1241 <main+0xb1>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    1333 <main+0x1a3>
mov    -0x18(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0xffffffffffffffff,-0x28(%rbp)
jne    126e <main+0xde>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    1333 <main+0x1a3>
mov    -0x18(%rbp),%rdi
mov    0x2d5f(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <fseek@plt>
cmp    $0x0,%rax
je     12a3 <main+0x113>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    1333 <main+0x1a3>
mov    -0x28(%rbp),%rdi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12d0 <main+0x140>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    1333 <main+0x1a3>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     130d <main+0x17d>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x2,-0x4(%rbp)
jmp    1333 <main+0x1a3>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-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
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
je     11b2 <main+0x22>
mov    $0x1,%ebp
cmp    $0x3,%edi
jne    11ef <main+0x5f>
mov    0x10(%rbx),%rdi
call   1080 <fuzz_openFile@plt>
mov    0x8(%rbx),%rdi
lea    0xe43(%rip),%rsi
call   10b0 <fopen@plt>
mov    $0x2,%ebp
test   %rax,%rax
je     11ef <main+0x5f>
mov    %rax,%rbx
mov    0x2e12(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
test   %rax,%rax
je     11fc <main+0x6c>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1070 <ftell@plt>
cmp    $0xffffffffffffffff,%rax
je     11e7 <main+0x57>
mov    %rax,%r14
mov    0x2dc4(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
test   %rax,%rax
jne    11e7 <main+0x57>
mov    %r14,%rdi
call   1090 <malloc@plt>
test   %rax,%rax
je     11e7 <main+0x57>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    126c <main+0xdc>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %ebp,%ebp
jmp    11ef <main+0x5f>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    11ef <main+0x5f>

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

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %44 [
i32 3, label %3
i32 2, label %7
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 2
%5 = load i8*, i8** %4
%6 = tail call i32 @fuzz_openFile(i8* %5)
br label %7
7: ; preds = %2, %3
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %44, label %12
12: ; preds = %7
%13 = load i32, i32* @SEEK_END
%14 = tail call i64 @fseek(i32* %10, i64 0, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = tail call i32 @fclose(i32* %10)
br label %44
18: ; preds = %12
%19 = tail call i64 @ftell(i32* %10)
%20 = icmp eq i64 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @fclose(i32* %10)
br label %44
23: ; preds = %18
%24 = load i32, i32* @SEEK_SET
%25 = tail call i64 @fseek(i32* %10, i64 0, i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %23
%28 = tail call i32 @fclose(i32* %10)
br label %44
29: ; preds = %23
%30 = tail call i32* @malloc(i64 %19)
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = tail call i32 @fclose(i32* %10)
br label %44
34: ; preds = %29
%35 = tail call i32 @fread(i32* %30, i64 %19, i32 1, i32* %10)
%36 = icmp eq i32 %35, 1
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = tail call i32 @fclose(i32* %10)
%39 = tail call i32 @free(i32* %30)
br label %44
40: ; preds = %34
%41 = tail call i32 @LLVMFuzzerTestOneInput(i32* %30, i64 %19)
%42 = tail call i32 @free(i32* %30)
%43 = tail call i32 @fclose(i32* %10)
br label %44
44: ; preds = %7, %2, %40, %37, %32, %27, %21, %16
%45 = phi i32 [ 2, %16 ], [ 2, %21 ], [ 2, %27 ], [ 2, %32 ], [ 2, %37 ], [ 0, %40 ], [ 1, %2 ], [ 2, %7 ]
ret i32 %45
}