#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 /*<<< orphan*/ LLVMFuzzerTestOneInput(unsigned char *, long);
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
size_t fread(unsigned char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(long);
int /*<<< orphan*/ stderr;
char *strrchr(char *, char);
int main(int argc, char **argv) {
  const char *progname;
  if ((progname = strrchr(argv[0], '/')))
    progname++;
  else
    progname = argv[0];
  fprintf(stderr, "%s: running %d inputs\n", progname, argc - 1);
  LLVMFuzzerInitialize(&argc, &argv);
  for (int i = 1; i < argc; i++) {
    fprintf(stderr, "Running: %s\n", argv[i]);
    FILE *f = fopen(argv[i], "r+");
    assert(f);
    fseek(f, 0, SEEK_END);
    long len = ftell(f);
    fseek(f, 0, SEEK_SET);
    unsigned char *buf = (unsigned char *)malloc(len);
    size_t n_read = fread(buf, 1, len, f);
    fclose(f);
    assert(n_read == len);
    LLVMFuzzerTestOneInput(buf, len);
    free(buf);
    fprintf(stderr, "Done:    %s: (%zd bytes)\n", argv[i], n_read);
  }
}


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    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1206 <main+0x46>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1211 <main+0x51>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
lea    0xdd5(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   10b0 <LLVMFuzzerInitialize@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1361 <main+0x1a1>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xda9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd9c(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%edi
call   1080 <assert@plt>
mov    -0x28(%rbp),%rdi
mov    0x2d41(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2d08(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   10c0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x40(%rbp),%rcx
lea    0xcdb(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1246 <main+0x86>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
mov    %edi,0xc(%rsp)
mov    %rsi,0x10(%rsp)
mov    (%rsi),%r14
mov    %r14,%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
lea    0x1(%rax),%rdx
test   %rax,%rax
cmove  %r14,%rdx
mov    0x2ddd(%rip),%r15
mov    (%r15),%edi
add    $0xffffffff,%ebx
lea    0xdf8(%rip),%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   10b0 <LLVMFuzzerInitialize@plt>
cmpl   $0x2,0xc(%rsp)
jl     1323 <main+0x163>
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%edi
mov    0x10(%rsp),%rax
mov    (%rax,%r12,8),%rdx
lea    0xdc4(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x10(%rsp),%rax
mov    (%rax,%r12,8),%rdi
lea    0xdba(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1080 <assert@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    %rbx,%rdi
call   10a0 <ftell@plt>
mov    %rax,%r13
mov    0x2d32(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    %r13,%rdi
call   10c0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
cmp    %r13,%r14
sete   %dil
call   1080 <assert@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1060 <LLVMFuzzerTestOneInput@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    (%r15),%edi
mov    0x10(%rsp),%rax
mov    (%rax,%r12,8),%rdx
lea    0xd20(%rip),%rsi
mov    %r14,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
add    $0x1,%r12
movslq 0xc(%rsp),%rax
cmp    %rax,%r12
jl     1240 <main+0x80>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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