// File: /workspace/github_cpp_makefile_star2_O1/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 0x3682
leaq 0x30(%rsp), %r15
leaq 0x10(%rsp), %r12
movl %r13d, %r14d
movl $0x0, 0x4(%rsp)
testl %r13d, %r13d
jle 0x347c
movq 0x7e57(%rip), %r13      # 0xb248
movq 0x8(%rsp), %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%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 0x10a4(%rip), %rax      # 0x44d2
movq %rax, 0x48(%rsp)
leaq 0x10cc(%rip), %rax      # 0x4506
movq %rax, 0x40(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movl $0x1f, %edx
movq %r15, %rcx
callq 0x6726
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x3469
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 0x33ea
movl %r14d, 0x4(%rsp)
cmpl $0x9, %r14d
jg 0x351e
movq 0x7db6(%rip), %r13      # 0xb248
movq 0x8(%rsp), %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0x20(%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 0x109b(%rip), %rax      # 0x456a
movq %rax, 0x28(%rsp)
leaq 0x10c3(%rip), %rax      # 0x459e
movq %rax, 0x20(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movl $0x1e, %edx
movq %r12, %rcx
callq 0x6726
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x350a
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 0x348b
movq 0x8(%rsp), %rdi
callq 0x2270
movq 0x7aa9(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x20f0
leal -0x41(%rax), %ecx
cmpl $0x1a, %ecx
jb 0x3552
leal -0x30(%rax), %ecx
cmpl $0xa, %ecx
setae %cl
cmpl $0x20, %eax
setne %dl
testb %cl, %dl
jne 0x3570
movl %r14d, %r13d
cmpl $0x9, %r14d
jg 0x33d6
movslq %r14d, %rcx
incl %r14d
movb %al, (%rbx,%rcx)
movl %r14d, %r13d
jmp 0x33d6
leal -0x61(%rax), %ecx
cmpl $0x19, %ecx
ja 0x3599
movl %r14d, %r13d
cmpl $0x9, %r14d
jg 0x33d6
addl $-0x20, %eax
movslq %r14d, %rcx
incl %r14d
movb %al, (%rbx,%rcx)
movl %r14d, %r13d
jmp 0x33d6
cmpl $0x106, %eax            # imm = 0x106
jle 0x35b6
cmpl $0x19a, %eax            # imm = 0x19A
je 0x35db
movl %r14d, %r13d
cmpl $0x107, %eax            # imm = 0x107
je 0x35bb
jmp 0x33d6
cmpl $0x8, %eax
jne 0x3603
movl $0x0, %r13d
testl %r14d, %r14d
je 0x33d6
movslq %r14d, %r13
movb $0x20, -0x1(%rbx,%r13)
decq %r13
jmp 0x33d6
movq 0x7c66(%rip), %rdi      # 0xb248
callq 0x6514
movq 0x8(%rsp), %rdi
callq 0x2060
leaq 0x50(%rsp), %rdi
callq 0x3682
movl %r14d, %r13d
jmp 0x33d6
movl %r14d, %r13d
cmpl $0xa, %eax
jne 0x33d6
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 0x367a
jmp 0x367a
movq %rax, %rbx
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x3672
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x3672
jmp 0x367a
movq %rax, %rbx
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x3672
leaq 0x30(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %rbx, %rdi
callq 0x23c0
movq %rax, %rdi
callq 0x4739