// File: /workspace/github_cpp_makefile_star2_O3/Dalgona[P]mine/mine.cpp
// Function: name_input(score_t&)
void name_input(score_t &score)
{
  int pos = 0;
  int ch;

  curs_set(0);
  WINDOW *nameWin;
  auto drawForm = [&]()
  {
    clear();
    refresh();
    nameWin = newwin(13, 39, scr->getRows() / 2 - 6, scr->getCols() / 2 - 19);
    wattron(nameWin, A_BOLD);
    NIC(18, mvwprintw(nameWin, 0, 5, "C O N G R A T U L A T I O N S"););
    NIC(19, mvwprintw(nameWin, 2, 4, "A   N E W   H I G H   S C O R E"););
    wattroff(nameWin, A_BOLD);
    NIC(11, mvwprintw(nameWin, 4, 0, "What is your name?");
           mvwprintw(nameWin, 8, 0, "Accepted Characters: A-Z, 0-9 and SPACE"););
    NIC(23, mvwprintw(nameWin, 12, 5, "BkSp: ERASE     Enter: DECIDE"););
  };
  drawForm();

  while (true)
  {
    for (int i = 0; i < pos; i++)
      NIC(31, mvwprintw(nameWin, 6, 4 * i, " %c ", score.name[i]););
    for (int i = pos; i < 10; i++)
      NIC(30, mvwprintw(nameWin, 6, 4 * i, " %c ", score.name[i]););
    wrefresh(nameWin);
    ch = getch();
    if ((ch >= 'A' && ch <= 'Z')
        || (ch >= '0' && ch <= '9')
        || ch == ' ')
    { if (pos < 10) score.name[pos++] = ch; }
    else if (ch >= 'a' && ch <= 'z')
    { if (pos < 10) score.name[pos++] = ch - 32; }
    else if (ch == 8 || ch == KEY_BACKSPACE)
    { if (pos != 0) score.name[--pos] = ' '; }
    else if (ch == KEY_RESIZE)
    { scr->updateMaxYX(); delwin(nameWin); drawForm(); }
    else if (ch == 10)
      break;
  }

  delwin(nameWin);
  curs_set(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
xorl %r13d, %r13d
xorl %edi, %edi
callq 0x2190
leaq 0x8(%rsp), %rax
leaq 0x50(%rsp), %rdi
movq %rax, (%rdi)
callq 0x364a
leaq 0x30(%rsp), %r15
leaq 0x10(%rsp), %r12
movl %r13d, %r14d
movl $0x0, 0x4(%rsp)
testl %r13d, %r13d
jle 0x3451
movq 0x7e90(%rip), %r13      # 0xb248
movq 0x8(%rsp), %rbp
movq $0x0, 0x38(%rsp)
movl $0x18, %edi
callq 0x2220
leaq 0x8(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x4(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %rax, 0x30(%rsp)
leaq 0x10df(%rip), %rax      # 0x44d0
movq %rax, 0x48(%rsp)
leaq 0x1107(%rip), %rax      # 0x4504
movq %rax, 0x40(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movl $0x1f, %edx
movq %r15, %rcx
callq 0x66ae
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x342c
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
cmpl %r14d, %eax
jl 0x33b1
movl %r14d, 0x4(%rsp)
cmpl $0x9, %r14d
jle 0x3456
xorl %ebp, %ebp
jmp 0x34e8
movl %r14d, 0x4(%rsp)
movq 0x7deb(%rip), %r13      # 0xb248
movq 0x8(%rsp), %rbp
movq $0x0, 0x18(%rsp)
movl $0x18, %edi
callq 0x2220
leaq 0x8(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x4(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %rax, 0x10(%rsp)
leaq 0x10ce(%rip), %rax      # 0x4564
movq %rax, 0x28(%rsp)
leaq 0x10f6(%rip), %rax      # 0x4598
movq %rax, 0x20(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movl $0x1e, %edx
movq %r12, %rcx
callq 0x66ae
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x34d1
movq %r12, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq *%rax
movl 0x4(%rsp), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x4(%rsp)
cmpl $0x9, %eax
jl 0x3456
movb $0x1, %bpl
movq 0x8(%rsp), %rdi
callq 0x2270
movq 0x7adf(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x20f0
leal -0x41(%rax), %ecx
cmpl $0x1a, %ecx
jb 0x351c
leal -0x30(%rax), %ecx
cmpl $0xa, %ecx
setae %cl
cmpl $0x20, %eax
setne %dl
testb %cl, %dl
jne 0x3539
movl %r14d, %r13d
testb %bpl, %bpl
je 0x339d
movslq %r14d, %rcx
incl %r14d
movb %al, (%rbx,%rcx)
movl %r14d, %r13d
jmp 0x339d
leal -0x61(%rax), %ecx
cmpl $0x19, %ecx
ja 0x3561
movl %r14d, %r13d
testb %bpl, %bpl
je 0x339d
addl $-0x20, %eax
movslq %r14d, %rcx
incl %r14d
movb %al, (%rbx,%rcx)
movl %r14d, %r13d
jmp 0x339d
cmpl $0x106, %eax            # imm = 0x106
jle 0x357e
cmpl $0x19a, %eax            # imm = 0x19A
je 0x35a3
movl %r14d, %r13d
cmpl $0x107, %eax            # imm = 0x107
je 0x3583
jmp 0x339d
cmpl $0x8, %eax
jne 0x35cb
movl $0x0, %r13d
testl %r14d, %r14d
je 0x339d
movslq %r14d, %r13
movb $0x20, -0x1(%rbx,%r13)
decq %r13
jmp 0x339d
movq 0x7c9e(%rip), %rdi      # 0xb248
callq 0x649a
movq 0x8(%rsp), %rdi
callq 0x2060
leaq 0x50(%rsp), %rdi
callq 0x364a
movl %r14d, %r13d
jmp 0x339d
movl %r14d, %r13d
cmpl $0xa, %eax
jne 0x339d
movq 0x8(%rsp), %rdi
callq 0x2060
movl $0x1, %edi
callq 0x2190
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3642
jmp 0x3642
movq %rax, %rbx
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x363a
leaq 0x30(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x363a
jmp 0x3642
movq %rax, %rbx
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x363a
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %rbx, %rdi
callq 0x23c0
movq %rax, %rdi
callq 0x4729