// File: /workspace/github_cpp_makefile_star2_O3/niekh1234[P]nnchesslib/board.cpp
// Function: nnchesslib::ChessBoard::squareAttacked(int, nnchesslib::Color)
bool ChessBoard::squareAttacked(int square, Color color)
{
    BitBoard pawnAttacks = Attacks::getNonSlidingAttacks(square, color, PAWN);
    if(pawnAttacks.board & getBoard(getOppositeColor(color), PAWN).board) return true;

    BitBoard knightAttacks = Attacks::getNonSlidingAttacks(square, color, KNIGHT);
    if(knightAttacks.board & getBoard(getOppositeColor(color), KNIGHT).board) return true;

    BitBoard kingAttacks = Attacks::getNonSlidingAttacks(square, color, KING);
    if(kingAttacks.board & getBoard(getOppositeColor(color), KING).board) return true;

    BitBoard bishopAttacks = Attacks::getSlidingAttacks(square, BISHOP, getBlockers().board);
    if(bishopAttacks.board & getBoard(getOppositeColor(color), BISHOP).board) return true;

    BitBoard rookAttacks = Attacks::getSlidingAttacks(square, ROOK, getBlockers().board);
    if(rookAttacks.board & getBoard(getOppositeColor(color), ROOK).board) return true;

    BitBoard queenAttacks = Attacks::getSlidingAttacks(square, QUEEN, getBlockers().board);
    if(queenAttacks.board & getBoard(getOppositeColor(color), QUEEN).board) return true;

    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %r12d
movl %esi, %r14d
movq %rdi, %rbx
movl %esi, %edi
movl %edx, %esi
xorl %edx, %edx
callq 0x31e5
leaq -0x58(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x3386
movq (%r15), %r13
xorl %r15d, %r15d
cmpl $0x1, %r12d
setne %r15b
movq %rbx, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x4d9e
movq %rax, %rcx
movb $0x1, %al
testq %r13, %rcx
jne 0x5179
movl %r14d, %edi
movl %r12d, %esi
movl $0x1, %edx
callq 0x31e5
leaq -0x50(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x3386
movq (%r13), %r13
movq %rbx, %rdi
movl %r15d, %esi
movl $0x1, %edx
callq 0x4d9e
movq %rax, %rcx
movb $0x1, %al
testq %r13, %rcx
jne 0x5179
movl %r14d, %edi
movl %r12d, %esi
movl $0x5, %edx
callq 0x31e5
leaq -0x48(%rbp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x3386
movq (%r12), %r12
movq %rbx, %rdi
movl %r15d, %esi
movl $0x5, %edx
callq 0x4d9e
movq %rax, %rcx
movb $0x1, %al
testq %r12, %rcx
jne 0x5179
movq 0x8(%rbx), %rsi
orq (%rbx), %rsi
leaq -0x30(%rbp), %r12
movq %r12, %rdi
callq 0x3386
movq (%r12), %rdx
movl %r14d, %edi
movl $0x2, %esi
callq 0x3237
leaq -0x40(%rbp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x3386
movq (%r12), %r12
movq %rbx, %rdi
movl %r15d, %esi
movl $0x2, %edx
callq 0x4d9e
movq %rax, %rcx
movb $0x1, %al
testq %r12, %rcx
jne 0x5179
movq 0x8(%rbx), %rsi
orq (%rbx), %rsi
leaq -0x30(%rbp), %r12
movq %r12, %rdi
callq 0x3386
movq (%r12), %rdx
movl %r14d, %edi
movl $0x3, %esi
callq 0x3237
leaq -0x38(%rbp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x3386
movq (%r12), %r12
movq %rbx, %rdi
movl %r15d, %esi
movl $0x3, %edx
callq 0x4d9e
movq %rax, %rcx
movb $0x1, %al
testq %r12, %rcx
jne 0x5179
movq 0x8(%rbx), %rsi
orq (%rbx), %rsi
leaq -0x30(%rbp), %r12
movq %r12, %rdi
callq 0x3386
movq (%r12), %rdx
movl %r14d, %edi
movl $0x4, %esi
callq 0x3237
leaq -0x30(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x3386
movq (%r14), %r14
movq %rbx, %rdi
movl %r15d, %esi
movl $0x4, %edx
callq 0x4d9e
testq %r14, %rax
setne %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq