#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 KEY_DOWN;
int KEY_UP;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getch();
int /*<<< orphan*/ mvaddch(int, int, char);
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ refresh();
void load_menu(unsigned char *currow) {
  unsigned char slotxt_1[50], slotxt_2[50], slotxt_3[50], i;
  int key = 0, buf;
  FILE *s1, *s2, *s3;
  s1 = fopen("saves\\slot_1.sav", "r");
  s2 = fopen("saves\\slot_2.sav", "r");
  s3 = fopen("saves\\slot_3.sav", "r");
  i = 0;
  while ((buf = fgetc(s1)) != '\n' && buf != EOF) {
    slotxt_1[i] = buf;
    i++;
  }
  slotxt_1[i] = '\0';
  i = 0;
  while ((buf = fgetc(s2)) != '\n' && buf != EOF) {
    slotxt_2[i] = buf;
    i++;
  }
  slotxt_2[i] = '\0';
  i = 0;
  while ((buf = fgetc(s3)) != '\n' && buf != EOF) {
    slotxt_3[i] = buf;
    i++;
  }
  slotxt_3[i] = '\0';
  fclose(s1);
  fclose(s2);
  fclose(s3);
  *currow = 1;
  mvprintw(4, 1, "            ");
  mvprintw(4, 5, "1: Slot 1 - %s", slotxt_1);
  mvprintw(5, 5, "2: Slot 2 - %s", slotxt_2);
  mvprintw(6, 5, "3: Slot 3 - %s", slotxt_3);
  mvprintw(7, 5, "4: Cancel");
  mvprintw(8, 1, "3: Quit Game");
  while (key != '\n' && key != '\r') {
    if (*currow == 1) {
      mvaddch(4, 4, '>');
      mvaddch(5, 4, ' ');
      mvaddch(6, 4, ' ');
      mvaddch(7, 4, ' ');
      refresh();
    } else if (*currow == 2) {
      mvaddch(4, 4, ' ');
      mvaddch(5, 4, '>');
      mvaddch(6, 4, ' ');
      mvaddch(7, 4, ' ');
      refresh();
    } else if (*currow == 3) {
      mvaddch(4, 4, ' ');
      mvaddch(5, 4, ' ');
      mvaddch(6, 4, '>');
      mvaddch(7, 4, ' ');
      refresh();
    } else if (*currow == 4) {
      mvaddch(4, 4, ' ');
      mvaddch(5, 4, ' ');
      mvaddch(6, 4, ' ');
      mvaddch(7, 4, '>');
      refresh();
    }
    key = getch();
    if (key == KEY_UP && *currow != 1)
      (*currow)--;
    else if (key == KEY_UP && *currow == 1)
      *currow = 4;
    else if (key == KEY_DOWN && *currow != 4)
      (*currow)++;
    else if (key == KEY_DOWN && *currow == 4)
      *currow = 1;
  }
  return;
}


