#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int gethiscorelist(char *);
char getkeypress_block(int);
int /*<<< orphan*/ newln(int);
int /*<<< orphan*/ printmenuitem(char *, int);
int /*<<< orphan*/ printstr(char *);
int /*<<< orphan*/ readhiscores(int /*<<< orphan*/ *);
int /*<<< orphan*/ refreshwin(int);
int /*<<< orphan*/ setattr_normal();
int /*<<< orphan*/ setcolorpair(int);
int /*<<< orphan*/ setcurs(int, int);
void show_hiscorelist(int x, int y) {
  char buf[320];
  char *p;
  int n;
  setcurs(x, y);
  printmenuitem("Highscores", 1);
  newln(x);
  setcolorpair(8);
  printstr("    Name      Score  Lvl  Lines");
  newln(x);
  setattr_normal();
  if (!readhiscores(NULL)) {
    printstr("    No saved scores");
    newln(x);
  } else {
    n = gethiscorelist(buf);
    p = buf;
    while (n) {
      p[30] = '\0';
      printstr(p);
      newln(x);
      p += 32;
      n--;
    }
  }
  refreshwin(-1);
  if (getkeypress_block(0x800) == 'q')
    exit(0);
}


x86 assembly (clang, -O0):
<show_hiscorelist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1080 <setcurs@plt>
lea    0xe2d(%rip),%rdi
mov    $0x1,%esi
call   10d0 <printmenuitem@plt>
mov    -0x4(%rbp),%edi
call   1060 <newln@plt>
mov    $0x8,%edi
call   1040 <setcolorpair@plt>
lea    0xe15(%rip),%rdi
call   1070 <printstr@plt>
mov    -0x4(%rbp),%edi
call   1060 <newln@plt>
mov    $0x0,%al
call   1050 <setattr_normal@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <readhiscores@plt>
cmp    $0x0,%eax
jne    1235 <show_hiscorelist+0x85>
lea    0xe08(%rip),%rdi
call   1070 <printstr@plt>
mov    -0x4(%rbp),%edi
call   1060 <newln@plt>
jmp    12ac <show_hiscorelist+0xfc>
lea    -0x150(%rbp),%rdi
call   1090 <gethiscorelist@plt>
mov    %eax,-0x15c(%rbp)
lea    -0x150(%rbp),%rax
mov    %rax,-0x158(%rbp)
cmpl   $0x0,-0x15c(%rbp)
je     12a7 <show_hiscorelist+0xf7>
mov    -0x158(%rbp),%rax
movb   $0x0,0x1e(%rax)
mov    -0x158(%rbp),%rdi
call   1070 <printstr@plt>
mov    -0x4(%rbp),%edi
call   1060 <newln@plt>
mov    -0x158(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x158(%rbp)
mov    -0x15c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x15c(%rbp)
jmp    1255 <show_hiscorelist+0xa5>
jmp    12ac <show_hiscorelist+0xfc>
mov    $0xffffffff,%edi
call   10a0 <refreshwin@plt>
mov    $0x800,%edi
call   1030 <getkeypress_block@plt>
movsbl %al,%eax
cmp    $0x71,%eax
jne    12d3 <show_hiscorelist+0x123>
xor    %edi,%edi
call   10c0 <exit@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_hiscorelist>:
push   %rbp
push   %r14
push   %rbx
sub    $0x140,%rsp
mov    %edi,%r14d
call   1080 <setcurs@plt>
lea    0xe36(%rip),%rdi
mov    $0x1,%esi
call   10d0 <printmenuitem@plt>
mov    %r14d,%edi
call   1060 <newln@plt>
mov    $0x8,%edi
call   1040 <setcolorpair@plt>
lea    0xe1e(%rip),%rdi
call   1070 <printstr@plt>
mov    %r14d,%edi
call   1060 <newln@plt>
xor    %eax,%eax
call   1050 <setattr_normal@plt>
xor    %edi,%edi
call   10b0 <readhiscores@plt>
test   %eax,%eax
je     123f <show_hiscorelist+0x8f>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1090 <gethiscorelist@plt>
test   %eax,%eax
je     1253 <show_hiscorelist+0xa3>
mov    %eax,%ebp
nopl   (%rax)
movb   $0x0,0x1e(%rbx)
mov    %rbx,%rdi
call   1070 <printstr@plt>
mov    %r14d,%edi
call   1060 <newln@plt>
add    $0x20,%rbx
add    $0xffffffff,%ebp
jne    1220 <show_hiscorelist+0x70>
jmp    1253 <show_hiscorelist+0xa3>
lea    0xde5(%rip),%rdi
call   1070 <printstr@plt>
mov    %r14d,%edi
call   1060 <newln@plt>
mov    $0xffffffff,%edi
call   10a0 <refreshwin@plt>
mov    $0x800,%edi
call   1030 <getkeypress_block@plt>
cmp    $0x71,%al
je     1277 <show_hiscorelist+0xc7>
add    $0x140,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"Highscores\00"
@.str.1 = [32 x i8] c" Name Score Lvl Lines\00"
@.str.2 = [20 x i8] c" No saved scores\00"
define void @show_hiscorelist(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [320 x i8]
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @setcurs(i32 %8, i32 %9)
%11 = call i32 @printmenuitem(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1)
%12 = load i32, i32* %3
%13 = call i32 @newln(i32 %12)
%14 = call i32 @setcolorpair(i32 8)
%15 = call i32 @printstr(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = call i32 @newln(i32 %16)
%18 = call i32 (...) @setattr_normal()
%19 = call i32 @readhiscores(i32* null)
%20 = icmp ne i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %2
%22 = call i32 @printstr(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* %3
%24 = call i32 @newln(i32 %23)
br label %44
25: ; preds = %2
%26 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 0
%27 = call i32 @gethiscorelist(i8* %26)
store i32 %27, i32* %7
%28 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 0
store i8* %28, i8** %6
br label %29
29: ; preds = %32, %25
%30 = load i32, i32* %7
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %43
32: ; preds = %29
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 30
store i8 0, i8* %34
%35 = load i8*, i8** %6
%36 = call i32 @printstr(i8* %35)
%37 = load i32, i32* %3
%38 = call i32 @newln(i32 %37)
%39 = load i8*, i8** %6
%40 = getelementptr inbounds i8, i8* %39, i64 32
store i8* %40, i8** %6
%41 = load i32, i32* %7
%42 = add nsw i32 %41, -1
store i32 %42, i32* %7
br label %29
43: ; preds = %29
br label %44
44: ; preds = %43, %21
%45 = call i32 @refreshwin(i32 -1)
%46 = call signext i8 @getkeypress_block(i32 2048)
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 113
br i1 %48, label %49, label %51
49: ; preds = %44
%50 = call i32 @exit(i32 0)
unreachable
51: ; preds = %44
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Highscores\00"
@.str.1 = [32 x i8] c" Name Score Lvl Lines\00"
@.str.2 = [20 x i8] c" No saved scores\00"
define void @show_hiscorelist(i32 %0, i32 %1) {
%3 = alloca [320 x i8]
%4 = getelementptr inbounds [320 x i8], [320 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @setcurs(i32 %0, i32 %1)
%6 = tail call i32 @printmenuitem(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1)
%7 = tail call i32 @newln(i32 %0)
%8 = tail call i32 @setcolorpair(i32 8)
%9 = tail call i32 @printstr(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @newln(i32 %0)
%11 = tail call i32 (...) @setattr_normal()
%12 = tail call i32 @readhiscores(i32* null)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = tail call i32 @printstr(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @newln(i32 %0)
br label %29
17: ; preds = %2
%18 = call i32 @gethiscorelist(i8* %4)
%19 = icmp eq i32 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %17, %20
%21 = phi i32 [ %27, %20 ], [ %18, %17 ]
%22 = phi i8* [ %26, %20 ], [ %4, %17 ]
%23 = getelementptr inbounds i8, i8* %22, i64 30
store i8 0, i8* %23
%24 = call i32 @printstr(i8* %22)
%25 = call i32 @newln(i32 %0)
%26 = getelementptr inbounds i8, i8* %22, i64 32
%27 = add nsw i32 %21, -1
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %20
29: ; preds = %20, %17, %14
%30 = call i32 @refreshwin(i32 -1)
%31 = call signext i8 @getkeypress_block(i32 2048)
%32 = icmp eq i8 %31, 113
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @exit(i32 0)
unreachable
35: ; preds = %29
ret void
}