// File: niekh1234[P]nnchesslib/attacks.cpp
// Function: nnchesslib::Attacks::getRookAttacksRays(int, unsigned long long)
U64 Attacks::getRookAttacksRays(int sq, U64 blockers)
{
    U64 combinedAttacks = (U64)0;

    // north attacks
    U64 rookAttacksNorth = Rays::getRay(NORTH, sq);
    U64 northBlocker = rookAttacksNorth & blockers;
    if(blockers)
    {
        int index = bitScanForward(northBlocker);
        rookAttacksNorth ^= Rays::getRay(NORTH, index);
    }
    combinedAttacks |= rookAttacksNorth;

    // south attacks
    U64 rookAttacksSouth = Rays::getRay(SOUTH, sq);
    U64 southBlocker = rookAttacksSouth & blockers;
    if(blockers)
    {
        int index = bitScanReverse(southBlocker);
        rookAttacksSouth ^= Rays::getRay(SOUTH, index);
    }
    combinedAttacks |= rookAttacksSouth;

    // east attacks
    U64 rookAttacksEast = Rays::getRay(EAST, sq);
    U64 eastBlocker = rookAttacksEast & blockers;
    if(blockers)
    {
        int index = bitScanForward(eastBlocker);
        rookAttacksEast ^= Rays::getRay(EAST, index);
    }
    combinedAttacks |= rookAttacksEast;

    // west attacks
    U64 rookAttacksWest = Rays::getRay(WEST, sq);
    U64 westBlocker = rookAttacksWest & blockers;
    if(blockers)
    {
        int index = bitScanReverse(westBlocker);
        rookAttacksWest ^= Rays::getRay(WEST, index);
    }
    combinedAttacks |= rookAttacksWest;

    return combinedAttacks;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl -0x4(%rbp), %esi
xorl %edi, %edi
callq 0xd630
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
andq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4329
movq -0x28(%rbp), %rdi
callq 0xd7d0
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %esi
xorl %edi, %edi
callq 0xd630
xorq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
orq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0x4(%rbp), %esi
movl $0x2, %edi
callq 0xd630
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
andq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x437a
movq -0x40(%rbp), %rdi
callq 0xd800
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %esi
movl $0x2, %edi
callq 0xd630
xorq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
orq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0x4(%rbp), %esi
movl $0x1, %edi
callq 0xd630
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
andq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x43cb
movq -0x58(%rbp), %rdi
callq 0xd7d0
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %esi
movl $0x1, %edi
callq 0xd630
xorq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
orq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0x4(%rbp), %esi
movl $0x3, %edi
callq 0xd630
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
andq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x441c
movq -0x70(%rbp), %rdi
callq 0xd800
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %esi
movl $0x3, %edi
callq 0xd630
xorq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
orq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)