#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fwrite(void *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ generate(void *, int, double);
void *malloc(int);
int /*<<< orphan*/ stderr;
void createSampleFile(char *filename, double p) {
  FILE *foutput = fopen(filename, "wb");
  void *buffer = malloc(((1 * (1 << 20)) - 1));
  generate(buffer, ((1 * (1 << 20)) - 1), p);
  fwrite(buffer, 1, ((1 * (1 << 20)) - 1), foutput);
  fclose(foutput);
  fprintf(stderr, "File %s generated\n", filename);
}


x86 assembly (clang, -O0):
<createSampleFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    $0xfffff,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
mov    $0xfffff,%esi
call   1080 <generate@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0xfffff,%edx
call   1070 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe29(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createSampleFile>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%r14
lea    0xe87(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    $0xfffff,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xfffff,%esi
movsd  0x8(%rsp),%xmm0
call   1080 <generate@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0xfffff,%edx
mov    %r15,%rcx
call   1070 <fwrite@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
mov    %r14,%rdx
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"File %s generated\0A\00"
define void @createSampleFile(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %3
store double %1, double* %4
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %5
%9 = call i8* @malloc(i32 1048575)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = load double, double* %4
%12 = call i32 @generate(i8* %10, i32 1048575, double %11)
%13 = load i8*, i8** %6
%14 = load i32*, i32** %5
%15 = call i32 @fwrite(i8* %13, i32 1, i32 1048575, i32* %14)
%16 = load i32*, i32** %5
%17 = call i32 @fclose(i32* %16)
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %3
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %19)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"File %s generated\0A\00"
define void @createSampleFile(i8* %0, double %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = tail call dereferenceable_or_null(1048575) i8* @malloc(i32 1048575)
%5 = tail call i32 @generate(i8* %4, i32 1048575, double %1)
%6 = tail call i32 @fwrite(i8* %4, i32 1, i32 1048575, i32* %3)
%7 = tail call i32 @fclose(i32* %3)
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %0)
ret void
}