// File: /workspace/github_cpp_makefile_star2_O1/tyhsu[P]Ewn/play.cpp
// Function: Play::player_move(int const&)
Movement Play::player_move(const int& dice)
{
    int movable_chs_cnt = this->game.count_movable_chs(dice);
    int chs_index, direct;
    Movement mvmt;

    do {
        cout << endl << "Next chessman able to move: ";
        for (int i=0; i<movable_chs_cnt; i++)
            cout << i << ")" << this->game.get_movable_chs(i).symbol << " ";
        cout << endl;
        cout << "Choose: ";
        cin >> chs_index;

        if (!this->game.get_is_switch())
            cout << "Direction: 0)Right 1)Down 2)Right-down" << endl;
        else
            cout << "Direction: 0)Left 1)Up 2)Left-up" << endl;
        cout << "Choose: ";
        cin >> direct;

        // get index
        chs_index = (this->game.get_is_switch() == false) ? this->game.get_movable_chs(chs_index).symbol - '1' : this->game.get_movable_chs(chs_index).symbol - 'A';
        mvmt.first = chs_index;
        mvmt.second = direct;
        //If the movement is illegal, run the loop
    } while (!this->game.check_in_board(mvmt));

    return mvmt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
callq 0x800c
movl %eax, %r12d
leaq -0x40(%rbp), %rax
movq $0x0, (%rax)
movq 0xa6ee(%rip), %r15      # 0xcfc8
movq %rbx, -0x50(%rbp)
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
movl $0x1c, %edx
movq %rax, %rdi
leaq 0x67bc(%rip), %rsi      # 0x90d0
callq 0x2170
movl $0x0, -0x30(%rbp)
testl %r12d, %r12d
movl %r12d, %r14d
movq %r15, %rbx
leaq -0x29(%rbp), %r13
leaq 0x6beb(%rip), %r15      # 0x951f
jle 0x29a6
xorl %esi, %esi
movq %rbx, %rdi
callq 0x21f0
movq %rbx, %r12
movq %r15, %rbx
movq %r13, %r15
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6c37(%rip), %rsi      # 0x9592
callq 0x2170
movq -0x50(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x86ca
movb %al, -0x29(%rbp)
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %r13
movq %rbx, %r15
movq %r12, %rbx
movq %r13, %rsi
callq 0x2170
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
movl -0x30(%rbp), %esi
incl %esi
movl %esi, -0x30(%rbp)
cmpl %r14d, %esi
jl 0x2938
movl %r14d, %r12d
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
movl $0x8, %edx
movq %rbx, %rdi
leaq 0x66c2(%rip), %rsi      # 0x90a1
callq 0x2170
movq 0xa5ed(%rip), %rdi      # 0xcfd8
leaq -0x34(%rbp), %rsi
callq 0x20a0
movq -0x50(%rbp), %rdi
movq %rdi, %r14
callq 0x872e
testb %al, %al
movq %rbx, %r15
je 0x2a18
movl $0x20, %edx
movq %r15, %rdi
leaq 0x66fe(%rip), %rsi      # 0x9114
jmp 0x2a27
movl $0x26, %edx
movq %r15, %rdi
leaq 0x66c6(%rip), %rsi      # 0x90ed
callq 0x2170
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20c0
movl $0x8, %edx
movq %r15, %rdi
leaq 0x663f(%rip), %rsi      # 0x90a1
callq 0x2170
movq 0xa56a(%rip), %rdi      # 0xcfd8
leaq -0x44(%rbp), %rsi
callq 0x20a0
movq %r14, %rdi
callq 0x872e
xorb $0x1, %al
movzbl %al, %r13d
shll $0x4, %r13d
movq %r14, %rdi
leaq -0x34(%rbp), %rsi
callq 0x86ca
movsbl %al, %eax
addl %r13d, %eax
addl $-0x41, %eax
movl %eax, -0x34(%rbp)
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq %r14, %rdi
leaq -0x40(%rbp), %rsi
callq 0x8118
testb %al, %al
je 0x28de
movq -0x40(%rbp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop