#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(int /*<<< orphan*/ const *, size_t, int,
                          int /*<<< orphan*/ *);
int getpid();
int /*<<< orphan*/ readcfgfile(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ unlink(char *);
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
  if (size < 50)
    return 0;
  char filename[256];
  sprintf(filename, "/tmp/libfuzzer.%d", getpid());
  FILE *fp = fopen(filename, "wb");
  if (!fp)
    return 0;
  fwrite(data, size, 1, fp);
  fclose(fp);
  readcfgfile(filename);
  unlink(filename);
  return 0;
}


x86 assembly (clang, -O0):
<LLVMFuzzerTestOneInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x32,-0x18(%rbp)
jae    119a <LLVMFuzzerTestOneInput+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    123c <LLVMFuzzerTestOneInput+0xcc>
lea    -0x120(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x130(%rbp),%rdi
mov    %eax,%edx
lea    0xe41(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
jne    11f8 <LLVMFuzzerTestOneInput+0x88>
movl   $0x0,-0x4(%rbp)
jmp    123c <LLVMFuzzerTestOneInput+0xcc>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x128(%rbp),%rcx
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x128(%rbp),%rdi
call   1050 <fclose@plt>
lea    -0x120(%rbp),%rdi
call   1090 <readcfgfile@plt>
lea    -0x120(%rbp),%rdi
call   1030 <unlink@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LLVMFuzzerTestOneInput>:
cmp    $0x32,%rsi
jb     11f4 <LLVMFuzzerTestOneInput+0x84>
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe6a(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1070 <sprintf@plt>
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11e8 <LLVMFuzzerTestOneInput+0x78>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1090 <readcfgfile@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [18 x i8] c"/tmp/libfuzzer.%d\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @LLVMFuzzerTestOneInput(i32* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i64
%6 = alloca [256 x i8]
%7 = alloca i32*
store i32* %0, i32** %4
store i64 %1, i64* %5
%8 = load i64, i64* %5
%9 = icmp ult i64 %8, 50
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %31
11: ; preds = %2
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%13 = call i32 (...) @getpid()
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %7
%17 = load i32*, i32** %7
%18 = icmp ne i32* %17, null
br i1 %18, label %20, label %19
19: ; preds = %11
store i32 0, i32* %3
br label %31
20: ; preds = %11
%21 = load i32*, i32** %4
%22 = load i64, i64* %5
%23 = load i32*, i32** %7
%24 = call i32 @fwrite(i32* %21, i64 %22, i32 1, i32* %23)
%25 = load i32*, i32** %7
%26 = call i32 @fclose(i32* %25)
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%28 = call i32 @readcfgfile(i8* %27)
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%30 = call i32 @unlink(i8* %29)
store i32 0, i32* %3
br label %31
31: ; preds = %20, %19, %10
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [18 x i8] c"/tmp/libfuzzer.%d\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @LLVMFuzzerTestOneInput(i32* nocapture %0, i64 %1) {
%3 = alloca [256 x i8]
%4 = icmp ult i64 %1, 50
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (...) @getpid()
%8 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %16, label %11
11: ; preds = %5
%12 = tail call i32 @fwrite(i32* %0, i64 %1, i32 1, i32* %9)
%13 = tail call i32 @fclose(i32* %9)
%14 = call i32 @readcfgfile(i8* %6)
%15 = call i32 @unlink(i8* %6)
br label %16
16: ; preds = %5, %11
br label %17
17: ; preds = %2, %16
ret i32 0
}