#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;
scalar_t__ calloc(size_t, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ fread(int /*<<< orphan*/ *, int, size_t,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int ii;
  for (ii = 1; ii < argc; ii++) {
    FILE *infile;
    printf("[%s] ", argv[ii]);
    infile = fopen(argv[ii], "rb");
    if (infile) {
      uint8_t *buffer = NULL;
      size_t buffer_len;
      printf("Opened.. ");
      fseek(infile, 0L, SEEK_END);
      buffer_len = ftell(infile);
      fseek(infile, 0L, SEEK_SET);
      buffer = (uint8_t *)calloc(buffer_len, sizeof(uint8_t));
      if (buffer) {
        fread(buffer, sizeof(uint8_t), buffer_len, infile);
        printf("Read %zu bytes, fuzzing.. ", buffer_len);
        LLVMFuzzerTestOneInput(buffer, buffer_len);
        printf("complete !!");
        free(buffer);
        buffer = NULL;
      } else {
        fprintf(stderr, "[%s] Failed to allocate %zu bytes \n", argv[ii],
                buffer_len);
      }
      fclose(infile);
      infile = NULL;
    } else {
      fprintf(stderr, "[%s] Open failed. \n", argv[ii]);
    }
    printf("\n");
  }
}


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)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    134b <main+0x1ab>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe10(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     130c <main+0x16c>
movq   $0x0,-0x28(%rbp)
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    0x2dbd(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2d82(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <fseek@plt>
mov    -0x30(%rbp),%rdi
mov    $0x4,%esi
call   1080 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12cf <main+0x12f>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x4,%esi
call   1040 <fread@plt>
mov    -0x30(%rbp),%rsi
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <LLVMFuzzerTestOneInput@plt>
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
jmp    12f6 <main+0x156>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x30(%rbp),%rcx
lea    0xd4b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x20(%rbp)
jmp    132f <main+0x18f>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd36(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bd <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     130b <main+0x15b>
mov    %rsi,%rbx
mov    %edi,%r14d
mov    $0x1,%r15d
jmp    1212 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r15,8),%rdx
lea    0xe6a(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%r15
cmp    %r15,%r14
je     130b <main+0x15b>
mov    (%rbx,%r15,8),%rsi
lea    0xde3(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx,%r15,8),%rdi
lea    0xdd7(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     11e0 <main+0x30>
mov    %rax,%rbp
lea    0xdc6(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %rbp,%rdi
call   10b0 <ftell@plt>
mov    %rax,%r12
mov    0x2d61(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %r12,%rdi
mov    $0x4,%esi
call   1090 <calloc@plt>
test   %rax,%rax
je     12e0 <main+0x130>
mov    %rax,%r13
mov    %rax,%rdi
mov    $0x4,%esi
mov    %r12,%rdx
mov    %rbp,%rcx
call   1050 <fread@plt>
lea    0xd69(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1080 <LLVMFuzzerTestOneInput@plt>
lea    0xd68(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
jmp    12fe <main+0x14e>
nopw   0x0(%rax,%rax,1)
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r15,8),%rdx
lea    0xd46(%rip),%rsi
mov    %r12,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
jmp    11fb <main+0x4b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"[%s] \00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [10 x i8] c"Opened.. \00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [27 x i8] c"Read %zu bytes, fuzzing.. \00"
@.str.4 = [12 x i8] c"complete !!\00"
@stderr = global i32 0
@.str.5 = [36 x i8] c"[%s] Failed to allocate %zu bytes \0A\00"
@.str.6 = [20 x i8] c"[%s] Open failed. \0A\00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %10
10: ; preds = %79, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %82
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %19)
%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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %7
%27 = load i32*, i32** %7
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %69
29: ; preds = %14
store i32* null, i32** %8
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32*, i32** %7
%32 = load i32, i32* @SEEK_END
%33 = call i32 @fseek(i32* %31, i64 0, i32 %32)
%34 = load i32*, i32** %7
%35 = call i64 @ftell(i32* %34)
store i64 %35, i64* %9
%36 = load i32*, i32** %7
%37 = load i32, i32* @SEEK_SET
%38 = call i32 @fseek(i32* %36, i64 0, i32 %37)
%39 = load i64, i64* %9
%40 = call i64 @calloc(i64 %39, i32 4)
%41 = inttoptr i64 %40 to i32*
store i32* %41, i32** %8
%42 = load i32*, i32** %8
%43 = icmp ne i32* %42, null
br i1 %43, label %44, label %57
44: ; preds = %29
%45 = load i32*, i32** %8
%46 = load i64, i64* %9
%47 = load i32*, i32** %7
%48 = call i32 @fread(i32* %45, i32 4, i64 %46, i32* %47)
%49 = load i64, i64* %9
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i64 %49)
%51 = load i32*, i32** %8
%52 = load i64, i64* %9
%53 = call i32 @LLVMFuzzerTestOneInput(i32* %51, i64 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%55 = load i32*, i32** %8
%56 = call i32 @free(i32* %55)
store i32* null, i32** %8
br label %66
57: ; preds = %29
%58 = load i32, i32* @stderr
%59 = load i8**, i8*** %5
%60 = load i32, i32* %6
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = load i64, i64* %9
%65 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* %63, i64 %64)
br label %66
66: ; preds = %57, %44
%67 = load i32*, i32** %7
%68 = call i32 @fclose(i32* %67)
store i32* null, i32** %7
br label %77
69: ; preds = %14
%70 = load i32, i32* @stderr
%71 = load i8**, i8*** %5
%72 = load i32, i32* %6
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %71, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %75)
br label %77
77: ; preds = %69, %66
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %79
79: ; preds = %77
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 1
store i32 %81, i32* %6
br label %10
82: ; preds = %10
%83 = load i32, i32* %3
ret i32 %83
}

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