// File: cpirc[P]Monochrome/src/bitboard.cpp
// Function: init_bitboards()
void init_bitboards() {
    initmagicmoves();

    // Pawns
    for (int sq = A1; sq <= H8; sq++) {
        std::uint64_t from = 1ULL << sq;
        pawn_mask[US][sq] = ((from << 7) & ~file_mask[FILE_H]) |
                            ((from << 9) & ~file_mask[FILE_A]);
        pawn_mask[THEM][sq] = ((from >> 7) & ~file_mask[FILE_A]) |
                              ((from >> 9) & ~file_mask[FILE_H]);
    }

    // Knights
    for (int sq = A1; sq <= H8; sq++) {
        std::uint64_t from = 1ULL << sq;
        knight_mask[sq] = (from >> 17) & (~file_mask[FILE_H]);   // Up 2 right 1
        knight_mask[sq] |= (from >> 15) & (~file_mask[FILE_A]);  // Up 2 left 1
        knight_mask[sq] |=
            (from << 17) & (~file_mask[FILE_A]);  // Down 2 left 1
        knight_mask[sq] |=
            (from << 15) & (~file_mask[FILE_H]);  // Down 2 right 1
        knight_mask[sq] |= (from >> 10) & ~(file_mask[FILE_G] |
                                            file_mask[FILE_H]);  // Right 2 up 1
        knight_mask[sq] |=
            (from << 6) &
            ~(file_mask[FILE_G] | file_mask[FILE_H]);  // Right 2 down 1
        knight_mask[sq] |= (from >> 6) & ~(file_mask[FILE_A] |
                                           file_mask[FILE_B]);  // Left 2 up 1
        knight_mask[sq] |= (from << 10) & ~(file_mask[FILE_A] |
                                            file_mask[FILE_B]);  // Left 2 up 1
        knight_mask[sq] |=
            (from << 10) &
            ~(file_mask[FILE_A] | file_mask[FILE_B]);  // Left 2 down 1
    }

    // Kings
    for (int sq = A1; sq <= H8; sq++) {
        std::uint64_t from = 1ULL << sq;
        king_mask[sq] = (from >> 8);                          // Up 1
        king_mask[sq] |= (from << 8);                         // Down 1
        king_mask[sq] |= (from >> 1) & (~file_mask[FILE_H]);  // Right 1
        king_mask[sq] |= (from << 1) & (~file_mask[FILE_A]);  // Left 1
        king_mask[sq] |= (from >> 7) & (~file_mask[FILE_A]);  // Up 1 Left 1
        king_mask[sq] |= (from >> 9) & (~file_mask[FILE_H]);  // Up 1 Right 1
        king_mask[sq] |= (from << 7) & (~file_mask[FILE_H]);  // Down 1 Right 1
        king_mask[sq] |= (from << 9) & (~file_mask[FILE_A]);  // Down 1 Left 1
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
callq 0x5440
movl $0x0, -0x4(%rbp)
cmpl $0x3f, -0x4(%rbp)
jg 0x378d
movl -0x4(%rbp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdx
shlq $0x7, %rdx
movq 0xe93a(%rip), %rax      # 0x12048
xorq $-0x1, %rax
andq %rax, %rdx
movq -0x10(%rbp), %rax
shlq $0x9, %rax
movq 0xe8ec(%rip), %rcx      # 0x12010
xorq $-0x1, %rcx
andq %rcx, %rax
orq %rax, %rdx
movslq -0x4(%rbp), %rcx
leaq 0x17cb7(%rip), %rax     # 0x1b3f0
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rdx
shrq $0x7, %rdx
movq 0xe8c4(%rip), %rax      # 0x12010
xorq $-0x1, %rax
andq %rax, %rdx
movq -0x10(%rbp), %rax
shrq $0x9, %rax
movq 0xe8e6(%rip), %rcx      # 0x12048
xorq $-0x1, %rcx
andq %rcx, %rax
orq %rax, %rdx
movslq -0x4(%rbp), %rcx
leaq 0x17c79(%rip), %rax     # 0x1b3f0
movq %rdx, 0x200(%rax,%rcx,8)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x36e4
movl $0x0, -0x14(%rbp)
cmpl $0x3f, -0x14(%rbp)
jg 0x3985
movl -0x14(%rbp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdx
shrq $0x11, %rdx
movq 0xe88a(%rip), %rax      # 0x12048
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x14(%rbp), %rcx
leaq 0x18020(%rip), %rax     # 0x1b7f0
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdx
shrq $0xf, %rdx
movq 0xe82d(%rip), %rax      # 0x12010
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x14(%rbp), %rcx
leaq 0x17ffb(%rip), %rax     # 0x1b7f0
orq (%rax,%rcx,8), %rdx
leaq 0x17ff0(%rip), %rax     # 0x1b7f0
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdx
shlq $0x11, %rdx
movq 0xe7fd(%rip), %rax      # 0x12010
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x14(%rbp), %rcx
leaq 0x17fcb(%rip), %rax     # 0x1b7f0
orq (%rax,%rcx,8), %rdx
leaq 0x17fc0(%rip), %rax     # 0x1b7f0
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdx
shlq $0xf, %rdx
movq 0xe805(%rip), %rax      # 0x12048
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x14(%rbp), %rcx
leaq 0x17f9b(%rip), %rax     # 0x1b7f0
orq (%rax,%rcx,8), %rdx
leaq 0x17f90(%rip), %rax     # 0x1b7f0
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdx
shrq $0xa, %rdx
movq 0xe7cd(%rip), %rax      # 0x12040
orq 0xe7ce(%rip), %rax      # 0x12048
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x14(%rbp), %rcx
leaq 0x17f64(%rip), %rax     # 0x1b7f0
orq (%rax,%rcx,8), %rdx
leaq 0x17f59(%rip), %rax     # 0x1b7f0
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdx
shlq $0x6, %rdx
movq 0xe796(%rip), %rax      # 0x12040
orq 0xe797(%rip), %rax      # 0x12048
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x14(%rbp), %rcx
leaq 0x17f2d(%rip), %rax     # 0x1b7f0
orq (%rax,%rcx,8), %rdx
leaq 0x17f22(%rip), %rax     # 0x1b7f0
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdx
shrq $0x6, %rdx
movq 0xe72f(%rip), %rax      # 0x12010
orq 0xe730(%rip), %rax      # 0x12018
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x14(%rbp), %rcx
leaq 0x17ef6(%rip), %rax     # 0x1b7f0
orq (%rax,%rcx,8), %rdx
leaq 0x17eeb(%rip), %rax     # 0x1b7f0
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdx
shlq $0xa, %rdx
movq 0xe6f8(%rip), %rax      # 0x12010
orq 0xe6f9(%rip), %rax      # 0x12018
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x14(%rbp), %rcx
leaq 0x17ebf(%rip), %rax     # 0x1b7f0
orq (%rax,%rcx,8), %rdx
leaq 0x17eb4(%rip), %rax     # 0x1b7f0
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdx
shlq $0xa, %rdx
movq 0xe6c1(%rip), %rax      # 0x12010
orq 0xe6c2(%rip), %rax      # 0x12018
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x14(%rbp), %rcx
leaq 0x17e88(%rip), %rax     # 0x1b7f0
orq (%rax,%rcx,8), %rdx
leaq 0x17e7d(%rip), %rax     # 0x1b7f0
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3794
movl $0x0, -0x24(%rbp)
cmpl $0x3f, -0x24(%rbp)
jg 0x3b0c
movl -0x24(%rbp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdx
shrq $0x8, %rdx
movslq -0x24(%rbp), %rcx
leaq 0x18036(%rip), %rax     # 0x1b9f0
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdx
shlq $0x8, %rdx
movslq -0x24(%rbp), %rcx
leaq 0x1801f(%rip), %rax     # 0x1b9f0
orq (%rax,%rcx,8), %rdx
leaq 0x18014(%rip), %rax     # 0x1b9f0
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdx
shrq %rdx
movq 0xe65a(%rip), %rax      # 0x12048
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x24(%rbp), %rcx
leaq 0x17ff0(%rip), %rax     # 0x1b9f0
orq (%rax,%rcx,8), %rdx
leaq 0x17fe5(%rip), %rax     # 0x1b9f0
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdx
shlq %rdx
movq 0xe5f3(%rip), %rax      # 0x12010
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x24(%rbp), %rcx
leaq 0x17fc1(%rip), %rax     # 0x1b9f0
orq (%rax,%rcx,8), %rdx
leaq 0x17fb6(%rip), %rax     # 0x1b9f0
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdx
shrq $0x7, %rdx
movq 0xe5c3(%rip), %rax      # 0x12010
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x24(%rbp), %rcx
leaq 0x17f91(%rip), %rax     # 0x1b9f0
orq (%rax,%rcx,8), %rdx
leaq 0x17f86(%rip), %rax     # 0x1b9f0
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdx
shrq $0x9, %rdx
movq 0xe5cb(%rip), %rax      # 0x12048
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x24(%rbp), %rcx
leaq 0x17f61(%rip), %rax     # 0x1b9f0
orq (%rax,%rcx,8), %rdx
leaq 0x17f56(%rip), %rax     # 0x1b9f0
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdx
shlq $0x7, %rdx
movq 0xe59b(%rip), %rax      # 0x12048
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x24(%rbp), %rcx
leaq 0x17f31(%rip), %rax     # 0x1b9f0
orq (%rax,%rcx,8), %rdx
leaq 0x17f26(%rip), %rax     # 0x1b9f0
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdx
shlq $0x9, %rdx
movq 0xe533(%rip), %rax      # 0x12010
xorq $-0x1, %rax
andq %rax, %rdx
movslq -0x24(%rbp), %rcx
leaq 0x17f01(%rip), %rax     # 0x1b9f0
orq (%rax,%rcx,8), %rdx
leaq 0x17ef6(%rip), %rax     # 0x1b9f0
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x398c
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)