#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);
size_t fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, 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*/);
size_t ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int i;
  fprintf(stderr, "StandaloneFuzzTargetMain: running %d inputs\n", argc - 1);
  for (i = 1; i < argc; i++) {
    size_t len, n_read, err;
    unsigned char *buf;
    FILE *f = fopen(argv[i], "rb+");
    if (!f) {
      fprintf(stderr, "Skipping: %s\n", argv[i]);
      continue;
    }
    fprintf(stderr, "Running: %s %s\n", argv[0], argv[i]);
    fseek(f, 0, SEEK_END);
    len = ftell(f);
    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);
    err = fclose(f);
    assert(err == 0);
    (void)err;
    fprintf(stderr, "Done:    %s: (%d bytes)\n", argv[i], (int)n_read);
  }
  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)
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    133c <main+0x19c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe34(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1235 <main+0x95>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    132e <main+0x18e>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    0x2d7e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x40(%rbp),%rdi
call   1090 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x40(%rbp),%rdi
mov    0x2d45(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
lea    0xd28(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11da <main+0x3a>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%ebp
mov    0x2e21(%rip),%rbx
mov    (%rbx),%edi
lea    -0x1(%rbp),%edx
lea    0xe3d(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
cmp    $0x2,%ebp
jl     12ef <main+0x14f>
mov    %ebp,%eax
mov    %rax,(%rsp)
mov    $0x1,%r14d
jmp    12c0 <main+0x120>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rax,%rbp
mov    (%r12),%rdx
mov    (%r12,%r14,8),%rcx
lea    0xe3d(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %rbp,%rdi
call   1090 <ftell@plt>
mov    %r12,%rbx
mov    %rax,%r12
mov    0x2d9f(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r12,%rdi
call   10a0 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rax,%r15
xor    %edi,%edi
cmp    %r12,%rax
sete   %dil
call   1070 <assert@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%r12
mov    0x2d5c(%rip),%rbx
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    (%rbx),%edi
mov    (%r12,%r14,8),%rdx
lea    0xda3(%rip),%rsi
mov    %r15d,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
add    $0x1,%r14
cmp    %r14,(%rsp)
je     12ef <main+0x14f>
mov    (%r12,%r14,8),%rdi
lea    0xd62(%rip),%rsi
call   10c0 <fopen@plt>
mov    (%rbx),%edi
test   %rax,%rax
jne    11f0 <main+0x50>
mov    (%r12,%r14,8),%rdx
lea    0xd4b(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    12b6 <main+0x116>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [45 x i8] c"StandaloneFuzzTargetMain: running %d inputs\0A\00"
@.str.1 = [4 x i8] c"rb+\00"
@.str.2 = [14 x i8] c"Skipping: %s\0A\00"
@.str.3 = [16 x i8] c"Running: %s %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [25 x i8] c"Done: %s: (%d bytes)\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*
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @stderr
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 1, i32* %6
br label %16
16: ; preds = %89, %2
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %92
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %11
%27 = load i32*, i32** %11
%28 = icmp ne i32* %27, null
br i1 %28, label %37, label %29
29: ; preds = %20
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %35)
br label %89
37: ; preds = %20
%38 = load i32, i32* @stderr
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = load i8**, i8*** %5
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %41, i8* %46)
%48 = load i32*, i32** %11
%49 = load i32, i32* @SEEK_END
%50 = call i32 @fseek(i32* %48, i32 0, i32 %49)
%51 = load i32*, i32** %11
%52 = call i64 @ftell(i32* %51)
store i64 %52, i64* %7
%53 = load i32*, i32** %11
%54 = load i32, i32* @SEEK_SET
%55 = call i32 @fseek(i32* %53, i32 0, i32 %54)
%56 = load i64, i64* %7
%57 = call i64 @malloc(i64 %56)
%58 = inttoptr i64 %57 to i8*
store i8* %58, i8** %10
%59 = load i8*, i8** %10
%60 = load i64, i64* %7
%61 = load i32*, i32** %11
%62 = call i64 @fread(i8* %59, i32 1, i64 %60, i32* %61)
store i64 %62, i64* %8
%63 = load i64, i64* %8
%64 = load i64, i64* %7
%65 = icmp eq i64 %63, %64
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
%68 = load i8*, i8** %10
%69 = load i64, i64* %7
%70 = call i32 @LLVMFuzzerTestOneInput(i8* %68, i64 %69)
%71 = load i8*, i8** %10
%72 = call i32 @free(i8* %71)
%73 = load i32*, i32** %11
%74 = call i64 @fclose(i32* %73)
store i64 %74, i64* %9
%75 = load i64, i64* %9
%76 = icmp eq i64 %75, 0
%77 = zext i1 %76 to i32
%78 = call i32 @assert(i32 %77)
%79 = load i64, i64* %9
%80 = load i32, i32* @stderr
%81 = load i8**, i8*** %5
%82 = load i32, i32* %6
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = load i64, i64* %8
%87 = trunc i64 %86 to i32
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %85, i32 %87)
br label %89
89: ; preds = %37, %29
%90 = load i32, i32* %6
%91 = add nsw i32 %90, 1
store i32 %91, i32* %6
br label %16
92: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [45 x i8] c"StandaloneFuzzTargetMain: running %d inputs\0A\00"
@.str.1 = [4 x i8] c"rb+\00"
@.str.2 = [14 x i8] c"Skipping: %s\0A\00"
@.str.3 = [16 x i8] c"Running: %s %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [25 x i8] c"Done: %s: (%d bytes)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @stderr
%4 = add nsw i32 %0, -1
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %47
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %44
%10 = phi i64 [ 1, %7 ], [ %45, %44 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
%15 = load i32, i32* @stderr
br i1 %14, label %16, label %19
16: ; preds = %9
%17 = load i8*, i8** %11
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %44
19: ; preds = %9
%20 = load i8*, i8** %1
%21 = load i8*, i8** %11
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %20, i8* %21)
%23 = load i32, i32* @SEEK_END
%24 = tail call i32 @fseek(i32* %13, i32 0, i32 %23)
%25 = tail call i64 @ftell(i32* %13)
%26 = load i32, i32* @SEEK_SET
%27 = tail call i32 @fseek(i32* %13, i32 0, i32 %26)
%28 = tail call i64 @malloc(i64 %25)
%29 = inttoptr i64 %28 to i8*
%30 = tail call i64 @fread(i8* %29, i32 1, i64 %25, i32* %13)
%31 = icmp eq i64 %30, %25
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = tail call i32 @LLVMFuzzerTestOneInput(i8* %29, i64 %25)
%35 = tail call i32 @free(i8* %29)
%36 = tail call i64 @fclose(i32* %13)
%37 = icmp eq i64 %36, 0
%38 = zext i1 %37 to i32
%39 = tail call i32 @assert(i32 %38)
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %11
%42 = trunc i64 %30 to i32
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %41, i32 %42)
br label %44
44: ; preds = %19, %16
%45 = add nuw nsw i64 %10, 1
%46 = icmp eq i64 %45, %8
br i1 %46, label %47, label %9
47: ; preds = %44, %2
ret i32 0
}