// File: nesro[P]NCursesGomoku/src/local.cpp
// Function: CLocal::nextMove()
void CLocal::nextMove(void) {

    /* nothing to do here */
    if (m_IsWinner == true) {
        return;
    }

    int key;

    char message[CBoard::MESSAGE_LENGTH];
    memset(message, '\0', CBoard::MESSAGE_LENGTH);
    sprintf(message, " Your (%c) turn!", m_Mark);
    m_Board->printMessage(message);

    /* make cursor visible */
    curs_set(2);

    for (;;) {
        key = getch();

        switch (key) {
            case KEY_UP:
                m_Board->moveCursor(CBoard::DIRECTION_UP);
                break;
                
            case KEY_DOWN:
                m_Board->moveCursor(CBoard::DIRECTION_DOWN);
                break;
                
            case KEY_LEFT:
                m_Board->moveCursor(CBoard::DIRECTION_LEFT);
                break;
                
            case KEY_RIGHT:
                m_Board->moveCursor(CBoard::DIRECTION_RIGHT);
                break;
                
            case 'w':
            case 'W':
            case ' ':
                if (m_Board->addStone(m_Mark, -1, -1)) {
                    curs_set(0);
                    return;
                }
                
                break;
                
            case 'q':
            case 'Q':
                m_Surrender = true;

                curs_set(0);
                return;

                break;
                
            default:
                break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movb 0xa(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x6296
jmp 0x63f7
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x3180
movq -0x38(%rbp), %rax
leaq -0x30(%rbp), %rdi
movsbl 0x9(%rax), %edx
leaq 0x2aed(%rip), %rsi      # 0x8da6
movb $0x0, %al
callq 0x3080
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4d00
movl $0x2, %edi
callq 0x31f0
movq 0x5ce6(%rip), %rax      # 0xbfc8
movq (%rax), %rdi
callq 0x3100
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
subl $0x20, %eax
je 0x63b6
jmp 0x62fe
movl -0x3c(%rbp), %eax
subl $0x51, %eax
je 0x63df
jmp 0x630c
movl -0x3c(%rbp), %eax
subl $0x57, %eax
je 0x63b6
jmp 0x631a
movl -0x3c(%rbp), %eax
subl $0x71, %eax
je 0x63df
jmp 0x6328
movl -0x3c(%rbp), %eax
subl $0x77, %eax
je 0x63b6
jmp 0x6336
movl -0x3c(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x637a
jmp 0x6342
movl -0x3c(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x6369
jmp 0x634e
movl -0x3c(%rbp), %eax
subl $0x104, %eax            # imm = 0x104
je 0x638e
jmp 0x635a
movl -0x3c(%rbp), %eax
subl $0x105, %eax            # imm = 0x105
je 0x63a2
jmp 0x63f0
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
xorl %esi, %esi
callq 0x4640
jmp 0x63f2
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x2, %esi
callq 0x4640
jmp 0x63f2
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %esi
callq 0x4640
jmp 0x63f2
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x3, %esi
callq 0x4640
jmp 0x63f2
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movsbl 0x9(%rax), %esi
movl %ecx, %edx
callq 0x4590
testb $0x1, %al
jne 0x63d4
jmp 0x63dd
xorl %edi, %edi
callq 0x31f0
jmp 0x63f7
jmp 0x63f2
movq -0x38(%rbp), %rax
movb $0x1, 0x8(%rax)
xorl %edi, %edi
callq 0x31f0
jmp 0x63f7
jmp 0x63f2
jmp 0x62db
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)