// File: /workspace/github_cpp_makefile_star2_O3/codeandkey[P]neocortex/src/board.cpp
// Function: neocortex::Board::Board(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Board::Board(std::string uci) : Board() {
	std::vector<std::string> ranks = util::split(uci, '/');

	if (ranks.size() != 8) {
		throw util::fmterr("Invalid UCI: expected 8 ranks, parsed %d", ranks.size());
	}

	int r = 8;
	for (auto rank : ranks) {
		--r;
		int f = 0;

		for (auto c : rank) {
			if (isdigit(c)) {
				for (int j = 0; j < (c - '0'); ++j) {
					if (f >= 8) {
						throw util::fmterr("Invalid UCI: overflow in %s", rank.c_str());
					}

					state[square::at(r, f++)] = piece::null;
				}
			} else {
				if (f >= 8) {
					throw util::fmterr("Invalid UCI: overflow in %s", rank.c_str());
				}

				place(square::at(r, f++), piece::from_uci(c));
			}
		}

		if (f != 8) {
			throw util::fmterr("Invalid UCI: not enough pieces in %s", rank.c_str());
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %r15
movq %rdi, %rbx
addq $0x48, %rdi
movl $0x100, %edx            # imm = 0x100
movq %rdi, 0x48(%rsp)
movl $0xff, %esi
callq 0x4150
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x30(%rbx)
movq $0x0, 0x40(%rbx)
movq %rbx, 0x50(%rsp)
movups %xmm0, 0x148(%rbx)
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x6f6c
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movl $0x2f, %edx
callq 0x16006
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x6008
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42b0
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %r12
movq %r12, %rax
subq %r14, %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x62c4
cmpq %r12, %r14
je 0x615a
leaq 0x10(%rsp), %rbx
movl $0x38, %r15d
movl $0x8, %ebp
movq %r12, 0x38(%rsp)
movq %rbx, (%rsp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x6f6c
movq %r14, 0x40(%rsp)
movq 0x8(%rsp), %r12
testq %r12, %r12
je 0x6265
movl %r15d, %r15d
decl %ebp
movq (%rsp), %r14
addq %r14, %r12
leal (,%rbp,8), %r13d
xorl %ebx, %ebx
movsbl (%r14), %edi
leal -0x30(%rdi), %eax
cmpl $0x9, %eax
ja 0x60e5
testl %eax, %eax
je 0x610f
movslq %edi, %rcx
movl %ebx, %eax
cmpl $0x9, %ebx
movl $0x8, %edx
cmovll %edx, %ebx
leaq (%r15,%rax), %rdx
movq 0x48(%rsp), %rsi
leaq (%rsi,%rdx,4), %rdx
negl %ebx
addq %rax, %rbx
addq $-0x30, %rcx
xorl %esi, %esi
movl %ebx, %edi
addl %esi, %edi
je 0x6195
leal (%rax,%rsi), %edi
orl %ebp, %edi
cmpl $0x8, %edi
jae 0x6176
movl $0xffffffff, (%rdx,%rsi,4) # imm = 0xFFFFFFFF
incq %rsi
cmpl %esi, %ecx
jne 0x60b9
addl %esi, %eax
movl %eax, %ebx
jmp 0x610f
cmpl $0x8, %ebx
jge 0x61fd
movl %ebx, %eax
orl %ebp, %eax
cmpl $0x8, %eax
jae 0x6176
callq 0x844e
movl %ebx, %esi
orl %r13d, %esi
movq 0x50(%rsp), %rdi
movl %eax, %edx
callq 0x642c
incl %ebx
incq %r14
cmpq %r12, %r14
jne 0x6081
cmpl $0x8, %ebx
jne 0x6265
movq (%rsp), %rdi
leaq 0x10(%rsp), %rbx
cmpq %rbx, %rdi
movq 0x40(%rsp), %r14
movq 0x38(%rsp), %r12
je 0x6149
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42b0
addq $0x20, %r14
addl $-0x8, %r15d
cmpq %r12, %r14
jne 0x6042
leaq 0x20(%rsp), %rdi
callq 0x6f0e
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12906(%rip), %rdi     # 0x18a83
leaq 0x128f2(%rip), %rsi     # 0x18a76
leaq 0x12927(%rip), %rcx     # 0x18ab2
movl $0x22, %edx
callq 0x4190
movl $0x8, %edi
callq 0x4110
movq %rax, %r14
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x129f6(%rip), %rsi     # 0x18bab
leaq 0x12a0a(%rip), %rdx     # 0x18bc6
leaq 0xb8(%rsp), %rdi
callq 0x70d8
movb $0x1, %bpl
movq (%rsp), %rdx
leaq 0xb8(%rsp), %rsi
movq %r14, %rdi
callq 0x6e1f
xorl %ebp, %ebp
movq 0x1bddf(%rip), %rsi     # 0x21fc8
movq 0x1bdf8(%rip), %rdx     # 0x21fe8
movq %r14, %rdi
callq 0x44c0
jmp 0x6331
movl $0x8, %edi
callq 0x4110
movq %rax, %r14
leaq 0xa8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1298e(%rip), %rsi     # 0x18bab
leaq 0x129a2(%rip), %rdx     # 0x18bc6
leaq 0x98(%rsp), %rdi
callq 0x70d8
movb $0x1, %bpl
movq (%rsp), %rdx
leaq 0x98(%rsp), %rsi
movq %r14, %rdi
callq 0x6e1f
xorl %ebp, %ebp
movq 0x1bd77(%rip), %rsi     # 0x21fc8
movq 0x1bd90(%rip), %rdx     # 0x21fe8
movq %r14, %rdi
callq 0x44c0
jmp 0x6331
movl $0x8, %edi
callq 0x4110
movq %rax, %r14
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x12942(%rip), %rsi     # 0x18bc7
leaq 0x1295f(%rip), %rdx     # 0x18beb
leaq 0x78(%rsp), %rdi
callq 0x70d8
movb $0x1, %bpl
movq (%rsp), %rdx
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
callq 0x6e1f
xorl %ebp, %ebp
movq 0x1bd15(%rip), %rsi     # 0x21fc8
movq 0x1bd2e(%rip), %rdx     # 0x21fe8
movq %r14, %rdi
callq 0x44c0
jmp 0x6331
movl $0x8, %edi
callq 0x4110
movq %rax, %r14
leaq 0xe8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1289e(%rip), %rsi     # 0x18b82
leaq 0x128bf(%rip), %rdx     # 0x18baa
leaq 0xd8(%rsp), %rdi
callq 0x70d8
movq 0x28(%rsp), %rdx
subq 0x20(%rsp), %rdx
sarq $0x5, %rdx
movb $0x1, %bpl
leaq 0xd8(%rsp), %rsi
movq %r14, %rdi
callq 0x6d30
xorl %ebp, %ebp
movq 0x1bca6(%rip), %rsi     # 0x21fc8
movq 0x1bcbf(%rip), %rdx     # 0x21fe8
movq %r14, %rdi
callq 0x44c0
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6351
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42b0
testb %bpl, %bpl
jne 0x635e
jmp 0x641a
movq %rax, %rbx
movq %r14, %rdi
callq 0x41e0
jmp 0x641a
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x6424
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42b0
jmp 0x6424
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x63ed
movq 0x88(%rsp), %rsi
jmp 0x63e5
jmp 0x63f4
movq %rax, %rbx
jmp 0x641a
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x63ed
movq 0xa8(%rsp), %rsi
jmp 0x63e5
jmp 0x63f4
movq %rax, %rbx
jmp 0x63ff
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x63ed
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x42b0
testb %bpl, %bpl
jne 0x63f7
jmp 0x63ff
movq %rax, %rbx
movq %r14, %rdi
callq 0x41e0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x641a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42b0
leaq 0x20(%rsp), %rdi
callq 0x6f0e
movq %rbx, %rdi
callq 0x44f0