#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 /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *);
void createHighScores(void) {
  FILE *file;
  int i;
  file = fopen("highscores.txt", "w+");
  if (file == NULL) {
    printf("FAILED TO CREATE HIGHSCORES!!! EXITING!");
    exit(0);
  }
  for (i = 0; i < 5; i++) {
    fprintf(file, "%d", i + 1);
    fprintf(file, "%s", "\t0\t\t\tEMPTY\n");
  }
  fclose(file);
  return;
}


x86 assembly (clang, -O0):
<createHighScores>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    118d <createHighScores+0x3d>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    11dd <createHighScores+0x8d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe7c(%rip),%rsi
lea    0xe78(%rip),%rdx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1194 <createHighScores+0x44>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createHighScores>:
push   %r15
push   %r14
push   %rbx
lea    0xe94(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1262 <createHighScores+0x102>
mov    %rax,%rbx
lea    0xeaf(%rip),%r14
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe99(%rip),%r15
mov    $0xb,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xb,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xb,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xb,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xb,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
lea    0xda9(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"highscores.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [40 x i8] c"FAILED TO CREATE HIGHSCORES!!! EXITING!\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [12 x i8] c"\090\09\09\09EMPTY\0A\00"
define void @createHighScores() {
%1 = alloca i32*
%2 = alloca i32
%3 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @exit(i32 0)
unreachable
9: ; preds = %0
store i32 0, i32* %2
br label %10
10: ; preds = %20, %9
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32*, i32** %1
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32*, i32** %1
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %20
20: ; preds = %13
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %10
23: ; preds = %10
%24 = load i32*, i32** %1
%25 = call i32 @fclose(i32* %24)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"highscores.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [40 x i8] c"FAILED TO CREATE HIGHSCORES!!! EXITING!\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [12 x i8] c"\090\09\09\09EMPTY\0A\00"
define void @createHighScores() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %15, label %3
3: ; preds = %0
%4 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 1)
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 11, i64 1, i32* %1)
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 11, i64 1, i32* %1)
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 3)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 11, i64 1, i32* %1)
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 4)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 11, i64 1, i32* %1)
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 5)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 11, i64 1, i32* %1)
%14 = tail call i32 @fclose(i32* %1)
ret void
15: ; preds = %0
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @exit(i32 0)
unreachable
}