#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*/ ch;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ x_pause();
void loadLv(int *nLv, int *enN) {
  char ch[7];
  char file_name[25] = "settings.txt";
  FILE *fp;
  fp = fopen(file_name, "r");
  if (fp == NULL) {
    perror("Error while opening the level file.\n");
    x_pause();
    endwin();
    exit(EXIT_FAILURE);
  }
  fgets(ch, sizeof(ch), fp);
  sscanf(ch, "lv: %d", nLv);
  fgets(ch, sizeof(ch), fp);
  sscanf(ch, "en: %d", enN);
  fclose(fp);
}


x86 assembly (clang, -O0):
<loadLv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe69(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe66(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe63(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe61(%rip),%al
mov    %al,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1201 <loadLv+0x81>
lea    0xe3b(%rip),%rdi
call   1090 <perror@plt>
mov    $0x0,%al
call   1060 <x_pause@plt>
mov    $0x0,%al
call   1070 <endwin@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    -0x17(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x7,%esi
call   1040 <fgets@plt>
lea    -0x17(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe1e(%rip),%rsi
call   1050 <sscanf@plt>
lea    -0x17(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x7,%esi
call   1040 <fgets@plt>
lea    -0x17(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xdff(%rip),%rsi
call   1050 <sscanf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadLv>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movups 0xe71(%rip),%xmm0
movups %xmm0,0x19(%rsp)
movaps 0xe5c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe69(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     121f <loadLv+0x9f>
mov    %rax,%rbx
lea    0x9(%rsp),%r12
mov    %r12,%rdi
mov    $0x7,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
lea    0xe62(%rip),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
call   1050 <sscanf@plt>
mov    %r12,%rdi
mov    $0x7,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
lea    0xe47(%rip),%rsi
mov    %r12,%rdi
mov    %r14,%rdx
call   1050 <sscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xdf5(%rip),%rdi
call   1090 <perror@plt>
xor    %eax,%eax
call   1060 <x_pause@plt>
xor    %eax,%eax
call   1070 <endwin@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@__const.loadLv.file_name = [25 x i8] c"settings.txt\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"Error while opening the level file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [7 x i8] c"lv: %d\00"
@.str.3 = [7 x i8] c"en: %d\00"
define void @loadLv(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [7 x i8]
%6 = alloca [25 x i8]
%7 = alloca i32*
store i32* %0, i32** %3
store i32* %1, i32** %4
%8 = bitcast [25 x i8]* %6 to i8*
%9 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (...) @x_pause()
%16 = call i32 (...) @endwin()
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%21 = load i32*, i32** %7
%22 = call i32 @fgets(i8* %20, i32 7, i32* %21)
%23 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%24 = load i32*, i32** %3
%25 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32* %24)
%26 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%27 = load i32*, i32** %7
%28 = call i32 @fgets(i8* %26, i32 7, i32* %27)
%29 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%30 = load i32*, i32** %4
%31 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* %30)
%32 = load i32*, i32** %7
%33 = call i32 @fclose(i32* %32)
ret void
}

LLVM IR (-O2):
@__const.loadLv.file_name = [25 x i8] c"settings.txt\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"Error while opening the level file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [7 x i8] c"lv: %d\00"
@.str.3 = [7 x i8] c"en: %d\00"
define void @loadLv(i32* %0, i32* %1) {
%3 = alloca [7 x i8]
%4 = alloca [25 x i8]
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = tail call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 (...) @x_pause()
%12 = tail call i32 (...) @endwin()
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = call i32 @fgets(i8* %5, i32 7, i32* %7)
%17 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32* %0)
%18 = call i32 @fgets(i8* %5, i32 7, i32* %7)
%19 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%20 = call i32 @fclose(i32* %7)
ret void
}