// File: ATOMIC-LICHESS[P]ATOMKRAFT/bitboard.cpp
// Function: (anonymous namespace)::init_masks()
void init_masks() {

    SquaresByColorBB[DARK]  =  0xAA55AA55AA55AA55ULL;
    SquaresByColorBB[LIGHT] = ~SquaresByColorBB[DARK];

    FileBB[FILE_A] = FileABB;
    RankBB[RANK_1] = Rank1BB;

    for (int f = FILE_B; f <= FILE_H; f++)
    {
        FileBB[f] = FileBB[f - 1] << 1;
        RankBB[f] = RankBB[f - 1] << 8;
    }

    for (int f = FILE_A; f <= FILE_H; f++)
    {
        NeighboringFilesBB[f] = (f > FILE_A ? FileBB[f - 1] : 0) | (f < FILE_H ? FileBB[f + 1] : 0);
        ThisAndNeighboringFilesBB[f] = FileBB[f] | NeighboringFilesBB[f];
    }

    for (int rw = RANK_7, rb = RANK_2; rw >= RANK_1; rw--, rb++)
    {
        InFrontBB[WHITE][rw] = InFrontBB[WHITE][rw + 1] | RankBB[rw + 1];
        InFrontBB[BLACK][rb] = InFrontBB[BLACK][rb - 1] | RankBB[rb - 1];
    }

    SetMaskBB[SQ_NONE] = EmptyBoardBB;
    ClearMaskBB[SQ_NONE] = ~SetMaskBB[SQ_NONE];

    for (Square s = SQ_A1; s <= SQ_H8; s++)
    {
        SetMaskBB[s] = (1ULL << s);
        ClearMaskBB[s] = ~SetMaskBB[s];
    }

    for (Color c = WHITE; c <= BLACK; c++)
        for (Square s = SQ_A1; s <= SQ_H8; s++)
        {
            SquaresInFrontMask[c][s] = in_front_bb(c, s) & file_bb(s);
            PassedPawnMask[c][s] = in_front_bb(c, s) & this_and_neighboring_files_bb(s);
            AttackSpanMask[c][s] = in_front_bb(c, s) & neighboring_files_bb(s);
        }

    for (Bitboard b = 0; b < 256; b++)
        BitCount8Bit[b] = (uint8_t)count_1s<CNT32>(b);
  }

