#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*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
FILE *openScoreFile(char *mode) {
  FILE *file;
  if ((file = fopen("/var/lib/games/greedy.scores", mode)) == NULL) {
    printf("\nUnable to open hiscore file \"%s\" ",
           "/var/lib/games/greedy.scores");
    if (strcmp(mode, "r") == 0)
      printf("for read.\n");
    else if (strcmp(mode, "w") == 0)
      printf("for write.\n");
  }
  return file;
}


x86 assembly (clang, -O0):
<openScoreFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11ce <openScoreFile+0x9e>
lea    0xebc(%rip),%rdi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xec6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    119c <openScoreFile+0x6c>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c9 <openScoreFile+0x99>
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c4 <openScoreFile+0x94>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c9 <openScoreFile+0x99>
jmp    11ce <openScoreFile+0x9e>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openScoreFile>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeb2(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11b0 <openScoreFile+0x70>
lea    0xeb8(%rip),%rdi
lea    0xe94(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a4 <openScoreFile+0x64>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11b0 <openScoreFile+0x70>
lea    0xea2(%rip),%rdi
jmp    11ab <openScoreFile+0x6b>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"/var/lib/games/greedy.scores\00"
@.str.1 = [35 x i8] c"\0AUnable to open hiscore file \22%s\22 \00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [11 x i8] c"for read.\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [12 x i8] c"for write.\0A\00"
define i32* @openScoreFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32* @fopen(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %4)
store i32* %5, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %22
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %2
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %21
14: ; preds = %7
%15 = load i8*, i8** %2
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
br label %21
21: ; preds = %20, %12
br label %22
22: ; preds = %21, %1
%23 = load i32*, i32** %3
ret i32* %23
}

LLVM IR (-O2):
@.str = [29 x i8] c"/var/lib/games/greedy.scores\00"
@.str.1 = [35 x i8] c"\0AUnable to open hiscore file \22%s\22 \00"
@.str.2 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c"w\00"
@str = [11 x i8] c"for write.\00"
@str.6 = [10 x i8] c"for read.\00"
define noalias i32* @openScoreFile(i8* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8, %4
%12 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0), %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0), %8 ]
%13 = tail call i32 @puts(i8* dereferenceable(1) %12)
br label %14
14: ; preds = %11, %8, %1
ret i32* %2
}