// File: /workspace/github_cpp_makefile_star2_O2/t3nma[P]sdl2-TicTacToe/src/Bot.cpp
// Function: Bot::hard(Board&) const
bool Bot::hard(Board &board) const
{
    // can win on a row?
    for(int i=0; i<3; i++)
    {
        if(board.isFieldCircle(i,0) && board.isFieldCircle(i,1) && board.isFieldEmpty(i,2))
        {
            board.place(i,2,false);
            return true;
        }

        if(board.isFieldCircle(i,0) && board.isFieldCircle(i,2) && board.isFieldEmpty(i,1))
        {
            board.place(i,1,false);
            return true;
        }

        if(board.isFieldCircle(i,1) && board.isFieldCircle(i,2) && board.isFieldEmpty(i,0))
        {
            board.place(i,0,false);
            return true;
        }
    }

    // can win on a column?
    for(int j=0; j<3; j++)
    {
        if(board.isFieldCircle(0,j) && board.isFieldCircle(1,j) && board.isFieldEmpty(2,j))
        {
            board.place(2,j,false);
            return true;
        }
        else if(board.isFieldCircle(0,j) && board.isFieldCircle(2,j) && board.isFieldEmpty(1,j))
        {
            board.place(1,j,false);
            return true;
        }
        else if(board.isFieldCircle(1,j) && board.isFieldCircle(2,j) && board.isFieldEmpty(0,j))
        {
            board.place(0,j,false);
            return true;
        }
    }

    // can win on a diagonal?
    if(board.isFieldCircle(0,0) && board.isFieldCircle(1,1) && board.isFieldEmpty(2,2))
    {
        board.place(2,2,false);
        return true;
    }
    else if(board.isFieldCircle(0,0) && board.isFieldCircle(2,2) && board.isFieldEmpty(1,1))
    {
        board.place(1,1,false);
        return true;
    }
    else if(board.isFieldCircle(1,1) && board.isFieldCircle(2,2) && board.isFieldEmpty(0,0))
    {
        board.place(0,0,false);
        return true;
    }
    else if(board.isFieldCircle(0,2) && board.isFieldCircle(1,1) && board.isFieldEmpty(2,0))
    {
        board.place(2,0,false);
        return true;
    }
    else if(board.isFieldCircle(0,2) && board.isFieldCircle(2,0) && board.isFieldEmpty(1,1))
    {
        board.place(1,1,false);
        return true;
    }
    else if(board.isFieldCircle(1,1) && board.isFieldCircle(2,2) && board.isFieldEmpty(0,2))
    {
        board.place(0,2,false);
        return true;
    }

    return false; // no possible way to win
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
xorl %r14d, %r14d
pushq $0x1
popq %r15
pushq $0x2
popq %r12
cmpl $0x3, %r14d
je 0x1c76
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x175e
testb %al, %al
je 0x1bfc
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x175e
testb %al, %al
je 0x1bfc
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x1706
testb %al, %al
jne 0x1e9f
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x175e
testb %al, %al
je 0x1c35
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x175e
testb %al, %al
je 0x1c35
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x1706
testb %al, %al
jne 0x1ea3
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x175e
testb %al, %al
je 0x1c6e
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x175e
testb %al, %al
je 0x1c6e
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1706
testb %al, %al
jne 0x1eae
incl %r14d
jmp 0x1bb9
xorl %r14d, %r14d
pushq $0x1
popq %r15
pushq $0x2
popq %r12
movq %rbx, %rdi
xorl %esi, %esi
cmpl $0x3, %r14d
je 0x1d3e
movl %r14d, %edx
callq 0x175e
testb %al, %al
je 0x1cc4
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x175e
testb %al, %al
je 0x1cc4
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x1706
testb %al, %al
jne 0x1ebd
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x175e
testb %al, %al
je 0x1cfd
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x175e
testb %al, %al
je 0x1cfd
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x1706
testb %al, %al
jne 0x1ec1
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x175e
testb %al, %al
je 0x1d36
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x175e
testb %al, %al
je 0x1d36
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x1706
testb %al, %al
jne 0x1ec9
incl %r14d
jmp 0x1c81
xorl %edx, %edx
callq 0x175e
testb %al, %al
je 0x1d72
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x175e
testb %al, %al
je 0x1d72
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1706
testb %al, %al
je 0x1d72
pushq $0x2
jmp 0x1e57
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x175e
testb %al, %al
je 0x1da8
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x175e
testb %al, %al
je 0x1da8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1706
testb %al, %al
jne 0x1e55
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x175e
testb %al, %al
je 0x1de4
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x175e
testb %al, %al
je 0x1de4
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1706
testb %al, %al
je 0x1de4
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x1eb4
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x175e
testb %al, %al
je 0x1e22
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x175e
testb %al, %al
je 0x1e22
pushq $0x2
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1706
testb %al, %al
je 0x1e22
pushq $0x2
popq %rsi
movq %rbx, %rdi
jmp 0x1eb4
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x175e
testb %al, %al
je 0x1e5f
pushq $0x2
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x175e
testb %al, %al
je 0x1e5f
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1706
testb %al, %al
je 0x1e5f
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
jmp 0x1ed1
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x175e
testb %al, %al
je 0x1eb8
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x175e
testb %al, %al
je 0x1eb8
xorl %r14d, %r14d
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1706
testb %al, %al
je 0x1edb
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x1ed1
pushq $0x2
jmp 0x1ea5
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %r14d, %esi
jmp 0x1ed1
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
jmp 0x1ed1
xorl %r14d, %r14d
jmp 0x1edb
pushq $0x2
jmp 0x1ec3
pushq $0x1
popq %rsi
movq %rbx, %rdi
jmp 0x1ece
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x16c6
movb $0x1, %r14b
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop