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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
xorl %r12d, %r12d
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1754
testb %al, %al
je 0x1933
movq %rbx, %rdi
movl %r14d, %esi
movl $0x1, %edx
callq 0x1754
testb %al, %al
je 0x1933
movl $0x2, %r15d
movq %rbx, %rdi
movl %r14d, %esi
movl $0x2, %edx
callq 0x1726
testb %al, %al
jne 0x19c8
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1754
testb %al, %al
je 0x1972
movq %rbx, %rdi
movl %r14d, %esi
movl $0x2, %edx
callq 0x1754
testb %al, %al
je 0x1972
movl $0x1, %r15d
movq %rbx, %rdi
movl %r14d, %esi
movl $0x1, %edx
callq 0x1726
testb %al, %al
jne 0x19c8
movq %rbx, %rdi
movl %r14d, %esi
movl $0x1, %edx
callq 0x1754
testb %al, %al
je 0x19ae
movq %rbx, %rdi
movl %r14d, %esi
movl $0x2, %edx
callq 0x1754
testb %al, %al
je 0x19ae
xorl %r15d, %r15d
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1726
testb %al, %al
jne 0x19c8
cmpl $0x2, %r14d
leal 0x1(%r14), %eax
setae %r12b
movl %eax, %r14d
cmpl $0x3, %eax
jne 0x18f0
jmp 0x19e5
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x16e4
movb $0x1, %r14b
testb $0x1, %r12b
je 0x1c98
xorl %r12d, %r12d
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x1754
testb %al, %al
je 0x1a2e
movq %rbx, %rdi
movl $0x1, %esi
movl %r14d, %edx
callq 0x1754
testb %al, %al
je 0x1a2e
movl $0x2, %r15d
movq %rbx, %rdi
movl $0x2, %esi
movl %r14d, %edx
callq 0x1726
testb %al, %al
jne 0x1ac3
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x1754
testb %al, %al
je 0x1a6d
movq %rbx, %rdi
movl $0x2, %esi
movl %r14d, %edx
callq 0x1754
testb %al, %al
je 0x1a6d
movl $0x1, %r15d
movq %rbx, %rdi
movl $0x1, %esi
movl %r14d, %edx
callq 0x1726
testb %al, %al
jne 0x1ac3
movq %rbx, %rdi
movl $0x1, %esi
movl %r14d, %edx
callq 0x1754
testb %al, %al
je 0x1aa9
movq %rbx, %rdi
movl $0x2, %esi
movl %r14d, %edx
callq 0x1754
testb %al, %al
je 0x1aa9
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x1726
testb %al, %al
jne 0x1ac3
cmpl $0x2, %r14d
leal 0x1(%r14), %eax
setae %r12b
movl %eax, %r14d
cmpl $0x3, %eax
jne 0x19eb
jmp 0x1ae0
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x16e4
movb $0x1, %r14b
testb $0x1, %r12b
je 0x1c98
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1754
testb %al, %al
je 0x1b29
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x1754
testb %al, %al
je 0x1b29
movq %rbx, %rdi
movl $0x2, %esi
movl $0x2, %edx
callq 0x1726
testb %al, %al
je 0x1b29
movq %rbx, %rdi
movl $0x2, %esi
jmp 0x1c89
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1754
testb %al, %al
je 0x1b69
movq %rbx, %rdi
movl $0x2, %esi
movl $0x2, %edx
callq 0x1754
testb %al, %al
je 0x1b69
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x1726
testb %al, %al
jne 0x1c33
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x1754
testb %al, %al
je 0x1bac
movq %rbx, %rdi
movl $0x2, %esi
movl $0x2, %edx
callq 0x1754
testb %al, %al
je 0x1bac
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1726
testb %al, %al
je 0x1bac
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x1bf0
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1754
testb %al, %al
je 0x1bf7
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x1754
testb %al, %al
je 0x1bf7
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x1726
testb %al, %al
je 0x1bf7
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
jmp 0x1c8e
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1754
testb %al, %al
je 0x1c42
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x1754
testb %al, %al
je 0x1c42
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x1726
testb %al, %al
je 0x1c42
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
jmp 0x1c8e
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x1754
xorl %r14d, %r14d
testb %al, %al
je 0x1c98
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x1754
testb %al, %al
je 0x1c98
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1726
testb %al, %al
je 0x1c98
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x16e4
movb $0x1, %r14b
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq