// File: bjohnsonfl[P]Overhead-Chess-Engine-/bitboard.cpp
// Function: bitboards::init()
void bitboards::init(){

  // std::cout << "Generating Bitboard Masks... \n";
    for(int i=0; i<numOfSq; i++)
    {
          squareBitMask[i] = (1ULL << i);
    }
    
    //diagonal and antiDiagonal bit masks
    for(int i=0; i<numOfSq; i++)
    {
        
        
        diagonalBitMask[i]  = diagMasks(i, 0) ;//& clearEdges;
        
       
        antiDiagonalBitMask[i] = antidiagMasks(i, 0);// & clearEdges;
        
        
    }
    
    for( int i = 0; i < numOfFile; i++)
    {
        fileBitMask[i] = fileA << i;
        clearFile[i] = ~fileBitMask[i];
    }
    
    for( int i = 0; i < numOfRank; i++)
    {
        rankBitMask[i] = rank1 << (8*i);
        clearRank[i] = ~rankBitMask[i];
    }
    // std::cout << "Generating Piece Attacks... \n";
     allPawnAttacks();
     allKingAttacks();
     allKnightAttacks();
     allBishopAttacks();
     allRookAttacks();
     allQueenAttacks();
     //std::cout << "Generating Magic Bishop Boards... \n";
     initMagicBishop();
     //std::cout << "Generating Magic Rook Boards... \n";
     initMagicRook();
     inBetweenBitMask();
     //std::cout << "Generating Bitboards Complete... \n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x40, -0x4(%rbp)
jge 0x401c
movl -0x4(%rbp), %eax
movl %eax, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movslq -0x4(%rbp), %rcx
leaq 0xee93(%rip), %rax      # 0x12ea0
movq %rdx, (%rax,%rcx,8)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x3fef
movl $0x0, -0x8(%rbp)
cmpl $0x40, -0x8(%rbp)
jge 0x4070
movl -0x8(%rbp), %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x4160
movq %rax, %rdx
movslq -0x8(%rbp), %rcx
leaq 0xf0dd(%rip), %rax      # 0x13120
movq %rdx, (%rax,%rcx,8)
movl -0x8(%rbp), %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x4280
movq %rax, %rdx
movslq -0x8(%rbp), %rcx
leaq 0xf2bf(%rip), %rax      # 0x13320
movq %rdx, (%rax,%rcx,8)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x4023
movl $0x0, -0xc(%rbp)
cmpl $0x8, -0xc(%rbp)
jge 0x40cb
movl -0xc(%rbp), %eax
movl %eax, %ecx
movabsq $0x101010101010101, %rdx # imm = 0x101010101010101
shlq %cl, %rdx
movslq -0xc(%rbp), %rcx
leaq 0xf006(%rip), %rax      # 0x130a0
movq %rdx, (%rax,%rcx,8)
movslq -0xc(%rbp), %rcx
leaq 0xeff7(%rip), %rax      # 0x130a0
movq (%rax,%rcx,8), %rdx
xorq $-0x1, %rdx
movslq -0xc(%rbp), %rcx
leaq 0xf464(%rip), %rax      # 0x13520
movq %rdx, (%rax,%rcx,8)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x4077
movl $0x0, -0x10(%rbp)
cmpl $0x8, -0x10(%rbp)
jge 0x4126
movl -0x10(%rbp), %eax
shll $0x3, %eax
movl %eax, %eax
movl %eax, %ecx
movl $0xff, %edx
shlq %cl, %rdx
movslq -0x10(%rbp), %rcx
leaq 0xefeb(%rip), %rax      # 0x130e0
movq %rdx, (%rax,%rcx,8)
movslq -0x10(%rbp), %rcx
leaq 0xefdc(%rip), %rax      # 0x130e0
movq (%rax,%rcx,8), %rdx
xorq $-0x1, %rdx
movslq -0x10(%rbp), %rcx
leaq 0xf449(%rip), %rax      # 0x13560
movq %rdx, (%rax,%rcx,8)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x40d2
callq 0x4380
callq 0x4540
callq 0x46b0
callq 0x4880
callq 0x4950
callq 0x4b80
callq 0x4bf0
callq 0x4fd0
callq 0x53b0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)