// File: /workspace/github_cpp_makefile_star2_O1/codeandkey[P]neocortex/src/bitboard.cpp
// Function: neocortex::bb::init()
void bb::init() {
	/* zero lookup buf */
	for (int i = 0; i < 64; ++i) {
		for (int j = 0; j < 64; ++j) {
			BETWEEN[i][j] = 0ULL;
		}
	}

	/* construct lookup */
	for (int src = 0; src < 64; ++src) {
		/* west */
		if (square::file(src) > 1) {
			int t = src - 2;

			do {
				for (int j = src - 1; j != t; --j) {
					BETWEEN[src][t] |= 1ULL << j;
				}
			} while (square::file(t--) != 0);
		}

		/* east */
		if (square::file(src) < 6) {
			int t = src + 2;

			do {
				for (int j = src + 1; j != t; ++j) {
					BETWEEN[src][t] |= 1ULL << j;
				}
			} while (square::file(t++) != 7);
		}

		/* north */
		if (square::rank(src) < 6) {
			int t = src + NORTH;

			do {
				t += NORTH;

				for (int j = src + NORTH; j != t; j += NORTH) {
					BETWEEN[src][t] |= 1ULL << j;
				}
			} while (square::rank(t) != 7);
		}

		/* south */
		if (square::rank(src) > 1) {
			int t = src + SOUTH;

			do {
				t += SOUTH;

				for (int j = src + SOUTH; j != t; j += SOUTH) {
					BETWEEN[src][t] |= 1ULL << j;
				}
			} while (square::rank(t) != 0);
		}
		
		/* northeast */
		if (square::rank(src) < 6 && square::file(src) < 6) {
			int t = src + NORTHEAST;

			do {
				t += NORTHEAST;

				for (int j = src + NORTHEAST; j != t; j += NORTHEAST) {
					BETWEEN[src][t] |= 1ULL << j;
				}
			} while (square::rank(t) != 7 && square::file(t) != 7);
		}

		/* northwest */
		if (square::rank(src) < 6 && square::file(src) > 1) {
			int t = src + NORTHWEST;

			do {
				t += NORTHWEST;

				for (int j = src + NORTHWEST; j != t; j += NORTHWEST) {
					BETWEEN[src][t] |= 1ULL << j;
				}
			} while (square::rank(t) != 7 && square::file(t) != 0);
		}

		/* southeast */
		if (square::rank(src) > 1 && square::file(src) < 6) {
			int t = src + SOUTHEAST;

			do {
				t += SOUTHEAST;

				for (int j = src + SOUTHEAST; j != t; j += SOUTHEAST) {
					BETWEEN[src][t] |= 1ULL << j;
				}
			} while (square::rank(t) != 0 && square::file(t) != 7);
		}

		/* southwest */
		if (square::rank(src) > 1 && square::file(src) > 1) {
			int t = src + SOUTHWEST;

			do {
				t += SOUTHWEST;

				for (int j = src + SOUTHWEST; j != t; j += SOUTHWEST) {
					BETWEEN[src][t] |= 1ULL << j;
				}
			} while (square::rank(t) != 0 && square::file(t) != 0);
		}
	}

	// generate neighbor files
	for (int sq = 0; sq < 64; ++sq) {
		int f = square::file(sq);
		NEIGHBOR_FILES[sq] = 0ULL;

		if (f > 0) {
			NEIGHBOR_FILES[sq] |= bb::file(f - 1);
		}

		if (f < 7) {
			NEIGHBOR_FILES[sq] |= bb::file(f + 1);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x1d063(%rip), %rbx     # 0x22990
xorl %r14d, %r14d
movl $0x8000, %edx           # imm = 0x8000
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4150
movq $-0x2, 0x18(%rsp)
movl $0x1, %ecx
movl $0x2, %eax
movq %rax, 0x10(%rsp)
movl $0x8, %esi
movq $-0x8, %rbp
movl $0x9, %r8d
movl $0x7, %r9d
movq $-0x7, %r10
movq $-0x9, %r11
movq %rbp, 0x20(%rsp)
movl %r14d, %eax
andl $0x7, %eax
movl %eax, 0xc(%rsp)
cmpl $0x2, %eax
jb 0x59de
leal -0x1(%r14), %r15d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq 0x18(%rsp), %r13
movq %r14, %rax
shlq $0x9, %rax
addq %rbx, %rax
leaq (%rax,%r13,8), %rax
movq (%rax), %rdx
movl %r12d, %ebp
movl %r15d, %edi
btsq %rdi, %rdx
decl %edi
incl %ebp
jne 0x59b7
movq %rdx, (%rax)
cmpq $0x40, %r13
jae 0x5d2f
leaq -0x1(%r13), %rax
decl %r12d
testb $0x7, %r13b
movq %rax, %r13
jne 0x59a0
cmpl $0x5, 0xc(%rsp)
ja 0x5a35
movl $0x1, %r15d
movq 0x10(%rsp), %r12
movq %r14, %rax
shlq $0x9, %rax
addq %rbx, %rax
leaq (%rax,%r12,8), %r13
movq (%r13), %rax
xorl %edx, %edx
leal (%rcx,%rdx), %edi
btsq %rdi, %rax
incq %rdx
cmpq %rdx, %r15
jne 0x5a04
movq %rax, (%r13)
cmpq $0x40, %r12
jae 0x5d2f
leaq 0x1(%r12), %rax
notl %r12d
incq %r15
testb $0x7, %r12b
movq %rax, %r12
jne 0x59f0
cmpq $0x2f, %r14
ja 0x5a8e
movl $0x8, %r15d
movq %rsi, %r13
leaq 0x8(%r13), %r12
movq %r14, %rax
shlq $0x9, %rax
addq %rbx, %rax
leaq (%rax,%r13,8), %rax
addq $0x40, %rax
movq (%rax), %rdx
xorl %ebp, %ebp
leal (%rsi,%rbp), %edi
btsq %rdi, %rdx
addq $0x8, %rbp
cmpq %rbp, %r15
jne 0x5a5f
movq %rdx, (%rax)
cmpq $0x38, %r13
jae 0x5d10
movl %r12d, %eax
andl $0x78, %eax
addq $0x8, %r15
movq %r12, %r13
cmpl $0x38, %eax
jne 0x5a44
cmpq $0x10, %r14
movq 0x20(%rsp), %rbp
jb 0x5add
movq %rbp, %r12
leaq -0x8(%r12), %r15
movq %r14, %rax
shlq $0x9, %rax
addq %rbx, %rax
leaq (%rax,%r12,8), %rax
addq $-0x40, %rax
movq (%rax), %rdx
movl %ebp, %edi
movl %edi, %r13d
btsq %rdi, %rdx
addl $-0x8, %edi
cmpq %r13, %r12
jne 0x5ab8
movq %rdx, (%rax)
cmpq $0x40, %r15
jae 0x5d10
movq %r15, %r12
cmpq $0x8, %r15
jae 0x5a9c
cmpq $0x30, %r14
setae %al
cmpl $0x6, 0xc(%rsp)
setae %dl
orb %al, %dl
jne 0x5b4f
movl $0x9, %r15d
movq %r8, %r13
leaq 0x9(%r13), %r12
movq %r14, %rax
shlq $0x9, %rax
addq %rbx, %rax
leaq (%rax,%r13,8), %rax
addq $0x48, %rax
movq (%rax), %rdx
xorl %ebp, %ebp
leal (%r8,%rbp), %edi
btsq %rdi, %rdx
addq $0x9, %rbp
cmpq %rbp, %r15
jne 0x5b14
movq %rdx, (%rax)
cmpq $0x37, %r13
jae 0x5d10
movl %r12d, %eax
andl $0x78, %eax
cmpl $0x38, %eax
je 0x5b4f
movl %r12d, %eax
andl $0x7, %eax
addq $0x9, %r15
movq %r12, %r13
cmpl $0x7, %eax
jne 0x5af9
cmpq $0x30, %r14
setae %al
cmpl $0x2, 0xc(%rsp)
setb %dl
orb %al, %dl
jne 0x5bc1
movl $0x7, %r15d
movq %r9, %r13
leaq 0x7(%r13), %r12
movq %r14, %rax
shlq $0x9, %rax
addq %rbx, %rax
leaq (%rax,%r13,8), %rax
addq $0x38, %rax
movq (%rax), %rdx
xorl %ebp, %ebp
leal (%r9,%rbp), %edi
btsq %rdi, %rdx
addq $0x7, %rbp
cmpq %rbp, %r15
jne 0x5b86
movq %rdx, (%rax)
cmpq $0x39, %r13
jae 0x5d10
movl %r12d, %eax
andl $0x78, %eax
cmpl $0x38, %eax
je 0x5bc1
movl %r12d, %eax
andl $0x7, %eax
addq $0x7, %r15
movq %r12, %r13
testq %rax, %rax
jne 0x5b6b
cmpq $0x10, %r14
setb %al
cmpl $0x6, 0xc(%rsp)
setae %dl
orb %al, %dl
movq 0x20(%rsp), %rbp
jne 0x5c29
movq %r10, %r12
leaq -0x7(%r12), %r15
movq %r14, %rax
shlq $0x9, %rax
addq %rbx, %rax
leaq (%rax,%r12,8), %rax
addq $-0x38, %rax
movq (%rax), %rdx
movl %r10d, %edi
movl %edi, %r13d
btsq %rdi, %rdx
addl $-0x7, %edi
cmpq %r13, %r12
jne 0x5bf9
movq %rdx, (%rax)
cmpq $0x40, %r15
jae 0x5d10
cmpq $0x8, %r15
jb 0x5c29
movl %r15d, %eax
andl $0x7, %eax
movq %r15, %r12
cmpl $0x7, %eax
jne 0x5bdc
cmpq $0x10, %r14
setb %al
cmpl $0x2, 0xc(%rsp)
setb %dl
orb %al, %dl
jne 0x5c89
movq %r11, %r12
leaq -0x9(%r12), %r15
movq %r14, %rax
shlq $0x9, %rax
addq %rbx, %rax
leaq (%rax,%r12,8), %rax
addq $-0x48, %rax
movq (%rax), %rdx
movl %r11d, %edi
movl %edi, %r13d
btsq %rdi, %rdx
addl $-0x9, %edi
cmpq %r13, %r12
jne 0x5c5c
movq %rdx, (%rax)
cmpq $0x40, %r15
jae 0x5d10
cmpq $0x8, %r15
jb 0x5c89
movl %r15d, %eax
movq %r15, %r12
andl $0x7, %eax
jne 0x5c3f
incq %r14
incq 0x18(%rsp)
incq %rcx
incq 0x10(%rsp)
incq %rsi
incq %rbp
incq %r8
incq %r9
incq %r10
incq %r11
cmpq $0x40, %r14
jne 0x597d
leaq 0x24cd4(%rip), %rdx     # 0x2a990
movabsq $0x101010101010101, %rsi # imm = 0x101010101010101
xorl %edi, %edi
movl %edi, %eax
movq $0x0, (%rdx)
andl $0x7, %eax
je 0x5ce7
leal -0x1(%rax), %ecx
movq %rsi, %r8
shlq %cl, %r8
movq %r8, (%rdx)
cmpl $0x7, %eax
je 0x5cf4
incb %al
movq %rsi, %r8
movl %eax, %ecx
shlq %cl, %r8
orq %r8, (%rdx)
incq %rdi
addq $0x8, %rdx
cmpq $0x40, %rdi
jne 0x5cc8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11d74(%rip), %rdi     # 0x17a8b
leaq 0x11d58(%rip), %rsi     # 0x17a76
leaq 0x11e18(%rip), %rcx     # 0x17b3d
movl $0x35, %edx
callq 0x4190
leaq 0x11d55(%rip), %rdi     # 0x17a8b
leaq 0x11d39(%rip), %rsi     # 0x17a76
leaq 0x11dd8(%rip), %rcx     # 0x17b1c
movl $0x40, %edx
callq 0x4190