#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*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ *malloc(size_t);
int main(int argc, char **argv) {
  FILE *fp;
  uint8_t *Data;
  size_t Size;
  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);
    return 2;
  }
  LLVMFuzzerTestOneInput(Data, Size);
  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   $0x2,-0x8(%rbp)
je     119c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    12e0 <main+0x170>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe55(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cb <main+0x5b>
movl   $0x2,-0x4(%rbp)
jmp    12e0 <main+0x170>
mov    -0x18(%rbp),%rdi
mov    0x2e12(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1080 <fseek@plt>
cmp    $0x0,%rax
je     1200 <main+0x90>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    12e0 <main+0x170>
mov    -0x18(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0xffffffffffffffff,-0x28(%rbp)
jne    122d <main+0xbd>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    12e0 <main+0x170>
mov    -0x18(%rbp),%rdi
mov    0x2da0(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1080 <fseek@plt>
cmp    $0x0,%rax
je     1262 <main+0xf2>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    12e0 <main+0x170>
mov    -0x28(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    128f <main+0x11f>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    12e0 <main+0x170>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     12c3 <main+0x153>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    12e0 <main+0x170>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <LLVMFuzzerTestOneInput@plt>
mov    -0x18(%rbp),%rdi
call   1040 <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    $0x1,%ebp
cmp    $0x2,%edi
jne    11c5 <main+0x55>
mov    0x8(%rsi),%rdi
lea    0xe74(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     11c0 <main+0x50>
mov    %rax,%rbx
mov    0x2e48(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    $0x2,%ebp
test   %rax,%rax
je     11d2 <main+0x62>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11c5 <main+0x55>
mov    $0x2,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1060 <ftell@plt>
cmp    $0xffffffffffffffff,%rax
je     11b6 <main+0x46>
mov    %rax,%r14
mov    0x2dee(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
test   %rax,%rax
jne    11b6 <main+0x46>
mov    %r14,%rdi
call   1070 <malloc@plt>
test   %rax,%rax
je     11b6 <main+0x46>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    11b6 <main+0x46>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <LLVMFuzzerTestOneInput@plt>
xor    %ebp,%ebp
jmp    11b6 <main+0x46>

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 ne i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %67
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 2, i32* %3
br label %67
20: ; preds = %12
%21 = load i32*, i32** %6
%22 = load i32, i32* @SEEK_END
%23 = call i64 @fseek(i32* %21, i64 0, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32*, i32** %6
%27 = call i32 @fclose(i32* %26)
store i32 2, i32* %3
br label %67
28: ; preds = %20
%29 = load i32*, i32** %6
%30 = call i64 @ftell(i32* %29)
store i64 %30, i64* %8
%31 = load i64, i64* %8
%32 = icmp eq i64 %31, -1
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i32*, i32** %6
%35 = call i32 @fclose(i32* %34)
store i32 2, i32* %3
br label %67
36: ; preds = %28
%37 = load i32*, i32** %6
%38 = load i32, i32* @SEEK_SET
%39 = call i64 @fseek(i32* %37, i64 0, i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i32*, i32** %6
%43 = call i32 @fclose(i32* %42)
store i32 2, i32* %3
br label %67
44: ; preds = %36
%45 = load i64, i64* %8
%46 = call i32* @malloc(i64 %45)
store i32* %46, i32** %7
%47 = load i32*, i32** %7
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i32*, i32** %6
%51 = call i32 @fclose(i32* %50)
store i32 2, i32* %3
br label %67
52: ; preds = %44
%53 = load i32*, i32** %7
%54 = load i64, i64* %8
%55 = load i32*, i32** %6
%56 = call i32 @fread(i32* %53, i64 %54, i32 1, i32* %55)
%57 = icmp ne i32 %56, 1
br i1 %57, label %58, label %61
58: ; preds = %52
%59 = load i32*, i32** %6
%60 = call i32 @fclose(i32* %59)
store i32 2, i32* %3
br label %67
61: ; preds = %52
%62 = load i32*, i32** %7
%63 = load i64, i64* %8
%64 = call i32 @LLVMFuzzerTestOneInput(i32* %62, i64 %63)
%65 = load i32*, i32** %6
%66 = call i32 @fclose(i32* %65)
store i32 0, i32* %3
br label %67
67: ; preds = %61, %58, %49, %41, %33, %25, %19, %11
%68 = load i32, i32* %3
ret i32 %68
}

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) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %31
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 ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %31, label %9
9: ; preds = %4
%10 = load i32, i32* @SEEK_END
%11 = tail call i64 @fseek(i32* %7, i64 0, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = tail call i64 @ftell(i32* %7)
%15 = icmp eq i64 %14, -1
br i1 %15, label %28, label %16
16: ; preds = %13
%17 = load i32, i32* @SEEK_SET
%18 = tail call i64 @fseek(i32* %7, i64 0, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = tail call i32* @malloc(i64 %14)
%22 = icmp eq i32* %21, null
br i1 %22, label %28, label %23
23: ; preds = %20
%24 = tail call i32 @fread(i32* %21, i64 %14, i32 1, i32* %7)
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @LLVMFuzzerTestOneInput(i32* %21, i64 %14)
br label %28
28: ; preds = %23, %20, %16, %13, %9, %26
%29 = phi i32 [ 0, %26 ], [ 2, %9 ], [ 2, %13 ], [ 2, %16 ], [ 2, %20 ], [ 2, %23 ]
%30 = tail call i32 @fclose(i32* %7)
br label %31
31: ; preds = %28, %4, %2
%32 = phi i32 [ 1, %2 ], [ 2, %4 ], [ %29, %28 ]
ret i32 %32
}