#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*/ *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);
    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   $0x2,-0x8(%rbp)
je     11ac <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    1302 <main+0x182>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe45(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11db <main+0x5b>
movl   $0x2,-0x4(%rbp)
jmp    1302 <main+0x182>
mov    -0x18(%rbp),%rdi
mov    0x2e02(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
cmp    $0x0,%rax
je     1210 <main+0x90>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    1302 <main+0x182>
mov    -0x18(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0xffffffffffffffff,-0x28(%rbp)
jne    123d <main+0xbd>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    1302 <main+0x182>
mov    -0x18(%rbp),%rdi
mov    0x2d90(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
cmp    $0x0,%rax
je     1272 <main+0xf2>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    1302 <main+0x182>
mov    -0x28(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    129f <main+0x11f>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x2,-0x4(%rbp)
jmp    1302 <main+0x182>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     12dc <main+0x15c>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x2,-0x4(%rbp)
jmp    1302 <main+0x182>
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   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%ebx
cmp    $0x2,%edi
jne    11cf <main+0x4f>
mov    0x8(%rsi),%rdi
lea    0xe63(%rip),%rsi
call   10a0 <fopen@plt>
mov    $0x2,%ebx
test   %rax,%rax
je     11cf <main+0x4f>
mov    %rax,%r14
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
test   %rax,%rax
je     11dd <main+0x5d>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
call   1070 <ftell@plt>
cmp    $0xffffffffffffffff,%rax
je     11c7 <main+0x47>
mov    %rax,%r15
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
test   %rax,%rax
jne    11c7 <main+0x47>
mov    %r15,%rdi
call   1080 <malloc@plt>
test   %rax,%rax
je     11c7 <main+0x47>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    124d <main+0xcd>
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %ebx,%ebx
jmp    11cf <main+0x4f>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r12,%rdi
call   1030 <free@plt>
jmp    11cf <main+0x4f>

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 %71
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 %71
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 %71
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 %71
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 %71
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 %71
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 %63
58: ; preds = %52
%59 = load i32*, i32** %6
%60 = call i32 @fclose(i32* %59)
%61 = load i32*, i32** %7
%62 = call i32 @free(i32* %61)
store i32 2, i32* %3
br label %71
63: ; preds = %52
%64 = load i32*, i32** %7
%65 = load i64, i64* %8
%66 = call i32 @LLVMFuzzerTestOneInput(i32* %64, i64 %65)
%67 = load i32*, i32** %7
%68 = call i32 @free(i32* %67)
%69 = load i32*, i32** %6
%70 = call i32 @fclose(i32* %69)
store i32 0, i32* %3
br label %71
71: ; preds = %63, %58, %49, %41, %33, %25, %19, %11
%72 = load i32, i32* %3
ret i32 %72
}

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 %41
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 %41, 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 %15, label %13
13: ; preds = %9
%14 = tail call i32 @fclose(i32* %7)
br label %41
15: ; preds = %9
%16 = tail call i64 @ftell(i32* %7)
%17 = icmp eq i64 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @fclose(i32* %7)
br label %41
20: ; preds = %15
%21 = load i32, i32* @SEEK_SET
%22 = tail call i64 @fseek(i32* %7, i64 0, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = tail call i32 @fclose(i32* %7)
br label %41
26: ; preds = %20
%27 = tail call i32* @malloc(i64 %16)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 @fclose(i32* %7)
br label %41
31: ; preds = %26
%32 = tail call i32 @fread(i32* %27, i64 %16, i32 1, i32* %7)
%33 = icmp eq i32 %32, 1
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = tail call i32 @fclose(i32* %7)
%36 = tail call i32 @free(i32* %27)
br label %41
37: ; preds = %31
%38 = tail call i32 @LLVMFuzzerTestOneInput(i32* %27, i64 %16)
%39 = tail call i32 @free(i32* %27)
%40 = tail call i32 @fclose(i32* %7)
br label %41
41: ; preds = %4, %2, %37, %34, %29, %24, %18, %13
%42 = phi i32 [ 2, %13 ], [ 2, %18 ], [ 2, %24 ], [ 2, %29 ], [ 2, %34 ], [ 0, %37 ], [ 1, %2 ], [ 2, %4 ]
ret i32 %42
}