// File: /workspace/github_cpp_makefile_star2_O2/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, %r13
movl %esi, %edi
movl %edx, %esi
xorl %edx, %edx
callq 0x2e6e
leaq -0x60(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x3036
movq (%r15), %rbx
xorl %r15d, %r15d
cmpl $0x1, %r12d
setne %r15b
movq %r13, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x4388
movq %rax, %rcx
movb $0x1, %al
testq %rbx, %rcx
jne 0x4720
pushq $0x1
popq %rdx
movl %r14d, %edi
movl %r12d, %esi
callq 0x2e6e
leaq -0x58(%rbp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3036
movq (%rbx), %rbx
movq %r13, -0x30(%rbp)
movq %r13, %rdi
movl %r15d, %esi
pushq $0x1
popq %rdx
callq 0x4388
movq %rax, %rcx
movb $0x1, %al
testq %rbx, %rcx
jne 0x4720
pushq $0x5
popq %rbx
movl %r14d, %edi
movl %r12d, %esi
movl %ebx, %edx
callq 0x2e6e
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x3036
movq (%r12), %r12
movq -0x30(%rbp), %r13
movq %r13, %rdi
movl %r15d, %esi
movl %ebx, %edx
callq 0x4388
movq %rax, %rcx
movb $0x1, %al
testq %r12, %rcx
jne 0x4720
movq %r13, %rdi
callq 0x445a
pushq $0x2
popq %rbx
movl %r14d, %edi
movl %ebx, %esi
movq %rax, %rdx
callq 0x2ec2
leaq -0x48(%rbp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x3036
movq (%r12), %r12
movq %r13, %rdi
movl %r15d, %esi
movl %ebx, %edx
callq 0x4388
movq %rax, %rcx
movb $0x1, %al
testq %r12, %rcx
jne 0x4720
movq %r13, %rdi
callq 0x445a
pushq $0x3
popq %rbx
movl %r14d, %edi
movl %ebx, %esi
movq %rax, %rdx
callq 0x2ec2
leaq -0x40(%rbp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x3036
movq (%r12), %r12
movq %r13, %rdi
movl %r15d, %esi
movl %ebx, %edx
callq 0x4388
movq %rax, %rcx
movb $0x1, %al
testq %r12, %rcx
jne 0x4720
movq %r13, %rdi
callq 0x445a
pushq $0x4
popq %rbx
movl %r14d, %edi
movl %ebx, %esi
movq %rax, %rdx
callq 0x2ec2
leaq -0x38(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x3036
movq (%r14), %r14
movq %r13, %rdi
movl %r15d, %esi
movl %ebx, %edx
callq 0x4388
testq %r14, %rax
setne %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop