// File: bjohnsonfl[P]Overhead-Chess-Engine-/bitboard.cpp
// Function: allRookAttacks()
void allRookAttacks(){
    bitboard rookMoves = 0ULL;
    square sq = a1;
    for(rank rk = rank_1; rk<numOfRank; rk++)
    {
        for(file f = file_a; f<numOfFile; f++)
        {
            sq = rankFile_to_sq(rk, f);
            rookMoves = fileBitMask[f] | rankBitMask[rk];
            openBoardAttacks[p_rook][sq] = rookMoves ^ squareBitMask[sq];
           
            if ( (sq == a1) || (sq == a8) || (sq == h1) || (sq == h8) )
            {
                magicRookMask[sq] = (rookMoves & clearCorners);
            }
            else if(rk == rank_1)
                magicRookMask[sq] = squareBitMask[sq] ^ (rookMoves & (clearEdges | (rank1 & clearCorners)));
            else if (rk == rank_8)
                magicRookMask[sq] = squareBitMask[sq] ^ (rookMoves & (clearEdges | (rank8 & clearCorners)));
            else if (f == file_a)
                magicRookMask[sq] = squareBitMask[sq] ^ (rookMoves & (clearEdges | (fileA & clearCorners)));
            else if (f == file_h)
                magicRookMask[sq] = squareBitMask[sq] ^ (rookMoves & (clearEdges | (fileH & clearCorners)));
            else
            {
                magicRookMask[sq] = squareBitMask[sq] ^ (rookMoves & clearEdges );
            }
                
            //printBitboard( openBoardAttacks[p_rook][sq]);
            //printBitboard(magicRookMask[sq]);
            rookMoves = 0ULL;
            
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq $0x0, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0x8, -0x10(%rbp)
jge 0x4b6b
movl $0x0, -0x14(%rbp)
cmpl $0x8, -0x14(%rbp)
jge 0x4b59
movl -0x10(%rbp), %edi
movl -0x14(%rbp), %esi
callq 0x5a00
movl %eax, -0xc(%rbp)
movl -0x14(%rbp), %eax
movl %eax, %ecx
leaq 0xe6fd(%rip), %rax      # 0x130a0
movq (%rax,%rcx,8), %rax
movl -0x10(%rbp), %ecx
movl %ecx, %edx
leaq 0xe72d(%rip), %rcx      # 0x130e0
orq (%rcx,%rdx,8), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdx
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xe4d5(%rip), %rax      # 0x12ea0
xorq (%rax,%rcx,8), %rdx
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xebc5(%rip), %rax      # 0x135a0
movq %rdx, 0x600(%rax,%rcx,8)
cmpl $0x0, -0xc(%rbp)
je 0x49fb
cmpl $0x38, -0xc(%rbp)
je 0x49fb
cmpl $0x7, -0xc(%rbp)
je 0x49fb
cmpl $0x3f, -0xc(%rbp)
jne 0x4a1e
movabsq $0x7effffffffffff7e, %rdx # imm = 0x7EFFFFFFFFFFFF7E
andq -0x8(%rbp), %rdx
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x1fb8b(%rip), %rax     # 0x245a0
movq %rdx, (%rax,%rcx,8)
jmp 0x4b41
cmpl $0x0, -0x10(%rbp)
jne 0x4a5a
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xe470(%rip), %rax      # 0x12ea0
movq (%rax,%rcx,8), %rdx
movabsq $0x7e7e7e7e7e7e7e, %rax # imm = 0x7E7E7E7E7E7E7E
andq -0x8(%rbp), %rax
xorq %rax, %rdx
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x1fb4f(%rip), %rax     # 0x245a0
movq %rdx, (%rax,%rcx,8)
jmp 0x4b3f
cmpl $0x7, -0x10(%rbp)
jne 0x4a96
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xe434(%rip), %rax      # 0x12ea0
movq (%rax,%rcx,8), %rdx
movabsq $0x7e7e7e7e7e7e7e00, %rax # imm = 0x7E7E7E7E7E7E7E00
andq -0x8(%rbp), %rax
xorq %rax, %rdx
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x1fb13(%rip), %rax     # 0x245a0
movq %rdx, (%rax,%rcx,8)
jmp 0x4b3d
cmpl $0x0, -0x14(%rbp)
jne 0x4acf
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xe3f8(%rip), %rax      # 0x12ea0
movq (%rax,%rcx,8), %rdx
movabsq $0x7f7f7f7f7f7f00, %rax # imm = 0x7F7F7F7F7F7F00
andq -0x8(%rbp), %rax
xorq %rax, %rdx
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x1fad7(%rip), %rax     # 0x245a0
movq %rdx, (%rax,%rcx,8)
jmp 0x4b3b
cmpl $0x7, -0x14(%rbp)
jne 0x4b08
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xe3bf(%rip), %rax      # 0x12ea0
movq (%rax,%rcx,8), %rdx
movabsq $0xfefefefefefe00, %rax # imm = 0xFEFEFEFEFEFE00
andq -0x8(%rbp), %rax
xorq %rax, %rdx
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x1fa9e(%rip), %rax     # 0x245a0
movq %rdx, (%rax,%rcx,8)
jmp 0x4b39
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xe38c(%rip), %rax      # 0x12ea0
movq (%rax,%rcx,8), %rdx
movabsq $0x7e7e7e7e7e7e00, %rax # imm = 0x7E7E7E7E7E7E00
andq -0x8(%rbp), %rax
xorq %rax, %rdx
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x1fa6b(%rip), %rax     # 0x245a0
movq %rdx, (%rax,%rcx,8)
jmp 0x4b3b
jmp 0x4b3d
jmp 0x4b3f
jmp 0x4b41
movq $0x0, -0x8(%rbp)
leaq -0x14(%rbp), %rdi
xorl %esi, %esi
callq 0x5a20
jmp 0x497f
jmp 0x4b5b
leaq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x5a40
jmp 0x496e
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)