// File: 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
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
xorl %edx, %edx
callq 0x46e0
movq %rax, %rsi
leaq -0x20(%rbp), %rdi
callq 0x4bc0
movq -0xa0(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
movl -0x18(%rbp), %esi
callq 0x7e00
movq -0xa0(%rbp), %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x76f0
movq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, -0x28(%rbp)
andq -0x28(%rbp), %rax
cmpq $0x0, %rax
je 0x7b74
movb $0x1, -0x1(%rbp)
jmp 0x7dea
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movl $0x1, %edx
callq 0x46e0
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x4bc0
movq -0xa0(%rbp), %rdi
movq -0x30(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0x18(%rbp), %esi
callq 0x7e00
movq -0xa0(%rbp), %rdi
movl %eax, %esi
movl $0x1, %edx
callq 0x76f0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movq %rcx, -0x38(%rbp)
andq -0x38(%rbp), %rax
cmpq $0x0, %rax
je 0x7bde
movb $0x1, -0x1(%rbp)
jmp 0x7dea
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movl $0x5, %edx
callq 0x46e0
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x4bc0
movq -0xa0(%rbp), %rdi
movq -0x40(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl -0x18(%rbp), %esi
callq 0x7e00
movq -0xa0(%rbp), %rdi
movl %eax, %esi
movl $0x5, %edx
callq 0x76f0
movq %rax, %rcx
movq -0xb0(%rbp), %rax
movq %rcx, -0x48(%rbp)
andq -0x48(%rbp), %rax
cmpq $0x0, %rax
je 0x7c48
movb $0x1, -0x1(%rbp)
jmp 0x7dea
movq -0xa0(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0xbc(%rbp)
callq 0x78d0
movl -0xbc(%rbp), %edi
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdx
movl $0x2, %esi
callq 0x4770
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x4bc0
movq -0xa0(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl -0x18(%rbp), %esi
callq 0x7e00
movq -0xa0(%rbp), %rdi
movl %eax, %esi
movl $0x2, %edx
callq 0x76f0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq %rcx, -0x60(%rbp)
andq -0x60(%rbp), %rax
cmpq $0x0, %rax
je 0x7ccf
movb $0x1, -0x1(%rbp)
jmp 0x7dea
movq -0xa0(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0xcc(%rbp)
callq 0x78d0
movl -0xcc(%rbp), %edi
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdx
movl $0x3, %esi
callq 0x4770
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x4bc0
movq -0xa0(%rbp), %rdi
movq -0x68(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0x18(%rbp), %esi
callq 0x7e00
movq -0xa0(%rbp), %rdi
movl %eax, %esi
movl $0x3, %edx
callq 0x76f0
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, -0x78(%rbp)
andq -0x78(%rbp), %rax
cmpq $0x0, %rax
je 0x7d56
movb $0x1, -0x1(%rbp)
jmp 0x7dea
movq -0xa0(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0xdc(%rbp)
callq 0x78d0
movl -0xdc(%rbp), %edi
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdx
movl $0x4, %esi
callq 0x4770
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x4bc0
movq -0xa0(%rbp), %rdi
movq -0x80(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl -0x18(%rbp), %esi
callq 0x7e00
movq -0xa0(%rbp), %rdi
movl %eax, %esi
movl $0x4, %edx
callq 0x76f0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x90(%rbp)
andq -0x90(%rbp), %rax
cmpq $0x0, %rax
je 0x7de6
movb $0x1, -0x1(%rbp)
jmp 0x7dea
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax,%rax)