#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 */
struct pdf_doc {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pdf_add_image_file(struct pdf_doc *, int /*<<< orphan*/ *,
                                      int, int, int, int, char *);
int /*<<< orphan*/ pdf_append_page(struct pdf_doc *);
struct pdf_doc *pdf_create(float, float, int /*<<< orphan*/ *);
int /*<<< orphan*/ pdf_destroy(struct pdf_doc *);
int /*<<< orphan*/ pdf_save(struct pdf_doc *, char *);
int /*<<< orphan*/ pdf_set_font(struct pdf_doc *, char *);
int LLVMFuzzerTestOneInput(char *data, int size) {
  FILE *temfile = fopen("./fuzz-image.dat", "w");
  fwrite(data, 1, size, temfile);
  fclose(temfile);
  struct pdf_doc *pdf = pdf_create(((float)((210.0f) * 72.0f / 25.4f)),
                                   ((float)((297.0f) * 72.0f / 25.4f)), NULL);
  pdf_set_font(pdf, "Times-Roman");
  pdf_append_page(pdf);
  pdf_add_image_file(pdf, NULL, 100, 500, 50, 150, "./fuzz-image.dat");
  pdf_save(pdf, "fuzz-image-file.pdf");
  pdf_destroy(pdf);
  return 0;
}


x86 assembly (clang, -O0):
<LLVMFuzzerTestOneInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xe62(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movss  0xe24(%rip),%xmm0
movss  0xe20(%rip),%xmm1
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <pdf_create@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1060 <pdf_set_font@plt>
mov    -0x20(%rbp),%rdi
call   1030 <pdf_append_page@plt>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x64,%edx
mov    $0x1f4,%ecx
mov    $0x32,%r8d
mov    $0x96,%r9d
lea    0xdd9(%rip),%rax
mov    %rax,(%rsp)
call   1070 <pdf_add_image_file@plt>
mov    -0x20(%rbp),%rdi
lea    0xde4(%rip),%rsi
call   1080 <pdf_save@plt>
mov    -0x20(%rbp),%rdi
call   1050 <pdf_destroy@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LLVMFuzzerTestOneInput>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0xe64(%rip),%r14
lea    0xe6e(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r15d,%edx
mov    %rax,%rcx
call   10b0 <fwrite@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
movss  0xe27(%rip),%xmm0
movss  0xe23(%rip),%xmm1
xor    %edi,%edi
call   10a0 <pdf_create@plt>
mov    %rax,%rbx
lea    0xe29(%rip),%rsi
mov    %rax,%rdi
call   1060 <pdf_set_font@plt>
mov    %rbx,%rdi
call   1030 <pdf_append_page@plt>
mov    %r14,(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x64,%edx
mov    $0x1f4,%ecx
mov    $0x32,%r8d
mov    $0x96,%r9d
call   1070 <pdf_add_image_file@plt>
lea    0xdfa(%rip),%rsi
mov    %rbx,%rdi
call   1080 <pdf_save@plt>
mov    %rbx,%rdi
call   1050 <pdf_destroy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.pdf_doc = type { i32 }
@.str = [17 x i8] c"./fuzz-image.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [12 x i8] c"Times-Roman\00"
@.str.3 = [20 x i8] c"fuzz-image-file.pdf\00"
define i32 @LLVMFuzzerTestOneInput(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca %struct.pdf_doc*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %5
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = load i32*, i32** %5
%11 = call i32 @fwrite(i8* %8, i32 1, i32 %9, i32* %10)
%12 = load i32*, i32** %5
%13 = call i32 @fclose(i32* %12)
%14 = call %struct.pdf_doc* @pdf_create(float 0x40829A3460000000, float 0x408A4F1E40000000, i32* null)
store %struct.pdf_doc* %14, %struct.pdf_doc** %6
%15 = load %struct.pdf_doc*, %struct.pdf_doc** %6
%16 = call i32 @pdf_set_font(%struct.pdf_doc* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%17 = load %struct.pdf_doc*, %struct.pdf_doc** %6
%18 = call i32 @pdf_append_page(%struct.pdf_doc* %17)
%19 = load %struct.pdf_doc*, %struct.pdf_doc** %6
%20 = call i32 @pdf_add_image_file(%struct.pdf_doc* %19, i32* null, i32 100, i32 500, i32 50, i32 150, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%21 = load %struct.pdf_doc*, %struct.pdf_doc** %6
%22 = call i32 @pdf_save(%struct.pdf_doc* %21, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%23 = load %struct.pdf_doc*, %struct.pdf_doc** %6
%24 = call i32 @pdf_destroy(%struct.pdf_doc* %23)
ret i32 0
}

LLVM IR (-O2):
%struct.pdf_doc = type { i32 }
@.str = [17 x i8] c"./fuzz-image.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [12 x i8] c"Times-Roman\00"
@.str.3 = [20 x i8] c"fuzz-image-file.pdf\00"
define i32 @LLVMFuzzerTestOneInput(i8* nocapture %0, i32 %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @fwrite(i8* %0, i32 1, i32 %1, i32* %3)
%5 = tail call i32 @fclose(i32* %3)
%6 = tail call %struct.pdf_doc* @pdf_create(float 0x40829A3460000000, float 0x408A4F1E40000000, i32* null)
%7 = tail call i32 @pdf_set_font(%struct.pdf_doc* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @pdf_append_page(%struct.pdf_doc* %6)
%9 = tail call i32 @pdf_add_image_file(%struct.pdf_doc* %6, i32* null, i32 100, i32 500, i32 50, i32 150, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @pdf_save(%struct.pdf_doc* %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @pdf_destroy(%struct.pdf_doc* %6)
ret i32 0
}