// File: /workspace/github_cpp_makefile_star2_O2/Dalgona[P]mine/mine.cpp
// Function: arcade_leaderboard()
void arcade_leaderboard(void)
{
  FILE *data = fopen("scores.dat", "rb");
  int fd = fileno(data);
  flock(fd, LOCK_EX);
  for (int i = 0; i < 3; i++)
  {
    scores[i].resize(5);
    for (int j = 0; j < 5; j++)
    {
      fread(scores[i][j].name, 11, 1, data);
      fread(&scores[i][j].time, 4, 1, data);
    }
  }
  flock(fd, LOCK_UN);
  fclose(data);

  refresh();
  WINDOW *lbw = newwin(9, 78, 8, 1);

  wattron(lbw, A_BOLD);
  LBC(14, mvwprintw(lbw, 0, 27, " H A L L   O F   F A M E "););
  LBC(15, mvwprintw(lbw, 2, 8, "BEGINNER"););
  LBC(16, mvwprintw(lbw, 2, 33, "INTERMEDIATE"););
  LBC(17, mvwprintw(lbw, 2, 63, "EXPERT"););
  wattroff(lbw, A_BOLD);

  const char *nth[] { "1st", "2nd", "3rd", "4th", "5th" };
  int iPart, dPart;
  for (int i = 0; i < 3; i++)
  {
    int col = 27 * i;
    for (int j = 0; j < 5; j++)
    {
      score_t &sc = scores[i][j];
      if (sc.time > 999999) iPart = 9999, dPart = 99;
      else iPart = sc.time / 100, dPart = sc.time % 100;
      LBC(20 + j, mvwprintw(lbw, 4 + j, col, "%s", nth[j]););
      wprintw(lbw, "  %10s  %04d.%02d", sc.name, iPart, dPart);
    }
  }

  wrefresh(lbw);
  delwin(lbw);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
leaq 0x3575(%rip), %rdi      # 0x6294
leaq 0x357c(%rip), %rsi      # 0x62a2
callq 0x22b0
movq %rax, %rbx
movq %rax, %rdi
callq 0x2250
pushq $0x2
popq %rsi
movl %eax, 0x18(%rsp)
movl %eax, %edi
callq 0x23f0
xorl %eax, %eax
pushq $0xb
popq %r15
pushq $0x1
popq %r12
pushq $0x4
popq %r13
cmpq $0x3, %rax
je 0x2dbf
movq %rax, 0x20(%rsp)
imulq $0x18, %rax, %rbp
leaq 0x74e8(%rip), %rax      # 0xa250
addq %rax, %rbp
movq %rbp, %rdi
pushq $0x5
popq %rsi
callq 0x41cc
pushq $0xc
popq %r14
cmpq $0x5c, %r14
je 0x2db5
movq (%rbp), %rax
leaq (%rax,%r14), %rdi
addq $-0xc, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2340
movq (%rbp), %rdi
addq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2340
addq $0x10, %r14
jmp 0x2d7a
movq 0x20(%rsp), %rax
incq %rax
jmp 0x2d52
pushq $0x8
popq %rbp
movl 0x18(%rsp), %edi
movl %ebp, %esi
callq 0x23f0
movq %rbx, %rdi
callq 0x2200
callq 0x23b0
pushq $0x9
popq %rdi
pushq $0x4e
popq %rsi
pushq $0x1
popq %rcx
movl %ebp, %edx
callq 0x2220
movq %rax, %rbx
leaq 0x8(%rsp), %r14
movq %rax, (%r14)
movq %rax, %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x2140
movq 0x743d(%rip), %rdi      # 0xa248
leaq 0xc0(%rsp), %rcx
andq $0x0, 0x8(%rcx)
movq %r14, (%rcx)
leaq 0x106c(%rip), %rax      # 0x3e8e
movq %rax, 0x18(%rcx)
leaq 0x107b(%rip), %rax      # 0x3ea8
movq %rax, 0x10(%rcx)
pushq $0xe
popq %rdx
movq %rbx, %rsi
callq 0x5e58
leaq 0xc0(%rsp), %rdi
callq 0x4200
movq 0x73f8(%rip), %rdi      # 0xa248
movq 0x8(%rsp), %rsi
leaq 0xa0(%rsp), %rcx
andq $0x0, 0x8(%rcx)
movq %r14, (%rcx)
leaq 0x1062(%rip), %rax      # 0x3ece
movq %rax, 0x18(%rcx)
leaq 0x1071(%rip), %rax      # 0x3ee8
movq %rax, 0x10(%rcx)
pushq $0xf
popq %rdx
callq 0x5e58
leaq 0xa0(%rsp), %rdi
callq 0x4200
movq 0x73b1(%rip), %rdi      # 0xa248
movq 0x8(%rsp), %rsi
leaq 0x80(%rsp), %rcx
andq $0x0, 0x8(%rcx)
movq %r14, (%rcx)
leaq 0x105b(%rip), %rax      # 0x3f0e
movq %rax, 0x18(%rcx)
leaq 0x106a(%rip), %rax      # 0x3f28
movq %rax, 0x10(%rcx)
pushq $0x10
popq %rdx
callq 0x5e58
leaq 0x80(%rsp), %rdi
callq 0x4200
movq 0x736a(%rip), %rdi      # 0xa248
movq 0x8(%rsp), %rsi
leaq 0x60(%rsp), %rcx
andq $0x0, 0x8(%rcx)
movq %r14, (%rcx)
leaq 0x1057(%rip), %rax      # 0x3f4e
movq %rax, 0x18(%rcx)
leaq 0x1066(%rip), %rax      # 0x3f68
movq %rax, 0x10(%rcx)
pushq $0x11
popq %rdx
callq 0x5e58
leaq 0x60(%rsp), %rdi
callq 0x4200
movq 0x8(%rsp), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x22d0
movq 0x6cf0(%rip), %rax      # 0x9c20
leaq 0xe0(%rsp), %rcx
movq %rax, 0x20(%rcx)
movaps 0x6ccd(%rip), %xmm0     # 0x9c10
movaps %xmm0, 0x10(%rcx)
movaps 0x6cb2(%rip), %xmm0     # 0x9c00
movaps %xmm0, (%rcx)
xorl %ecx, %ecx
cmpq $0x3, %rcx
je 0x3080
imull $0x1b, %ecx, %eax
movl %eax, 0x2c(%rsp)
movq %rcx, 0x58(%rsp)
imulq $0x18, %rcx, %rcx
leaq 0x72dc(%rip), %rax      # 0xa250
addq %rax, %rcx
movq %rcx, 0x18(%rsp)
xorl %ebp, %ebp
movl %ebp, 0x14(%rsp)
cmpl $0x5, %ebp
jge 0x3073
movslq %ebp, %r13
movq 0x18(%rsp), %rax
movq (%rax), %rax
shlq $0x4, %r13
movq %rax, 0x20(%rsp)
movl 0xc(%rax,%r13), %eax
movl $0x270f, %ecx           # imm = 0x270F
pushq $0x63
popq %r12
cmpl $0xf423f, %eax          # imm = 0xF423F
jg 0x2fbf
cltd
pushq $0x64
popq %rcx
idivl %ecx
movl %edx, %r12d
movl %eax, %ecx
movl %ecx, %ebx
movq 0x7280(%rip), %r15      # 0xa248
movq 0x8(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
pushq $0x20
popq %rdi
callq 0x2210
addl $0x14, %ebp
leaq 0x8(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x14(%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x2c(%rsp), %rcx
movq %rcx, 0x10(%rax)
leaq 0xe0(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq %rax, 0x30(%rsp)
leaq 0xf77(%rip), %rax       # 0x3f8e
movq %rax, 0x48(%rsp)
leaq 0xf9b(%rip), %rax       # 0x3fbe
movq %rax, 0x40(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
leaq 0x30(%rsp), %r14
movq %r14, %rcx
callq 0x5e58
movq 0x20(%rsp), %r15
addq %r13, %r15
movq %r14, %rdi
callq 0x4200
movq 0x8(%rsp), %rdi
leaq 0x3260(%rip), %rsi      # 0x62b9
movq %r15, %rdx
movl %ebx, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x2050
movl 0x14(%rsp), %ebp
incl %ebp
jmp 0x2f7e
movq 0x58(%rsp), %rcx
incq %rcx
jmp 0x2f53
movq 0x8(%rsp), %rdi
callq 0x2260
movq 0x8(%rsp), %rdi
callq 0x2060
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x30e1
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x30e1
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x30e1
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x30e1
jmp 0x30d9
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4200
movq %rbx, %rdi
callq 0x23d0