// Assembly:
subq $0x58, %rsp
movabsq $-0x55aa55aa55aa55ab, %rax # imm = 0xAA55AA55AA55AA55
movq %rax, 0x13abdb(%rip)    # 0x1486d0
movq 0x13abd4(%rip), %rax    # 0x1486d0
xorq $-0x1, %rax
movq %rax, 0x13abd1(%rip)    # 0x1486d8
movabsq $0x101010101010101, %rax # imm = 0x101010101010101
movq %rax, 0x13abc8(%rip)    # 0x1486e0
movq $0xff, 0x13abfd(%rip) # 0x148720
movl $0x1, 0x54(%rsp)
cmpl $0x7, 0x54(%rsp)
jg 0xdb90
movl 0x54(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x13ab9d(%rip), %rax    # 0x1486e0
movq (%rax,%rcx,8), %rdx
shlq %rdx
movslq 0x54(%rsp), %rcx
leaq 0x13ab8a(%rip), %rax    # 0x1486e0
movq %rdx, (%rax,%rcx,8)
movl 0x54(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x13abb5(%rip), %rax    # 0x148720
movq (%rax,%rcx,8), %rdx
shlq $0x8, %rdx
movslq 0x54(%rsp), %rcx
leaq 0x13aba1(%rip), %rax    # 0x148720
movq %rdx, (%rax,%rcx,8)
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0xdb2b
movl $0x0, 0x50(%rsp)
cmpl $0x7, 0x50(%rsp)
jg 0xdc62
cmpl $0x0, 0x50(%rsp)
jle 0xdbc6
movl 0x50(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x13ab25(%rip), %rax    # 0x1486e0
movq (%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
jmp 0xdbcf
xorl %eax, %eax
movq %rax, 0x28(%rsp)
jmp 0xdbcf
movq 0x28(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpl $0x7, 0x50(%rsp)
jge 0xdbfc
movl 0x50(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x13aaef(%rip), %rax    # 0x1486e0
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
jmp 0xdc05
xorl %eax, %eax
movq %rax, 0x18(%rsp)
jmp 0xdc05
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rax
orq %rax, %rdx
movslq 0x50(%rsp), %rcx
leaq 0x13ab42(%rip), %rax    # 0x148760
movq %rdx, (%rax,%rcx,8)
movslq 0x50(%rsp), %rcx
leaq 0x13aab2(%rip), %rax    # 0x1486e0
movq (%rax,%rcx,8), %rdx
movslq 0x50(%rsp), %rcx
leaq 0x13ab22(%rip), %rax    # 0x148760
orq (%rax,%rcx,8), %rdx
movslq 0x50(%rsp), %rcx
leaq 0x13ab52(%rip), %rax    # 0x1487a0
movq %rdx, (%rax,%rcx,8)
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0xdb98
movl $0x6, 0x4c(%rsp)
movl $0x1, 0x48(%rsp)
cmpl $0x0, 0x4c(%rsp)
jl 0xdd0e
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x13ab52(%rip), %rax    # 0x1487e0
movq (%rax,%rcx,8), %rdx
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x13aa7d(%rip), %rax    # 0x148720
orq (%rax,%rcx,8), %rdx
movslq 0x4c(%rsp), %rcx
leaq 0x13ab2d(%rip), %rax    # 0x1487e0
movq %rdx, (%rax,%rcx,8)
movl 0x48(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x13ab18(%rip), %rax    # 0x1487e0
movq 0x40(%rax,%rcx,8), %rdx
movl 0x48(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x13aa42(%rip), %rax    # 0x148720
orq (%rax,%rcx,8), %rdx
movslq 0x48(%rsp), %rcx
leaq 0x13aaf2(%rip), %rax    # 0x1487e0
movq %rdx, 0x40(%rax,%rcx,8)
movl 0x4c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x4c(%rsp)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0xdc72
movq $0x0, 0x13a797(%rip) # 0x1484b0
movq 0x13a790(%rip), %rax    # 0x1484b0
xorq $-0x1, %rax
movq %rax, 0x13a995(%rip)    # 0x1486c0
movl $0x0, 0x44(%rsp)
cmpl $0x3f, 0x44(%rsp)
jg 0xdd8a
movl 0x44(%rsp), %eax
movl %eax, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movslq 0x44(%rsp), %rcx
leaq 0x13a55c(%rip), %rax    # 0x1482b0
movq %rdx, (%rax,%rcx,8)
movslq 0x44(%rsp), %rcx
leaq 0x13a54c(%rip), %rax    # 0x1482b0
movq (%rax,%rcx,8), %rdx
xorq $-0x1, %rdx
movslq 0x44(%rsp), %rcx
leaq 0x13a748(%rip), %rax    # 0x1484c0
movq %rdx, (%rax,%rcx,8)
leaq 0x44(%rsp), %rdi
xorl %esi, %esi
callq 0xe5c0
jmp 0xdd33
movl $0x0, 0x40(%rsp)
cmpl $0x1, 0x40(%rsp)
jg 0xde92
movl $0x0, 0x3c(%rsp)
cmpl $0x3f, 0x3c(%rsp)
jg 0xde7f
movl 0x40(%rsp), %edi
movl 0x3c(%rsp), %esi
callq 0xe5f0
movq %rax, (%rsp)
movl 0x3c(%rsp), %edi
callq 0xe640
movq (%rsp), %rdx
andq %rax, %rdx
movl 0x40(%rsp), %eax
movl %eax, %ecx
leaq 0x144a82(%rip), %rax    # 0x152860
shlq $0x9, %rcx
addq %rcx, %rax
movslq 0x3c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x40(%rsp), %edi
movl 0x3c(%rsp), %esi
callq 0xe5f0
movq %rax, 0x8(%rsp)
movl 0x3c(%rsp), %edi
callq 0xe660
movq 0x8(%rsp), %rdx
andq %rax, %rdx
movl 0x40(%rsp), %eax
movl %eax, %ecx
leaq 0x144e42(%rip), %rax    # 0x152c60
shlq $0x9, %rcx
addq %rcx, %rax
movslq 0x3c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x40(%rsp), %edi
movl 0x3c(%rsp), %esi
callq 0xe5f0
movq %rax, 0x10(%rsp)
movl 0x3c(%rsp), %edi
callq 0xe680
movq 0x10(%rsp), %rdx
andq %rax, %rdx
movl 0x40(%rsp), %eax
movl %eax, %ecx
leaq 0x145202(%rip), %rax    # 0x153060
shlq $0x9, %rcx
addq %rcx, %rax
movslq 0x3c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x3c(%rsp), %rdi
xorl %esi, %esi
callq 0xe5c0
jmp 0xdda5
jmp 0xde81
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0xe6a0
jmp 0xdd92
movq $0x0, 0x30(%rsp)
cmpq $0x100, 0x30(%rsp)      # imm = 0x100
jae 0xded1
movq 0x30(%rsp), %rdi
callq 0xe6d0
movb %al, %dl
movq 0x30(%rsp), %rcx
leaq 0x145ba2(%rip), %rax    # 0x153a60
movb %dl, (%rax,%rcx)
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0xde9b
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)