x86 assembly (clang, -O0):
<load_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc8(%rbp)
lea    0xe70(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xd8(%rbp)
lea    0xe69(%rip),%rdi
lea    0xe60(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xe0(%rbp)
lea    0xe60(%rip),%rdi
lea    0xe46(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xe8(%rbp)
movb   $0x0,-0xc1(%rbp)
mov    -0xd8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0xcc(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xe9(%rbp)
je     121b <load_menu+0xab>
mov    -0xcc(%rbp),%eax
mov    0x2dd0(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0xe9(%rbp)
mov    -0xe9(%rbp),%al
test   $0x1,%al
jne    122e <load_menu+0xbe>
jmp    1254 <load_menu+0xe4>
mov    -0xcc(%rbp),%eax
mov    %al,%cl
movzbl -0xc1(%rbp),%eax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0xc1(%rbp),%al
add    $0x1,%al
mov    %al,-0xc1(%rbp)
jmp    11de <load_menu+0x6e>
movzbl -0xc1(%rbp),%eax
movb   $0x0,-0x40(%rbp,%rax,1)
movb   $0x0,-0xc1(%rbp)
mov    -0xe0(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0xcc(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xea(%rbp)
je     12a4 <load_menu+0x134>
mov    -0xcc(%rbp),%eax
mov    0x2d47(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0xea(%rbp)
mov    -0xea(%rbp),%al
test   $0x1,%al
jne    12b7 <load_menu+0x147>
jmp    12dd <load_menu+0x16d>
mov    -0xcc(%rbp),%eax
mov    %al,%cl
movzbl -0xc1(%rbp),%eax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0xc1(%rbp),%al
add    $0x1,%al
mov    %al,-0xc1(%rbp)
jmp    1267 <load_menu+0xf7>
movzbl -0xc1(%rbp),%eax
movb   $0x0,-0x80(%rbp,%rax,1)
movb   $0x0,-0xc1(%rbp)
mov    -0xe8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0xcc(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xeb(%rbp)
je     132d <load_menu+0x1bd>
mov    -0xcc(%rbp),%eax
mov    0x2cbe(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0xeb(%rbp)
mov    -0xeb(%rbp),%al
test   $0x1,%al
jne    1340 <load_menu+0x1d0>
jmp    1369 <load_menu+0x1f9>
mov    -0xcc(%rbp),%eax
mov    %al,%cl
movzbl -0xc1(%rbp),%eax
mov    %cl,-0xc0(%rbp,%rax,1)
mov    -0xc1(%rbp),%al
add    $0x1,%al
mov    %al,-0xc1(%rbp)
jmp    12f0 <load_menu+0x180>
movzbl -0xc1(%rbp),%eax
movb   $0x0,-0xc0(%rbp,%rax,1)
mov    -0xd8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xe0(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xe8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x8(%rbp),%rax
movb   $0x1,(%rax)
mov    $0x4,%edi
mov    $0x1,%esi
lea    0xc81(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
lea    -0x40(%rbp),%rcx
mov    $0x4,%edi
mov    $0x5,%esi
lea    0xc72(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
lea    -0x80(%rbp),%rcx
mov    $0x5,%esi
lea    0xc6a(%rip),%rdx
mov    %esi,%edi
mov    $0x0,%al
call   1090 <mvprintw@plt>
lea    -0xc0(%rbp),%rcx
mov    $0x6,%edi
mov    $0x5,%esi
lea    0xc58(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
mov    $0x7,%edi
mov    $0x5,%esi
lea    0xc4f(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
mov    $0x8,%edi
mov    $0x1,%esi
lea    0xc41(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
xor    %eax,%eax
cmpl   $0xa,-0xc8(%rbp)
mov    %al,-0xec(%rbp)
je     1464 <load_menu+0x2f4>
cmpl   $0xd,-0xc8(%rbp)
setne  %al
mov    %al,-0xec(%rbp)
mov    -0xec(%rbp),%al
test   $0x1,%al
jne    1477 <load_menu+0x307>
jmp    170d <load_menu+0x59d>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x1,%eax
jne    14e0 <load_menu+0x370>
mov    $0x4,%esi
mov    $0x3e,%edx
mov    %esi,%edi
call   1080 <mvaddch@plt>
mov    $0x5,%edi
mov    $0x4,%esi
mov    $0x20,%edx
call   1080 <mvaddch@plt>
mov    $0x6,%edi
mov    $0x4,%esi
mov    $0x20,%edx
call   1080 <mvaddch@plt>
mov    $0x7,%edi
mov    $0x4,%esi
mov    $0x20,%edx
call   1080 <mvaddch@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
jmp    1625 <load_menu+0x4b5>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x2,%eax
jne    1549 <load_menu+0x3d9>
mov    $0x4,%esi
mov    $0x20,%edx
mov    %esi,%edi
call   1080 <mvaddch@plt>
mov    $0x5,%edi
mov    $0x4,%esi
mov    $0x3e,%edx
call   1080 <mvaddch@plt>
mov    $0x6,%edi
mov    $0x4,%esi
mov    $0x20,%edx
call   1080 <mvaddch@plt>
mov    $0x7,%edi
mov    $0x4,%esi
mov    $0x20,%edx
call   1080 <mvaddch@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
jmp    1620 <load_menu+0x4b0>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x3,%eax
jne    15b2 <load_menu+0x442>
mov    $0x4,%esi
mov    $0x20,%edx
mov    %esi,%edi
call   1080 <mvaddch@plt>
mov    $0x5,%edi
mov    $0x4,%esi
mov    $0x20,%edx
call   1080 <mvaddch@plt>
mov    $0x6,%edi
mov    $0x4,%esi
mov    $0x3e,%edx
call   1080 <mvaddch@plt>
mov    $0x7,%edi
mov    $0x4,%esi
mov    $0x20,%edx
call   1080 <mvaddch@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
jmp    161b <load_menu+0x4ab>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x4,%eax
jne    1616 <load_menu+0x4a6>
mov    $0x4,%esi
mov    $0x20,%edx
mov    %esi,%edi
call   1080 <mvaddch@plt>
mov    $0x5,%edi
mov    $0x4,%esi
mov    $0x20,%edx
call   1080 <mvaddch@plt>
mov    $0x6,%edi
mov    $0x4,%esi
mov    $0x20,%edx
call   1080 <mvaddch@plt>
mov    $0x7,%edi
mov    $0x4,%esi
mov    $0x3e,%edx
call   1080 <mvaddch@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
jmp    161b <load_menu+0x4ab>
jmp    1620 <load_menu+0x4b0>
jmp    1625 <load_menu+0x4b5>
mov    $0x0,%al
call   1060 <getch@plt>
mov    %eax,-0xc8(%rbp)
mov    -0xc8(%rbp),%eax
mov    0x2999(%rip),%rcx
cmp    (%rcx),%eax
jne    1667 <load_menu+0x4f7>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x1,%eax
je     1667 <load_menu+0x4f7>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
add    $0xff,%cl
mov    %cl,(%rax)
jmp    1708 <load_menu+0x598>
mov    -0xc8(%rbp),%eax
mov    0x2964(%rip),%rcx
cmp    (%rcx),%eax
jne    1698 <load_menu+0x528>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x1,%eax
jne    1698 <load_menu+0x528>
mov    -0x8(%rbp),%rax
movb   $0x4,(%rax)
jmp    1703 <load_menu+0x593>
mov    -0xc8(%rbp),%eax
mov    0x2943(%rip),%rcx
cmp    (%rcx),%eax
jne    16cd <load_menu+0x55d>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x4,%eax
je     16cd <load_menu+0x55d>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
add    $0x1,%cl
mov    %cl,(%rax)
jmp    16fe <load_menu+0x58e>
mov    -0xc8(%rbp),%eax
mov    0x290e(%rip),%rcx
cmp    (%rcx),%eax
jne    16f9 <load_menu+0x589>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x4,%eax
jne    16f9 <load_menu+0x589>
mov    -0x8(%rbp),%rax
movb   $0x1,(%rax)
jmp    16fe <load_menu+0x58e>
jmp    1703 <load_menu+0x593>
jmp    1708 <load_menu+0x598>
jmp    143f <load_menu+0x2cf>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rdi,%r13
lea    0xe75(%rip),%rdi
lea    0xe7f(%rip),%r12
mov    %r12,%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
lea    0xe6f(%rip),%rdi
mov    %r12,%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
lea    0xe6e(%rip),%rdi
mov    %r12,%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1040 <fgetc@plt>
xor    %ecx,%ecx
mov    0x2e0e(%rip),%rbp
cmp    $0xa,%eax
je     1202 <load_menu+0x92>
cmp    0x0(%rbp),%eax
je     1202 <load_menu+0x92>
xor    %ebx,%ebx
xchg   %ax,%ax
movzbl %bl,%ebx
mov    %al,0x80(%rsp,%rbx,1)
add    $0x1,%bl
mov    %r14,%rdi
call   1040 <fgetc@plt>
cmp    $0xa,%eax
je     11ff <load_menu+0x8f>
cmp    0x0(%rbp),%eax
jne    11e0 <load_menu+0x70>
movzbl %bl,%ecx
movb   $0x0,0x80(%rsp,%rcx,1)
mov    %r15,%rdi
call   1040 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0xa,%eax
je     123f <load_menu+0xcf>
cmp    0x0(%rbp),%eax
je     123f <load_menu+0xcf>
xor    %ebx,%ebx
movzbl %bl,%ebx
mov    %al,0x40(%rsp,%rbx,1)
add    $0x1,%bl
mov    %r15,%rdi
call   1040 <fgetc@plt>
cmp    $0xa,%eax
je     123c <load_menu+0xcc>
cmp    0x0(%rbp),%eax
jne    1220 <load_menu+0xb0>
movzbl %bl,%ecx
movb   $0x0,0x40(%rsp,%rcx,1)
mov    %r12,%rdi
call   1040 <fgetc@plt>
cmp    $0xa,%eax
je     1280 <load_menu+0x110>
mov    $0x0,%ecx
cmp    0x0(%rbp),%eax
je     1282 <load_menu+0x112>
xor    %ebx,%ebx
nopl   (%rax)
movzbl %bl,%ebx
mov    %al,(%rsp,%rbx,1)
add    $0x1,%bl
mov    %r12,%rdi
call   1040 <fgetc@plt>
cmp    $0xa,%eax
je     127b <load_menu+0x10b>
cmp    0x0(%rbp),%eax
jne    1260 <load_menu+0xf0>
movzbl %bl,%ecx
jmp    1282 <load_menu+0x112>
xor    %ecx,%ecx
movb   $0x0,(%rsp,%rcx,1)
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
movb   $0x1,0x0(%r13)
lea    0xd8b(%rip),%rdx
mov    $0x4,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1090 <mvprintw@plt>
lea    0xd80(%rip),%rdx
lea    0x80(%rsp),%rcx
mov    $0x4,%edi
mov    $0x5,%esi
xor    %eax,%eax
call   1090 <mvprintw@plt>
lea    0xd6f(%rip),%rdx
lea    0x40(%rsp),%rcx
mov    $0x5,%edi
mov    $0x5,%esi
xor    %eax,%eax
call   1090 <mvprintw@plt>
lea    0xd61(%rip),%rdx
mov    %rsp,%rcx
mov    $0x6,%edi
mov    $0x5,%esi
xor    %eax,%eax
call   1090 <mvprintw@plt>
lea    0xd55(%rip),%rdx
mov    $0x7,%edi
mov    $0x5,%esi
xor    %eax,%eax
call   1090 <mvprintw@plt>
lea    0xd47(%rip),%rdx
mov    $0x8,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1090 <mvprintw@plt>
mov    0x2c8e(%rip),%rbp
mov    0x2c97(%rip),%r12
xor    %eax,%eax
jmp    137a <load_menu+0x20a>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x0(%r13),%ecx
lea    -0x1(%rcx),%edx
cmp    $0x1,%cl
movzbl %dl,%ecx
mov    $0x4,%edx
cmove  %edx,%ecx
mov    %cl,0x0(%r13)
cmp    $0xa,%eax
je     1440 <load_menu+0x2d0>
cmp    $0xd,%eax
je     1440 <load_menu+0x2d0>
movzbl 0x0(%r13),%eax
add    $0xff,%al
cmp    $0x3,%al
ja     140e <load_menu+0x29e>
movzbl %al,%ecx
shl    $0x3,%ecx
mov    $0x2020203e,%eax
shr    %cl,%eax
mov    $0x20203e20,%ebx
shr    %cl,%ebx
mov    $0x203e2020,%r14d
shr    %cl,%r14d
mov    $0x3e202020,%r15d
shr    %cl,%r15d
movsbl %al,%edx
mov    $0x4,%edi
mov    $0x4,%esi
call   1080 <mvaddch@plt>
movsbl %bl,%edx
mov    $0x5,%edi
mov    $0x4,%esi
call   1080 <mvaddch@plt>
movsbl %r14b,%edx
mov    $0x6,%edi
mov    $0x4,%esi
call   1080 <mvaddch@plt>
movsbl %r15b,%edx
mov    $0x7,%edi
mov    $0x4,%esi
call   1080 <mvaddch@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
xor    %eax,%eax
call   1060 <getch@plt>
cmp    0x0(%rbp),%eax
je     1360 <load_menu+0x1f0>
cmp    (%r12),%eax
jne    137a <load_menu+0x20a>
movzbl 0x0(%r13),%ecx
lea    0x1(%rcx),%edx
cmp    $0x4,%cl
movzbl %dl,%ecx
mov    $0x1,%edx
jmp    1373 <load_menu+0x203>
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"saves\\slot_1.sav\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"saves\\slot_2.sav\00"
@.str.3 = [17 x i8] c"saves\\slot_3.sav\00"
@EOF = global i32 0
@.str.4 = [13 x i8] c" \00"
@.str.5 = [15 x i8] c"1: Slot 1 - %s\00"
@.str.6 = [15 x i8] c"2: Slot 2 - %s\00"
@.str.7 = [15 x i8] c"3: Slot 3 - %s\00"
@.str.8 = [10 x i8] c"4: Cancel\00"
@.str.9 = [13 x i8] c"3: Quit Game\00"
@KEY_UP = global i32 0
@KEY_DOWN = global i32 0
define void @load_menu(i8* %0) {
%2 = alloca i8*
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = alloca [50 x i8]
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
store i8* %0, i8** %2
store i32 0, i32* %7
%12 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 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** %9
%13 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %10
%14 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %11
store i8 0, i8* %6
br label %15
15: ; preds = %25, %1
%16 = load i32*, i32** %9
%17 = call i32 @fgetc(i32* %16)
store i32 %17, i32* %8
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32, i32* %8
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
br label %23
23: ; preds = %19, %15
%24 = phi i1 [ false, %15 ], [ %22, %19 ]
br i1 %24, label %25, label %33
25: ; preds = %23
%26 = load i32, i32* %8
%27 = trunc i32 %26 to i8
%28 = load i8, i8* %6
%29 = zext i8 %28 to i64
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %29
store i8 %27, i8* %30
%31 = load i8, i8* %6
%32 = add i8 %31, 1
store i8 %32, i8* %6
br label %15
33: ; preds = %23
%34 = load i8, i8* %6
%35 = zext i8 %34 to i64
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %35
store i8 0, i8* %36
store i8 0, i8* %6
br label %37
37: ; preds = %47, %33
%38 = load i32*, i32** %10
%39 = call i32 @fgetc(i32* %38)
store i32 %39, i32* %8
%40 = icmp ne i32 %39, 10
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i32, i32* %8
%43 = load i32, i32* @EOF
%44 = icmp ne i32 %42, %43
br label %45
45: ; preds = %41, %37
%46 = phi i1 [ false, %37 ], [ %44, %41 ]
br i1 %46, label %47, label %55
47: ; preds = %45
%48 = load i32, i32* %8
%49 = trunc i32 %48 to i8
%50 = load i8, i8* %6
%51 = zext i8 %50 to i64
%52 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %51
store i8 %49, i8* %52
%53 = load i8, i8* %6
%54 = add i8 %53, 1
store i8 %54, i8* %6
br label %37
55: ; preds = %45
%56 = load i8, i8* %6
%57 = zext i8 %56 to i64
%58 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %57
store i8 0, i8* %58
store i8 0, i8* %6
br label %59
59: ; preds = %69, %55
%60 = load i32*, i32** %11
%61 = call i32 @fgetc(i32* %60)
store i32 %61, i32* %8
%62 = icmp ne i32 %61, 10
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = load i32, i32* %8
%65 = load i32, i32* @EOF
%66 = icmp ne i32 %64, %65
br label %67
67: ; preds = %63, %59
%68 = phi i1 [ false, %59 ], [ %66, %63 ]
br i1 %68, label %69, label %77
69: ; preds = %67
%70 = load i32, i32* %8
%71 = trunc i32 %70 to i8
%72 = load i8, i8* %6
%73 = zext i8 %72 to i64
%74 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 %73
store i8 %71, i8* %74
%75 = load i8, i8* %6
%76 = add i8 %75, 1
store i8 %76, i8* %6
br label %59
77: ; preds = %67
%78 = load i8, i8* %6
%79 = zext i8 %78 to i64
%80 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 %79
store i8 0, i8* %80
%81 = load i32*, i32** %9
%82 = call i32 @fclose(i32* %81)
%83 = load i32*, i32** %10
%84 = call i32 @fclose(i32* %83)
%85 = load i32*, i32** %11
%86 = call i32 @fclose(i32* %85)
%87 = load i8*, i8** %2
store i8 1, i8* %87
%88 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 4, i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%89 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%90 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 4, i32 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %89)
%91 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%92 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 5, i32 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %91)
%93 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%94 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 6, i32 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %93)
%95 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 7, i32 5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%96 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 8, i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %97
97: ; preds = %204, %77
%98 = load i32, i32* %7
%99 = icmp ne i32 %98, 10
br i1 %99, label %100, label %103
100: ; preds = %97
%101 = load i32, i32* %7
%102 = icmp ne i32 %101, 13
br label %103
103: ; preds = %100, %97
%104 = phi i1 [ false, %97 ], [ %102, %100 ]
br i1 %104, label %105, label %205
105: ; preds = %103
%106 = load i8*, i8** %2
%107 = load i8, i8* %106
%108 = zext i8 %107 to i32
%109 = icmp eq i32 %108, 1
br i1 %109, label %110, label %116
110: ; preds = %105
%111 = call i32 @mvaddch(i32 4, i32 4, i8 signext 62)
%112 = call i32 @mvaddch(i32 5, i32 4, i8 signext 32)
%113 = call i32 @mvaddch(i32 6, i32 4, i8 signext 32)
%114 = call i32 @mvaddch(i32 7, i32 4, i8 signext 32)
%115 = call i32 (...) @refresh()
br label %152
116: ; preds = %105
%117 = load i8*, i8** %2
%118 = load i8, i8* %117
%119 = zext i8 %118 to i32
%120 = icmp eq i32 %119, 2
br i1 %120, label %121, label %127
121: ; preds = %116
%122 = call i32 @mvaddch(i32 4, i32 4, i8 signext 32)
%123 = call i32 @mvaddch(i32 5, i32 4, i8 signext 62)
%124 = call i32 @mvaddch(i32 6, i32 4, i8 signext 32)
%125 = call i32 @mvaddch(i32 7, i32 4, i8 signext 32)
%126 = call i32 (...) @refresh()
br label %151
127: ; preds = %116
%128 = load i8*, i8** %2
%129 = load i8, i8* %128
%130 = zext i8 %129 to i32
%131 = icmp eq i32 %130, 3
br i1 %131, label %132, label %138
132: ; preds = %127
%133 = call i32 @mvaddch(i32 4, i32 4, i8 signext 32)
%134 = call i32 @mvaddch(i32 5, i32 4, i8 signext 32)
%135 = call i32 @mvaddch(i32 6, i32 4, i8 signext 62)
%136 = call i32 @mvaddch(i32 7, i32 4, i8 signext 32)
%137 = call i32 (...) @refresh()
br label %150
138: ; preds = %127
%139 = load i8*, i8** %2
%140 = load i8, i8* %139
%141 = zext i8 %140 to i32
%142 = icmp eq i32 %141, 4
br i1 %142, label %143, label %149
143: ; preds = %138
%144 = call i32 @mvaddch(i32 4, i32 4, i8 signext 32)
%145 = call i32 @mvaddch(i32 5, i32 4, i8 signext 32)
%146 = call i32 @mvaddch(i32 6, i32 4, i8 signext 32)
%147 = call i32 @mvaddch(i32 7, i32 4, i8 signext 62)
%148 = call i32 (...) @refresh()
br label %149
149: ; preds = %143, %138
br label %150
150: ; preds = %149, %132
br label %151
151: ; preds = %150, %121
br label %152
152: ; preds = %151, %110
%153 = call i32 (...) @getch()
store i32 %153, i32* %7
%154 = load i32, i32* %7
%155 = load i32, i32* @KEY_UP
%156 = icmp eq i32 %154, %155
br i1 %156, label %157, label %166
157: ; preds = %152
%158 = load i8*, i8** %2
%159 = load i8, i8* %158
%160 = zext i8 %159 to i32
%161 = icmp ne i32 %160, 1
br i1 %161, label %162, label %166
162: ; preds = %157
%163 = load i8*, i8** %2
%164 = load i8, i8* %163
%165 = add i8 %164, -1
store i8 %165, i8* %163
br label %204
166: ; preds = %157, %152
%167 = load i32, i32* %7
%168 = load i32, i32* @KEY_UP
%169 = icmp eq i32 %167, %168
br i1 %169, label %170, label %177
170: ; preds = %166
%171 = load i8*, i8** %2
%172 = load i8, i8* %171
%173 = zext i8 %172 to i32
%174 = icmp eq i32 %173, 1
br i1 %174, label %175, label %177
175: ; preds = %170
%176 = load i8*, i8** %2
store i8 4, i8* %176
br label %203
177: ; preds = %170, %166
%178 = load i32, i32* %7
%179 = load i32, i32* @KEY_DOWN
%180 = icmp eq i32 %178, %179
br i1 %180, label %181, label %190
181: ; preds = %177
%182 = load i8*, i8** %2
%183 = load i8, i8* %182
%184 = zext i8 %183 to i32
%185 = icmp ne i32 %184, 4
br i1 %185, label %186, label %190
186: ; preds = %181
%187 = load i8*, i8** %2
%188 = load i8, i8* %187
%189 = add i8 %188, 1
store i8 %189, i8* %187
br label %202
190: ; preds = %181, %177
%191 = load i32, i32* %7
%192 = load i32, i32* @KEY_DOWN
%193 = icmp eq i32 %191, %192
br i1 %193, label %194, label %201
194: ; preds = %190
%195 = load i8*, i8** %2
%196 = load i8, i8* %195
%197 = zext i8 %196 to i32
%198 = icmp eq i32 %197, 4
br i1 %198, label %199, label %201
199: ; preds = %194
%200 = load i8*, i8** %2
store i8 1, i8* %200
br label %201
201: ; preds = %199, %194, %190
br label %202
202: ; preds = %201, %186
br label %203
203: ; preds = %202, %175
br label %204
204: ; preds = %203, %162
br label %97
205: ; preds = %103
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"saves\\slot_1.sav\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"saves\\slot_2.sav\00"
@.str.3 = [17 x i8] c"saves\\slot_3.sav\00"
@EOF = global i32 0
@.str.4 = [13 x i8] c" \00"
@.str.5 = [15 x i8] c"1: Slot 1 - %s\00"
@.str.6 = [15 x i8] c"2: Slot 2 - %s\00"
@.str.7 = [15 x i8] c"3: Slot 3 - %s\00"
@.str.8 = [10 x i8] c"4: Cancel\00"
@.str.9 = [13 x i8] c"3: Quit Game\00"
@KEY_UP = global i32 0
@KEY_DOWN = global i32 0
define void @load_menu(i8* nocapture %0) {
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @fgetc(i32* %8)
%12 = icmp ne i32 %11, 10
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %11, %13
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %16, label %30
16: ; preds = %1, %16
%17 = phi i32 [ %23, %16 ], [ %11, %1 ]
%18 = phi i8 [ %22, %16 ], [ 0, %1 ]
%19 = trunc i32 %17 to i8
%20 = zext i8 %18 to i64
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %20
store i8 %19, i8* %21
%22 = add i8 %18, 1
%23 = tail call i32 @fgetc(i32* %8)
%24 = icmp ne i32 %23, 10
%25 = load i32, i32* @EOF
%26 = icmp ne i32 %23, %25
%27 = select i1 %24, i1 %26, i1 false
br i1 %27, label %16, label %28
28: ; preds = %16
%29 = zext i8 %22 to i64
br label %30
30: ; preds = %28, %1
%31 = phi i64 [ 0, %1 ], [ %29, %28 ]
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %31
store i8 0, i8* %32
%33 = tail call i32 @fgetc(i32* %9)
%34 = icmp ne i32 %33, 10
%35 = load i32, i32* @EOF
%36 = icmp ne i32 %33, %35
%37 = select i1 %34, i1 %36, i1 false
br i1 %37, label %38, label %52
38: ; preds = %30, %38
%39 = phi i32 [ %45, %38 ], [ %33, %30 ]
%40 = phi i8 [ %44, %38 ], [ 0, %30 ]
%41 = trunc i32 %39 to i8
%42 = zext i8 %40 to i64
%43 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %42
store i8 %41, i8* %43
%44 = add i8 %40, 1
%45 = tail call i32 @fgetc(i32* %9)
%46 = icmp ne i32 %45, 10
%47 = load i32, i32* @EOF
%48 = icmp ne i32 %45, %47
%49 = select i1 %46, i1 %48, i1 false
br i1 %49, label %38, label %50
50: ; preds = %38
%51 = zext i8 %44 to i64
br label %52
52: ; preds = %50, %30
%53 = phi i64 [ 0, %30 ], [ %51, %50 ]
%54 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %53
store i8 0, i8* %54
%55 = tail call i32 @fgetc(i32* %10)
%56 = icmp ne i32 %55, 10
%57 = load i32, i32* @EOF
%58 = icmp ne i32 %55, %57
%59 = select i1 %56, i1 %58, i1 false
br i1 %59, label %60, label %74
60: ; preds = %52, %60
%61 = phi i32 [ %67, %60 ], [ %55, %52 ]
%62 = phi i8 [ %66, %60 ], [ 0, %52 ]
%63 = trunc i32 %61 to i8
%64 = zext i8 %62 to i64
%65 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %64
store i8 %63, i8* %65
%66 = add i8 %62, 1
%67 = tail call i32 @fgetc(i32* %10)
%68 = icmp ne i32 %67, 10
%69 = load i32, i32* @EOF
%70 = icmp ne i32 %67, %69
%71 = select i1 %68, i1 %70, i1 false
br i1 %71, label %60, label %72
72: ; preds = %60
%73 = zext i8 %66 to i64
br label %74
74: ; preds = %72, %52
%75 = phi i64 [ 0, %52 ], [ %73, %72 ]
%76 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %75
store i8 0, i8* %76
%77 = tail call i32 @fclose(i32* %8)
%78 = tail call i32 @fclose(i32* %9)
%79 = tail call i32 @fclose(i32* %10)
store i8 1, i8* %0
%80 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 4, i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%81 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 4, i32 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %5)
%82 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 5, i32 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%83 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 6, i32 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%84 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 7, i32 5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%85 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 8, i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %86
86: ; preds = %133, %74
%87 = phi i32 [ 0, %74 ], [ %115, %133 ]
switch i32 %87, label %88 [
i32 13, label %134
i32 10, label %134
]
88: ; preds = %86
%89 = load i8, i8* %0
%90 = add i8 %89, -1
%91 = icmp ult i8 %90, 4
br i1 %91, label %92, label %114
92: ; preds = %88
%93 = zext i8 %90 to i32
%94 = shl nuw nsw i32 %93, 3
%95 = lshr i32 538976318, %94
%96 = trunc i32 %95 to i8
%97 = zext i8 %90 to i32
%98 = shl nuw nsw i32 %97, 3
%99 = lshr i32 538983968, %98
%100 = trunc i32 %99 to i8
%101 = zext i8 %90 to i32
%102 = shl nuw nsw i32 %101, 3
%103 = lshr i32 540942368, %102
%104 = trunc i32 %103 to i8
%105 = zext i8 %90 to i32
%106 = shl nuw nsw i32 %105, 3
%107 = lshr i32 1042292768, %106
%108 = trunc i32 %107 to i8
%109 = call i32 @mvaddch(i32 4, i32 4, i8 signext %96)
%110 = call i32 @mvaddch(i32 5, i32 4, i8 signext %100)
%111 = call i32 @mvaddch(i32 6, i32 4, i8 signext %104)
%112 = call i32 @mvaddch(i32 7, i32 4, i8 signext %108)
%113 = call i32 (...) @refresh()
br label %114
114: ; preds = %88, %92
%115 = call i32 (...) @getch()
%116 = load i32, i32* @KEY_UP
%117 = icmp eq i32 %115, %116
br i1 %117, label %118, label %123
118: ; preds = %114
%119 = load i8, i8* %0
%120 = icmp eq i8 %119, 1
%121 = add i8 %119, -1
%122 = select i1 %120, i8 4, i8 %121
br label %131
123: ; preds = %114
%124 = load i32, i32* @KEY_DOWN
%125 = icmp eq i32 %115, %124
br i1 %125, label %126, label %133
126: ; preds = %123
%127 = load i8, i8* %0
%128 = icmp eq i8 %127, 4
%129 = add i8 %127, 1
%130 = select i1 %128, i8 1, i8 %129
br label %131
131: ; preds = %126, %118
%132 = phi i8 [ %122, %118 ], [ %130, %126 ]
store i8 %132, i8* %0
br label %133
133: ; preds = %131, %123
br label %86
134: ; preds = %86, %86
ret void
}