#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 */
scalar_t__ EOF;
int /*<<< orphan*/ createUser(char *, char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, char *, int *);
void loadRank() {
  FILE *rankFile;
  char name[50];
  char pass[20];
  int points;
  rankFile = fopen("rank", "r");
  if (rankFile == NULL) {
    rankFile = fopen("rank", "w");
    fclose(rankFile);
    rankFile = fopen("rank", "r");
  }
  while (fscanf(rankFile, "%s %s %d\n", name, pass, &points) != EOF) {
    createUser(name, pass, points);
  }
  fclose(rankFile);
}


x86 assembly (clang, -O0):
<loadRank>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeaf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11a1 <loadRank+0x61>
lea    0xe8f(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe6f(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
jmp    11a6 <loadRank+0x66>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    0xe50(%rip),%rsi
lea    -0x64(%rbp),%r8
call   1040 <fscanf@plt>
mov    0x2e1f(%rip),%rcx
cmp    (%rcx),%rax
je     11e7 <loadRank+0xa7>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x64(%rbp),%edx
call   1050 <createUser@plt>
jmp    11a6 <loadRank+0x66>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadRank>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xeab(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1199 <loadRank+0x59>
lea    0xe90(%rip),%rbx
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rdi
call   1030 <fclose@plt>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe69(%rip),%rsi
lea    0x30(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %r14,%rdi
call   1040 <fscanf@plt>
mov    0x2e2a(%rip),%rbp
cmp    0x0(%rbp),%rax
je     1209 <loadRank+0xc9>
lea    0x30(%rsp),%r15
lea    0x10(%rsp),%rbx
lea    0xe34(%rip),%r12
lea    0xc(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <createUser@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r13,%r8
call   1040 <fscanf@plt>
cmp    0x0(%rbp),%rax
jne    11e0 <loadRank+0xa0>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"rank\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [10 x i8] c"%s %s %d\0A\00"
@EOF = global i64 0
define void @loadRank() {
%1 = alloca i32*
%2 = alloca [50 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %1
%6 = load i32*, i32** %1
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %9, i32** %1
%10 = load i32*, i32** %1
%11 = call i32 @fclose(i32* %10)
%12 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %1
br label %13
13: ; preds = %8, %0
br label %14
14: ; preds = %21, %13
%15 = load i32*, i32** %1
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%18 = call i64 @fscanf(i32* %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %17, i32* %4)
%19 = load i64, i64* @EOF
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %26
21: ; preds = %14
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%24 = load i32, i32* %4
%25 = call i32 @createUser(i8* %22, i8* %23, i32 %24)
br label %14
26: ; preds = %14
%27 = load i32*, i32** %1
%28 = call i32 @fclose(i32* %27)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"rank\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [10 x i8] c"%s %s %d\0A\00"
@EOF = global i64 0
define void @loadRank() {
%1 = alloca [50 x i8]
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @fclose(i32* %10)
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %9, %0
%14 = phi i32* [ %12, %9 ], [ %7, %0 ]
%15 = call i64 @fscanf(i32* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %4, i8* %5, i32* %3)
%16 = load i64, i64* @EOF
%17 = icmp eq i64 %15, %16
br i1 %17, label %24, label %18
18: ; preds = %13, %18
%19 = load i32, i32* %3
%20 = call i32 @createUser(i8* %4, i8* %5, i32 %19)
%21 = call i64 @fscanf(i32* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %4, i8* %5, i32* %3)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %18
24: ; preds = %18, %13
%25 = call i32 @fclose(i32* %14)
ret void
}