#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ stderr;
void create_prelude_h(int length) {
  FILE *f = fopen("src/prelude.h", "w");
  if (f == NULL) {
    fprintf(stderr, "Error opening file\n");
    exit(1);
  }
  fprintf(f, "const char prelude[] = {\n");
  fprintf(f, "#include \"prelude.bin\"\n");
  fprintf(f, "};\n");
  fprintf(f, "const int prelude_length = %d;\n", length);
  fclose(f);
}


x86 assembly (clang, -O0):
<create_prelude_h>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xeae(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118f <create_prelude_h+0x4f>
mov    0x2e6c(%rip),%rax
movslq (%rax),%rdi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_prelude_h>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xea4(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11dc <create_prelude_h+0x8c>
mov    %rax,%rbx
lea    0xead(%rip),%rdi
mov    $0x19,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
lea    0xeae(%rip),%rdi
mov    $0x17,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
lea    0xead(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fclose@plt>
mov    0x2dfd(%rip),%rax
movslq (%rax),%rcx
lea    0xe23(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"src/prelude.h\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [20 x i8] c"Error opening file\0A\00"
@.str.3 = [26 x i8] c"const char prelude[] = {\0A\00"
@.str.4 = [24 x i8] c"#include \22prelude.bin\22\0A\00"
@.str.5 = [4 x i8] c"};\0A\00"
@.str.6 = [32 x i8] c"const int prelude_length = %d;\0A\00"
define void @create_prelude_h(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i32*
%11 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
%14 = load i32*, i32** %3
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32*, i32** %3
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%18 = load i32*, i32** %3
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%20 = load i32*, i32** %3
%21 = load i32, i32* %2
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %21)
%23 = load i32*, i32** %3
%24 = call i32 @fclose(i32* %23)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"src/prelude.h\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [20 x i8] c"Error opening file\0A\00"
@.str.3 = [26 x i8] c"const char prelude[] = {\0A\00"
@.str.4 = [24 x i8] c"#include \22prelude.bin\22\0A\00"
@.str.5 = [4 x i8] c"};\0A\00"
@.str.6 = [32 x i8] c"const int prelude_length = %d;\0A\00"
define void @create_prelude_h(i32 %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i64 19, i64 1, i32* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i64 25, i64 1, i32* %2)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i64 23, i64 1, i32* %2)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %2)
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %0)
%15 = tail call i32 @fclose(i32* %2)
ret void
}