// File: /workspace/github_cpp_makefile_star2_O2/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 %r14d, %r14d
pushq $0x1
popq %r15
pushq $0x2
popq %r12
cmpl $0x3, %r14d
je 0x192c
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1732
testb %al, %al
je 0x18b2
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x1732
testb %al, %al
je 0x18b2
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x1706
testb %al, %al
jne 0x1b58
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1732
testb %al, %al
je 0x18eb
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x1732
testb %al, %al
je 0x18eb
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x1706
testb %al, %al
jne 0x1b5c
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x1732
testb %al, %al
je 0x1924
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x1732
testb %al, %al
je 0x1924
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1706
testb %al, %al
jne 0x1b67
incl %r14d
jmp 0x186f
xorl %r14d, %r14d
pushq $0x1
popq %r15
pushq $0x2
popq %r12
movq %rbx, %rdi
xorl %esi, %esi
cmpl $0x3, %r14d
je 0x19f4
movl %r14d, %edx
callq 0x1732
testb %al, %al
je 0x197a
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x1732
testb %al, %al
je 0x197a
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x1706
testb %al, %al
jne 0x1b76
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x1732
testb %al, %al
je 0x19b3
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x1732
testb %al, %al
je 0x19b3
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x1706
testb %al, %al
jne 0x1b7a
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x1732
testb %al, %al
je 0x19ec
movq %rbx, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x1732
testb %al, %al
je 0x19ec
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x1706
testb %al, %al
jne 0x1b82
incl %r14d
jmp 0x1937
xorl %edx, %edx
callq 0x1732
testb %al, %al
je 0x1a28
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1732
testb %al, %al
je 0x1a28
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1706
testb %al, %al
je 0x1a28
pushq $0x2
jmp 0x1b0d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1732
testb %al, %al
je 0x1a5e
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1732
testb %al, %al
je 0x1a5e
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1706
testb %al, %al
jne 0x1b0b
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1732
testb %al, %al
je 0x1a9a
pushq $0x2
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1732
testb %al, %al
je 0x1a9a
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1706
testb %al, %al
je 0x1a9a
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x1b6d
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1732
testb %al, %al
je 0x1ad8
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1732
testb %al, %al
je 0x1ad8
pushq $0x2
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1706
testb %al, %al
je 0x1ad8
pushq $0x2
popq %rsi
movq %rbx, %rdi
jmp 0x1b6d
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1732
testb %al, %al
je 0x1b15
pushq $0x2
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1732
testb %al, %al
je 0x1b15
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1706
testb %al, %al
je 0x1b15
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
jmp 0x1b8a
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %edx, %esi
callq 0x1732
testb %al, %al
je 0x1b71
pushq $0x2
popq %rsi
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1732
testb %al, %al
je 0x1b94
xorl %r14d, %r14d
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1706
testb %al, %al
je 0x1b94
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x1b8a
pushq $0x2
jmp 0x1b5e
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %r14d, %esi
jmp 0x1b8a
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
jmp 0x1b8a
xorl %r14d, %r14d
jmp 0x1b94
pushq $0x2
jmp 0x1b7c
pushq $0x1
popq %rsi
movq %rbx, %rdi
jmp 0x1b87
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