#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 EOF;
int /*<<< orphan*/ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ msgbox(char *);
int level_of_save(void) {
  int i;
  FILE *fp = fopen("saved", "r");
  if (fp != NULL) {
    for (i = 0; i < 23 * 80; i++) {
      fgetc(fp);
    }
  }
  i = fscanf(fp, "%d", &i);
  i = fscanf(fp, "%d", &i);
  if (fscanf(fp, "%d", &i) == EOF) {
    i = -1;
    msgbox("Save file not found!");
  }
  return i;
}


x86 assembly (clang, -O0):
<level_of_save>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119a <level_of_save+0x5a>
movl   $0x0,-0x4(%rbp)
cmpl   $0x730,-0x4(%rbp)
jge    1195 <level_of_save+0x55>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1171 <level_of_save+0x31>
jmp    119a <level_of_save+0x5a>
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1030 <fscanf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe4c(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1030 <fscanf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe35(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1030 <fscanf@plt>
mov    0x2e05(%rip),%rcx
cmp    (%rcx),%eax
jne    11fe <level_of_save+0xbe>
movl   $0xffffffff,-0x4(%rbp)
lea    0xe12(%rip),%rdi
call   1060 <msgbox@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<level_of_save>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1185 <level_of_save+0x45>
mov    $0x730,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <fgetc@plt>
add    $0xffffffff,%ebp
jne    1170 <level_of_save+0x30>
movl   $0x730,0x4(%rsp)
lea    0xe7c(%rip),%r14
lea    0x4(%rsp),%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fscanf@plt>
mov    %eax,0x4(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fscanf@plt>
mov    %eax,0x4(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fscanf@plt>
mov    0x2e1e(%rip),%rcx
cmp    (%rcx),%eax
jne    11e2 <level_of_save+0xa2>
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xe2e(%rip),%rdi
call   1060 <msgbox@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"saved\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.3 = [21 x i8] c"Save file not found!\00"
define i32 @level_of_save() {
%1 = alloca i32
%2 = alloca i32*
%3 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %17
6: ; preds = %0
store i32 0, i32* %1
br label %7
7: ; preds = %13, %6
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1840
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i32*, i32** %2
%12 = call i32 @fgetc(i32* %11)
br label %13
13: ; preds = %10
%14 = load i32, i32* %1
%15 = add nsw i32 %14, 1
store i32 %15, i32* %1
br label %7
16: ; preds = %7
br label %17
17: ; preds = %16, %0
%18 = load i32*, i32** %2
%19 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
store i32 %19, i32* %1
%20 = load i32*, i32** %2
%21 = call i32 @fscanf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
store i32 %21, i32* %1
%22 = load i32*, i32** %2
%23 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %17
store i32 -1, i32* %1
%27 = call i32 @msgbox(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %17
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [6 x i8] c"saved\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.3 = [21 x i8] c"Save file not found!\00"
define i32 @level_of_save() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %11, label %5
5: ; preds = %0, %5
%6 = phi i32 [ %8, %5 ], [ 0, %0 ]
%7 = tail call i32 @fgetc(i32* %3)
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 1840
br i1 %9, label %10, label %5
10: ; preds = %5
store i32 1840, i32* %1
br label %11
11: ; preds = %10, %0
%12 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
store i32 %12, i32* %1
%13 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
store i32 %13, i32* %1
%14 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %11
store i32 -1, i32* %1
%18 = call i32 @msgbox(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %11
%20 = load i32, i32* %1
ret i32 %20
}