// File: /workspace/github_cpp_makefile_star2_O3/SethKasmann[P]clever-girl/src/bitboard.cpp
// Function: bb_init()
void bb_init()
{
    for (Square sq_src = first_sq; sq_src <= last_sq; ++sq_src)
    {
        U64 bit = 1ULL << sq_src;
        square_bb[sq_src] = bit;
        pawn_attacks[white][sq_src] = ((bit & Not_h_file) << 7)
                                    | ((bit & Not_a_file) << 9);
        pawn_attacks[black][sq_src] = ((bit & Not_h_file) >> 9)
                                    | ((bit & Not_a_file) >> 7);
        pawn_push[white][sq_src]    = bit << 8;
        pawn_push[black][sq_src]    = bit >> 8;

        U64 front = east_fill(bit) | west_fill(bit);
        in_front[white][sq_src] = north_fill(front << 8);
        in_front[black][sq_src] = south_fill(front >> 8);

        king_net_bb[white][sq_src] = King_moves[sq_src] | (King_moves[sq_src] << 16);
        king_net_bb[black][sq_src] = King_moves[sq_src] | (King_moves[sq_src] >> 16);

        file_bb[sq_src] = north_fill(bit) | south_fill(bit);
        rank_bb[sq_src] = east_fill(bit) | west_fill(bit);

        bishopMoves[sq_src] = (north_east_fill(bit) | north_west_fill(bit) 
                    | south_east_fill(bit) | south_west_fill(bit)) & ~bit;

        rookMoves[sq_src] = (north_fill(bit) | south_fill(bit) 
                  | east_fill(bit) | west_fill(bit)) & ~bit;

        if (bit & Rank_2)
        {
            pawn_dbl_push[white][sq_src] = bit << 16;
            pawn_dbl_push[black][sq_src] = 0;
        }
        else if (bit & Rank_7)
        {
            pawn_dbl_push[white][sq_src] = 0;
            pawn_dbl_push[black][sq_src] = bit >> 16;
        }
        else
        {
            pawn_dbl_push[white][sq_src] = 0;
            pawn_dbl_push[black][sq_src] = 0;
        }
        for (Square sq_dst = H1; sq_dst <= A8; ++sq_dst)
        {
            adj_files[sq_dst] = sq_dst & File_a ? File_b
                              : sq_dst & File_b ? File_a | File_c
                              : sq_dst & File_c ? File_b | File_d
                              : sq_dst & File_d ? File_c | File_e
                              : sq_dst & File_e ? File_d | File_f
                              : sq_dst & File_f ? File_e | File_g
                              : sq_dst & File_g ? File_f | File_h
                              : File_g;


            U64 r_attacks, b_attacks, occ;
            occ = 1ULL << sq_src | 1ULL << sq_dst;
            
            r_attacks = Rmagic(sq_src, 0);
            b_attacks = Bmagic(sq_src, 0);

            r_attacks &= (r_attacks & occ ? Rmagic(sq_dst, 0) : 0);
            b_attacks &= (b_attacks & occ ? Bmagic(sq_dst, 0) : 0);

            coplanar[sq_src][sq_dst] = r_attacks | b_attacks;

            r_attacks = Rmagic(sq_src, occ);
            b_attacks = Bmagic(sq_src, occ);

            r_attacks &= (r_attacks & occ ? Rmagic(sq_dst, occ) : 0);
            b_attacks &= (b_attacks & occ ? Bmagic(sq_dst, occ) : 0);

            between_dia[sq_src][sq_dst] = b_attacks;
            between_hor[sq_src][sq_dst] = r_attacks;
            between[sq_src][sq_dst] = b_attacks | r_attacks;
        }
    }
    outpost_area[white] = Rank_4 | Rank_5 | Rank_6 | Rank_7;
    outpost_area[black] = Rank_2 | Rank_3 | Rank_4 | Rank_5;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movabsq $-0x101010101010102, %rax # imm = 0xFEFEFEFEFEFEFEFE
movabsq $-0x303030303040000, %r8 # imm = 0xFCFCFCFCFCFC0000
movabsq $0x3f3f3f3f3f3f0000, %rdx # imm = 0x3F3F3F3F3F3F0000
movabsq $0xf0f0f0f00000000, %rsi # imm = 0xF0F0F0F00000000
leaq 0x10441b(%rip), %rdi    # 0x111c70
movq %rdi, -0x40(%rsp)
leaq 0xec40f(%rip), %rdi     # 0xf9c70
movq %rdi, -0x48(%rsp)
leaq 0xf4403(%rip), %rdi     # 0x101c70
movq %rdi, -0x50(%rsp)
leaq 0xfc3f7(%rip), %rdi     # 0x109c70
movq %rdi, -0x58(%rsp)
xorl %ecx, %ecx
leaq 0xfcfc(%r8), %rdi
movq %rdi, -0x20(%rsp)
addq $0x3f3f, %rdx           # imm = 0x3F3F
movq %rdx, -0x28(%rsp)
movl $0xf0f0f0f, %edx        # imm = 0xF0F0F0F
addq %rsi, %rdx
movq %rdx, -0x30(%rsp)
addq $-0xfe, %rax
movq %rax, -0x38(%rsp)
leaq 0xebfb9(%rip), %rbx     # 0xf9870
movl $0x1, %r12d
shlq %cl, %r12
movq %r12, %rax
movabsq $-0x101010101010102, %rdi # imm = 0xFEFEFEFEFEFEFEFE
andq %rdi, %rax
movq %rax, %r8
shlq $0x7, %r8
movq %r12, %rdx
movabsq $0x7f7f7f7f7f7f7f7f, %r9 # imm = 0x7F7F7F7F7F7F7F7F
andq %r9, %rdx
movq %rdx, %rsi
shlq $0x9, %rsi
orq %r8, %rsi
leaq 0xeb778(%rip), %r8      # 0xf9070
movq %rsi, (%r8,%rcx,8)
shrq $0x9, %rax
shrq $0x7, %rdx
movl $0x100, %esi            # imm = 0x100
shlq %cl, %rsi
orq %rax, %rdx
movq %rdx, 0x200(%r8,%rcx,8)
leaq 0xebb52(%rip), %rax     # 0xf9470
movq %rsi, (%rax,%rcx,8)
movq %r12, %r11
shrq $0x8, %r11
movq %r11, 0x200(%rax,%rcx,8)
movl $0x2, %eax
shlq %cl, %rax
andq %rdi, %rax
btsq %rcx, %rax
leaq (,%rax,4), %rdi
andq -0x20(%rsp), %rdi
orq %rax, %rdi
movq %rdi, %rsi
shlq $0x4, %rsi
movabsq $-0xf0f0f0f0f0f0f10, %rax # imm = 0xF0F0F0F0F0F0F0F0
andq %rax, %rsi
movq %r12, %rax
shrq %rax
andq %r9, %rax
btsq %rcx, %rax
movq %rax, %rdx
shrq $0x2, %rdx
andq -0x28(%rsp), %rdx
orq %rax, %rdx
movq %rdx, %rax
shrq $0x4, %rax
andq -0x30(%rsp), %rax
orq %rdi, %rsi
orq %rax, %rsi
orq %rdx, %rsi
movq %rsi, %rdi
shlq $0x10, %rdi
orq %rsi, %rdi
movq %rsi, %r10
movq %rsi, %r8
shrq $0x10, %r8
btsq %rcx, %r11
movq %r11, %rdx
shrq $0x10, %rdx
orq %r11, %rdx
movabsq $0x101010101010101, %rax # imm = 0x101010101010101
shlq %cl, %rax
orq %rsi, %r8
orq %rdx, %rax
shrq $0x20, %rdx
orq %rax, %rdx
leaq 0xeb298(%rip), %rax     # 0xf8c70
movq %rdx, (%rax,%rcx,8)
leaq 0xeb48d(%rip), %rax     # 0xf8e70
movq %rsi, (%rax,%rcx,8)
orq %rsi, %rdx
shlq $0x8, %rsi
orq %rsi, %rdi
shlq $0x10, %rdi
orq %rsi, %rdi
movq %rdi, %rax
shlq $0x20, %rax
orq %rdi, %rax
leaq 0x10c467(%rip), %rsi    # 0x119e70
movq %rax, (%rsi,%rcx,8)
shrq $0x8, %r10
orq %r10, %r8
shrq $0x10, %r8
orq %r10, %r8
movq %r8, %rax
shrq $0x20, %rax
orq %r8, %rax
movq %rax, 0x200(%rsi,%rcx,8)
leaq 0xe20c(%rip), %rax      # 0x1bc40
movq (%rax,%rcx,8), %rax
movq %rax, %rsi
shlq $0x10, %rsi
orq %rax, %rsi
leaq 0x10c827(%rip), %r8     # 0x11a270
movq %rsi, (%r8,%rcx,8)
movq %rax, %rsi
shrq $0x10, %rsi
movl $0x200, %edi            # imm = 0x200
shlq %cl, %rdi
orq %rax, %rsi
movq %rsi, 0x200(%r8,%rcx,8)
andq -0x38(%rsp), %rdi
btsq %rcx, %rdi
movq %rdi, %rsi
shlq $0x12, %rsi
movabsq $-0x303030303040000, %rax # imm = 0xFCFCFCFCFCFC0000
andq %rax, %rsi
movl $0x80, %eax
shlq %cl, %rax
orq %rdi, %rsi
leaq -0x7f(%r9), %r8
andq %rax, %r8
btsq %rcx, %r8
movq %r8, %rax
shlq $0xe, %rax
movabsq $0x3f3f3f3f3f3f0000, %rdi # imm = 0x3F3F3F3F3F3F0000
andq %rdi, %rax
orq %r8, %rax
movq %r12, %r8
shrq $0x7, %r8
movabsq $0xfefefefefefefe, %rdi # imm = 0xFEFEFEFEFEFEFE
andq %rdi, %r8
btsq %rcx, %r8
movq %r8, %rdi
shrq $0xe, %rdi
movabsq $0xfcfcfcfcfcfc, %r9    # imm = 0xFCFCFCFCFCFC
andq %r9, %rdi
orq %r8, %rdi
movq %r12, %r9
shrq $0x9, %r9
movabsq $0x7f7f7f7f7f7f7f, %r8  # imm = 0x7F7F7F7F7F7F7F
andq %r8, %r9
btsq %rcx, %r9
movq %r9, %r8
shrq $0x12, %r8
movabsq $0x3f3f3f3f3f3f, %r10   # imm = 0x3F3F3F3F3F3F
andq %r10, %r8
orq %r9, %r8
movq %rsi, %r10
movl $0xf0f0f0f, %r11d       # imm = 0xF0F0F0F
andq %r11, %r10
shlq $0x24, %r10
orq %r8, %rsi
orq %rdi, %rsi
shrq $0x1c, %rdi
andl $0xf0f0f0f0, %edi       # imm = 0xF0F0F0F0
orq %rax, %rdi
shlq $0x1c, %rax
movabsq $0xf0f0f0f00000000, %r9 # imm = 0xF0F0F0F00000000
andq %r9, %rax
orq %r10, %rax
shrq $0x24, %r8
andq %r11, %r8
orq %rax, %r8
orq %r8, %rdi
orq %rdi, %rsi
btrq %rcx, %rsi
leaq 0x10cb1f(%rip), %rax    # 0x11a680
movq %rsi, (%rax,%rcx,8)
btrq %rcx, %rdx
leaq 0x10cd10(%rip), %rax    # 0x11a880
movq %rdx, (%rax,%rcx,8)
leaq 0xeaef5(%rip), %rax     # 0xf8a70
movq %r12, (%rax,%rcx,8)
movl $0xff00, %eax           # imm = 0xFF00
btq %rcx, %rax
jae 0xdb9a
movl $0x10000, %eax          # imm = 0x10000
shlq %cl, %rax
movq %rax, (%rbx,%rcx,8)
xorl %eax, %eax
jmp 0xdbc0
movq %r12, %rdx
movabsq $0xff000000000000, %rax # imm = 0xFF000000000000
andq %rax, %rdx
movq %r12, %rax
shrq $0x10, %rax
testq %rdx, %rdx
movq $0x0, (%rbx,%rcx,8)
cmoveq %rdx, %rax
movq %rax, 0x200(%rbx,%rcx,8)
leaq 0x17841(%rip), %rax     # 0x25410
movq (%rax,%rcx,8), %rbp
leaq 0xd466(%rip), %rax      # 0x1b040
movl (%rax,%rcx,4), %eax
movq %rax, -0x8(%rsp)
leaq 0x17627(%rip), %rax     # 0x25210
movq (%rax,%rcx,8), %rdi
leaq 0xd94c(%rip), %rax      # 0x1b540
movl (%rax,%rcx,4), %eax
movq %rax, -0x10(%rsp)
leaq 0xd73d(%rip), %rax      # 0x1b340
movq (%rax,%rcx,8), %r8
leaq 0xd532(%rip), %rax      # 0x1b140
movq (%rax,%rcx,8), %r11
leaq 0xdc27(%rip), %rax      # 0x1b840
movq (%rax,%rcx,8), %rdx
movq %rcx, -0x18(%rsp)
leaq 0xda17(%rip), %rax      # 0x1b640
movq (%rax,%rcx,8), %r10
xorl %r14d, %r14d
xorl %r15d, %r15d
leaq 0xeae36(%rip), %rax     # 0xf8a70
movq (%r14,%rax), %rax
movabsq $0x4040404040404040, %rcx # imm = 0x4040404040404040
movabsq $-0x7f7f7f7f7f7f7f80, %r9 # imm = 0x8080808080808080
testq %r9, %rax
jne 0xdcf3
movabsq $-0x5f5f5f5f5f5f5f60, %rcx # imm = 0xA0A0A0A0A0A0A0A0
movabsq $0x4040404040404040, %r9 # imm = 0x4040404040404040
testq %r9, %rax
jne 0xdcf3
movabsq $0x5050505050505050, %rcx # imm = 0x5050505050505050
movabsq $0x2020202020202020, %r9 # imm = 0x2020202020202020
testq %r9, %rax
jne 0xdcf3
movabsq $0x2828282828282828, %rcx # imm = 0x2828282828282828
movabsq $0x1010101010101010, %r9 # imm = 0x1010101010101010
testq %r9, %rax
jne 0xdcf3
movabsq $0x1414141414141414, %rcx # imm = 0x1414141414141414
movabsq $0x808080808080808, %r9 # imm = 0x808080808080808
testq %r9, %rax
jne 0xdcf3
movabsq $0xa0a0a0a0a0a0a0a, %rcx # imm = 0xA0A0A0A0A0A0A0A
movabsq $0x404040404040404, %r9 # imm = 0x404040404040404
testq %r9, %rax
jne 0xdcf3
movabsq $0x202020202020202, %r9 # imm = 0x202020202020202
testq %r9, %rax
movabsq $0x505050505050505, %rcx # imm = 0x505050505050505
cmoveq %r9, %rcx
leaq 0x10bf76(%rip), %rax    # 0x119c70
movq %rcx, (%r14,%rax)
movq %r12, %r9
btsq %r15, %r9
movq (%rbp), %r13
movq (%rdi), %rcx
testq %r9, %r13
je 0xdd21
leaq 0x176f8(%rip), %rax     # 0x25410
movq (%rax,%r15,8), %rax
movq (%rax), %rax
jmp 0xdd23
xorl %eax, %eax
movq %r12, %rsi
testq %r9, %rcx
je 0xdd3c
leaq 0x174de(%rip), %rbx     # 0x25210
movq (%rbx,%r15,8), %r12
movq (%r12), %r12
jmp 0xdd3f
xorl %r12d, %r12d
andq %r13, %rax
andq %rcx, %r12
movq %r8, %r13
andq %r9, %r13
imulq %r11, %r13
movq -0x8(%rsp), %rcx
shrq %cl, %r13
orq %rax, %r12
movq %rdx, %rbx
andq %r9, %rbx
imulq %r10, %rbx
movq -0x10(%rsp), %rcx
shrq %cl, %rbx
movq -0x40(%rsp), %rax
movq %r12, (%rax,%r15,8)
movq (%rbp,%r13,8), %rax
movq (%rdi,%rbx,8), %r13
testq %r9, %rax
je 0xddbc
leaq 0x17686(%rip), %rcx     # 0x25410
movq (%rcx,%r15,8), %rbx
leaq 0xd5ab(%rip), %rcx      # 0x1b340
movq (%rcx,%r15,8), %r12
andq %r9, %r12
leaq 0xd39d(%rip), %rcx      # 0x1b140
imulq (%rcx,%r15,8), %r12
leaq 0xd291(%rip), %rcx      # 0x1b040
movb (%rcx,%r15,4), %cl
shrq %cl, %r12
movq (%rbx,%r12,8), %r12
jmp 0xddbf
xorl %r12d, %r12d
testq %r9, %r13
je 0xddfa
leaq 0x17445(%rip), %rcx     # 0x25210
movq (%rcx,%r15,8), %rbx
leaq 0xda6a(%rip), %rcx      # 0x1b840
andq (%rcx,%r15,8), %r9
leaq 0xd85f(%rip), %rcx      # 0x1b640
imulq (%rcx,%r15,8), %r9
leaq 0xd753(%rip), %rcx      # 0x1b540
movb (%rcx,%r15,4), %cl
shrq %cl, %r9
movq (%rbx,%r9,8), %rcx
jmp 0xddfc
xorl %ecx, %ecx
andq %rax, %r12
andq %r13, %rcx
movq -0x48(%rsp), %rax
movq %rcx, (%rax,%r15,8)
movq -0x50(%rsp), %rax
movq %r12, (%rax,%r15,8)
orq %r12, %rcx
movq -0x58(%rsp), %rax
movq %rcx, (%rax,%r15,8)
incq %r15
addq $0x8, %r14
cmpq $0x40, %r15
movq %rsi, %r12
jne 0xdc33
movq -0x18(%rsp), %rcx
incq %rcx
movl $0x200, %eax            # imm = 0x200
addq %rax, -0x40(%rsp)
addq %rax, -0x48(%rsp)
addq %rax, -0x50(%rsp)
addq %rax, -0x58(%rsp)
cmpq $0x40, %rcx
leaq 0xeba10(%rip), %rbx     # 0xf9870
jne 0xd8b7
movabsq $0xffffffff000000, %rax # imm = 0xFFFFFFFF000000
movq %rax, 0x10c7f9(%rip)    # 0x11a670
movabsq $0xffffffff00, %rax     # imm = 0xFFFFFFFF00
movq %rax, 0x10c7f0(%rip)    # 0x11a678
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq