// File: /workspace/github_cpp_makefile_star2_O3/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 0x1e11f(%rip), %rbx     # 0x23990
xorl %r14d, %r14d
movl $0x8000, %edx           # imm = 0x8000
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4150
movq $-0x2, 0x10(%rsp)
movl $0x1, %edx
movl $0x2, %eax
movq %rax, 0x18(%rsp)
movl $0x8, %esi
movq $-0x8, %rdi
movl $0x9, %r8d
movl $0x7, %eax
movq %rax, 0x8(%rsp)
movq $-0x7, %r10
movq $-0x9, %r11
movdqa 0x13213(%rip), %xmm0    # 0x18ae0
movdqa 0x1321b(%rip), %xmm1    # 0x18af0
movdqa 0x13223(%rip), %xmm2    # 0x18b00
movdqa 0x1322b(%rip), %xmm3    # 0x18b10
movdqa 0x13233(%rip), %xmm4    # 0x18b20
movdqa 0x1323b(%rip), %xmm5    # 0x18b30
movl %r14d, %eax
andl $0x7, %eax
movl %eax, (%rsp)
cmpl $0x2, %eax
jb 0x5962
movq %rdx, %rbp
leal -0x1(%r14), %eax
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq 0x10(%rsp), %r12
movq %r14, %rcx
shlq $0x9, %rcx
addq %rbx, %rcx
leaq (%rcx,%r12,8), %rcx
movq (%rcx), %r9
movl %r15d, %r13d
movl %eax, %edx
btsq %rdx, %r9
decl %edx
incl %r13d
jne 0x592b
movq %r9, (%rcx)
cmpq $0x40, %r12
jae 0x5e44
movq %r12, %rcx
decq %rcx
decl %r15d
testb $0x7, %r12b
movq %rcx, %r12
jne 0x5915
cmpl $0x5, (%rsp)
movq %rbp, %rdx
ja 0x5a69
movq %rdx, %xmm6
pshufd $0x44, %xmm6, %xmm6     # xmm6 = xmm6[0,1,0,1]
paddq %xmm0, %xmm6
movq %r14, %r15
shlq $0x9, %r15
addq %rbx, %r15
xorl %r12d, %r12d
movq 0x18(%rsp), %r13
movq %r12, %r9
andq $-0x2, %r9
leaq (%r15,%r13,8), %rax
movsd (%rax), %xmm8
movq %r12, %xmm7
pshufd $0x44, %xmm7, %xmm9     # xmm9 = xmm7[0,1,0,1]
movq $-0x2, %rcx
movdqa %xmm6, %xmm10
movapd %xmm8, %xmm7
movdqa %xmm1, %xmm11
psllq %xmm10, %xmm11
pshufd $0xee, %xmm10, %xmm12   # xmm12 = xmm10[2,3,2,3]
movdqa %xmm1, %xmm8
psllq %xmm12, %xmm8
movsd %xmm11, %xmm8           # xmm8 = xmm11[0],xmm8[1]
orpd %xmm7, %xmm8
paddq %xmm2, %xmm10
addq $0x2, %rcx
cmpq %rcx, %r9
jne 0x59a9
movq %rcx, %xmm10
pshufd $0x44, %xmm10, %xmm10   # xmm10 = xmm10[0,1,0,1]
por %xmm0, %xmm10
pxor %xmm3, %xmm9
pxor %xmm3, %xmm10
movdqa %xmm10, %xmm11
pcmpgtd %xmm9, %xmm11
pshufd $0xa0, %xmm11, %xmm12   # xmm12 = xmm11[0,0,2,2]
pcmpeqd %xmm9, %xmm10
pshufd $0xf5, %xmm10, %xmm9    # xmm9 = xmm10[1,1,3,3]
pand %xmm12, %xmm9
pshufd $0xf5, %xmm11, %xmm10   # xmm10 = xmm11[1,1,3,3]
por %xmm9, %xmm10
andpd %xmm10, %xmm7
andnpd %xmm8, %xmm10
orpd %xmm7, %xmm10
pshufd $0xee, %xmm10, %xmm7    # xmm7 = xmm10[2,3,2,3]
por %xmm10, %xmm7
movq %xmm7, (%rax)
cmpq $0x40, %r13
jae 0x5e44
leaq 0x1(%r13), %rax
notl %r13d
incq %r12
testb $0x7, %r13b
movq %rax, %r13
jne 0x5982
movb $0x1, %bpl
jmp 0x5a6b
xorl %ebp, %ebp
cmpq $0x2f, %r14
ja 0x5ada
movl %ebp, 0x4(%rsp)
movq %rdx, %rbp
movl $0x8, %eax
movq %rsi, %r12
leaq 0x8(%r12), %r15
movq %r14, %rcx
shlq $0x9, %rcx
addq %rbx, %rcx
leaq (%rcx,%r12,8), %rcx
addq $0x40, %rcx
movq (%rcx), %r9
xorl %r13d, %r13d
leal (%rsi,%r13), %edx
btsq %rdx, %r9
addq $0x8, %r13
cmpq %r13, %rax
jne 0x5a9d
movq %r9, (%rcx)
cmpq $0x38, %r12
jae 0x5e25
movl %r15d, %ecx
andl $0x78, %ecx
addq $0x8, %rax
movq %r15, %r12
cmpl $0x38, %ecx
jne 0x5a80
cmpq $0x10, %r14
movq %rbp, %rdx
movl 0x4(%rsp), %ebp
jb 0x5b32
movl $0xfffffff8, %eax       # imm = 0xFFFFFFF8
movq %rdi, %r15
movq %r14, %rcx
shlq $0x9, %rcx
addq %rbx, %rcx
leaq (%rcx,%r15,8), %rcx
addq $-0x40, %rcx
addq $-0x8, %r15
movq (%rcx), %r9
movl %eax, %r12d
movl %edi, %r13d
btsq %r13, %r9
addl $-0x8, %r13d
addl $0x8, %r12d
jne 0x5b01
movq %r9, (%rcx)
cmpq $0x40, %r15
jae 0x5e25
addl $-0x8, %eax
cmpq $0x8, %r15
jae 0x5ae2
movb $0x1, %al
cmpq $0x2f, %r14
jbe 0x5b34
jmp 0x5ce9
xorl %eax, %eax
movl %eax, 0x4(%rsp)
testb %bpl, %bpl
je 0x5bc1
movq %rdx, 0x20(%rsp)
movl $0x9, %r15d
movq %r8, %r12
leaq 0x9(%r12), %rax
movq %r14, %rcx
shlq $0x9, %rcx
addq %rbx, %rcx
leaq (%rcx,%r12,8), %rcx
addq $0x48, %rcx
movq (%rcx), %r9
xorl %r13d, %r13d
leal (%r8,%r13), %edx
btsq %rdx, %r9
addq $0x9, %r13
cmpq %r13, %r15
jne 0x5b6c
movq %r9, (%rcx)
cmpq $0x37, %r12
jae 0x5e25
movl %eax, %ecx
andl $0x78, %ecx
cmpl $0x38, %ecx
je 0x5ba5
movl %eax, %ecx
andl $0x7, %ecx
addq $0x9, %r15
movq %rax, %r12
cmpl $0x7, %ecx
jne 0x5b4f
cmpq $0x30, %r14
setae %al
cmpl $0x2, (%rsp)
setb %cl
orb %al, %cl
movq 0x20(%rsp), %rdx
je 0x5bcb
jmp 0x5cde
cmpl $0x2, (%rsp)
jb 0x5cde
movq 0x8(%rsp), %r15
movq %r15, %xmm6
pshufd $0x44, %xmm6, %xmm6     # xmm6 = xmm6[0,1,0,1]
paddq %xmm4, %xmm6
xorl %r9d, %r9d
movq %r9, %r13
andq $-0x2, %r13
leaq 0x7(%r15), %r12
movq %r14, %rax
shlq $0x9, %rax
addq %rbx, %rax
leaq (%rax,%r15,8), %rax
addq $0x38, %rax
movsd (%rax), %xmm8
movq %r9, %xmm7
pshufd $0x44, %xmm7, %xmm9     # xmm9 = xmm7[0,1,0,1]
movq $-0x2, %rcx
movdqa %xmm6, %xmm10
movapd %xmm8, %xmm7
movdqa %xmm1, %xmm11
psllq %xmm10, %xmm11
pshufd $0xee, %xmm10, %xmm12   # xmm12 = xmm10[2,3,2,3]
movdqa %xmm1, %xmm8
psllq %xmm12, %xmm8
movsd %xmm11, %xmm8           # xmm8 = xmm11[0],xmm8[1]
orpd %xmm7, %xmm8
paddq %xmm5, %xmm10
addq $0x2, %rcx
cmpq %rcx, %r13
jne 0x5c1a
movq %rcx, %xmm10
pshufd $0x44, %xmm10, %xmm10   # xmm10 = xmm10[0,1,0,1]
por %xmm0, %xmm10
pxor %xmm3, %xmm9
pxor %xmm3, %xmm10
movdqa %xmm10, %xmm11
pcmpgtd %xmm9, %xmm11
pshufd $0xa0, %xmm11, %xmm12   # xmm12 = xmm11[0,0,2,2]
pcmpeqd %xmm9, %xmm10
pshufd $0xf5, %xmm10, %xmm9    # xmm9 = xmm10[1,1,3,3]
pand %xmm12, %xmm9
pshufd $0xf5, %xmm11, %xmm10   # xmm10 = xmm11[1,1,3,3]
por %xmm9, %xmm10
andpd %xmm10, %xmm7
andnpd %xmm8, %xmm10
orpd %xmm7, %xmm10
pshufd $0xee, %xmm10, %xmm7    # xmm7 = xmm10[2,3,2,3]
por %xmm10, %xmm7
movq %xmm7, (%rax)
cmpq $0x39, %r15
jae 0x5e25
movl %r12d, %eax
andl $0x78, %eax
cmpl $0x38, %eax
je 0x5cde
movl %r12d, %eax
andl $0x7, %eax
incq %r9
movq %r12, %r15
testq %rax, %rax
jne 0x5be1
cmpb $0x0, 0x4(%rsp)
je 0x5d9e
testb %bpl, %bpl
je 0x5d44
movl $0xfffffff9, %eax       # imm = 0xFFFFFFF9
movq %r10, %r15
movq %r14, %rcx
shlq $0x9, %rcx
addq %rbx, %rcx
leaq (%rcx,%r15,8), %rcx
addq $-0x38, %rcx
addq $-0x7, %r15
movq (%rcx), %r9
movl %eax, %r12d
movl %r10d, %r13d
btsq %r13, %r9
addl $-0x7, %r13d
addl $0x7, %r12d
jne 0x5d15
movq %r9, (%rcx)
cmpq $0x40, %r15
jae 0x5e25
cmpq $0x8, %r15
jb 0x5d44
movl %r15d, %ecx
andl $0x7, %ecx
addl $-0x7, %eax
cmpl $0x7, %ecx
jne 0x5cf6
cmpl $0x2, (%rsp)
jb 0x5d9e
movl $0xfffffff7, %eax       # imm = 0xFFFFFFF7
movq %r11, %r15
movq %r14, %rcx
shlq $0x9, %rcx
addq %rbx, %rcx
leaq (%rcx,%r15,8), %rcx
addq $-0x48, %rcx
addq $-0x9, %r15
movq (%rcx), %r9
movl %eax, %ebp
movl %r11d, %r12d
btsq %r12, %r9
addl $-0x9, %r12d
addl $0x9, %ebp
jne 0x5d70
movq %r9, (%rcx)
cmpq $0x40, %r15
jae 0x5e25
cmpq $0x8, %r15
jb 0x5d9e
movl %r15d, %ecx
andl $0x7, %ecx
addl $-0x9, %eax
testq %rcx, %rcx
jne 0x5d52
incq %r14
incq 0x10(%rsp)
incq %rdx
incq 0x18(%rsp)
incq %rsi
incq %rdi
incq %r8
incq 0x8(%rsp)
incq %r10
incq %r11
cmpq $0x40, %r14
jne 0x58f5
leaq 0x25bbd(%rip), %rdx     # 0x2b990
movabsq $0x101010101010101, %rsi # imm = 0x101010101010101
xorl %edi, %edi
movl %edi, %eax
andl $0x7, %eax
je 0x5df6
leal -0x1(%rax), %ecx
movq %rsi, %r8
shlq %cl, %r8
cmpl $0x7, %eax
jne 0x5df9
jmp 0x5e06
xorl %r8d, %r8d
incb %al
movq %rsi, %r9
movl %eax, %ecx
shlq %cl, %r9
orq %r9, %r8
movq %r8, (%rdx)
incq %rdi
addq $0x8, %rdx
cmpq $0x40, %rdi
jne 0x5ddf
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12df4(%rip), %rdi     # 0x18c20
leaq 0x12c43(%rip), %rsi     # 0x18a76
leaq 0x12d27(%rip), %rcx     # 0x18b61
movl $0x35, %edx
callq 0x4190
leaq 0x12dd5(%rip), %rdi     # 0x18c20
leaq 0x12c24(%rip), %rsi     # 0x18a76
leaq 0x12ce7(%rip), %rcx     # 0x18b40
movl $0x40, %edx
callq 0x4190