// File: /workspace/github_cpp_makefile_star2_O1/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, 0x148(%rbx)
movups %xmm0, (%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x30(%rbx)
movq %rbx, 0x50(%rsp)
movq $0x0, 0x40(%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 0x6e64
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movl $0x2f, %edx
callq 0x15d76
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x5ef4
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 0x61b0
cmpq %r12, %r14
je 0x6046
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 0x6e64
movq %r14, 0x40(%rsp)
movq 0x8(%rsp), %r12
testq %r12, %r12
je 0x6151
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 0x5fd1
testl %eax, %eax
je 0x5ffb
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 0x6081
leal (%rax,%rsi), %edi
orl %ebp, %edi
cmpl $0x8, %edi
jae 0x6062
movl $0xffffffff, (%rdx,%rsi,4) # imm = 0xFFFFFFFF
incq %rsi
cmpl %esi, %ecx
jne 0x5fa5
addl %esi, %eax
movl %eax, %ebx
jmp 0x5ffb
cmpl $0x8, %ebx
jge 0x60e9
movl %ebx, %eax
orl %ebp, %eax
cmpl $0x8, %eax
jae 0x6062
callq 0x8346
movl %ebx, %esi
orl %r13d, %esi
movq 0x50(%rsp), %rdi
movl %eax, %edx
callq 0x6320
incl %ebx
incq %r14
cmpq %r12, %r14
jne 0x5f6d
cmpl $0x8, %ebx
jne 0x6151
movq (%rsp), %rdi
leaq 0x10(%rsp), %rbx
cmpq %rbx, %rdi
movq 0x40(%rsp), %r14
movq 0x38(%rsp), %r12
je 0x6035
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42b0
addq $0x20, %r14
addl $-0x8, %r15d
cmpq %r12, %r14
jne 0x5f2e
leaq 0x20(%rsp), %rdi
callq 0x6e08
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11a60(%rip), %rdi     # 0x17ac9
leaq 0x11a06(%rip), %rsi     # 0x17a76
leaq 0x11a81(%rip), %rcx     # 0x17af8
movl $0x22, %edx
callq 0x4190
movl $0x8, %edi
callq 0x4110
movq %rax, %r14
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x11ae6(%rip), %rsi     # 0x17b87
leaq 0x11afa(%rip), %rdx     # 0x17ba2
leaq 0xb8(%rsp), %rdi
callq 0x6fca
movb $0x1, %bpl
movq (%rsp), %rdx
leaq 0xb8(%rsp), %rsi
movq %r14, %rdi
callq 0x6d19
xorl %ebp, %ebp
movq 0x1aef3(%rip), %rsi     # 0x20fc8
movq 0x1af0c(%rip), %rdx     # 0x20fe8
movq %r14, %rdi
callq 0x44c0
jmp 0x621d
movl $0x8, %edi
callq 0x4110
movq %rax, %r14
leaq 0xa8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x11a7e(%rip), %rsi     # 0x17b87
leaq 0x11a92(%rip), %rdx     # 0x17ba2
leaq 0x98(%rsp), %rdi
callq 0x6fca
movb $0x1, %bpl
movq (%rsp), %rdx
leaq 0x98(%rsp), %rsi
movq %r14, %rdi
callq 0x6d19
xorl %ebp, %ebp
movq 0x1ae8b(%rip), %rsi     # 0x20fc8
movq 0x1aea4(%rip), %rdx     # 0x20fe8
movq %r14, %rdi
callq 0x44c0
jmp 0x621d
movl $0x8, %edi
callq 0x4110
movq %rax, %r14
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x11a32(%rip), %rsi     # 0x17ba3
leaq 0x11a4f(%rip), %rdx     # 0x17bc7
leaq 0x78(%rsp), %rdi
callq 0x6fca
movb $0x1, %bpl
movq (%rsp), %rdx
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
callq 0x6d19
xorl %ebp, %ebp
movq 0x1ae29(%rip), %rsi     # 0x20fc8
movq 0x1ae42(%rip), %rdx     # 0x20fe8
movq %r14, %rdi
callq 0x44c0
jmp 0x621d
movl $0x8, %edi
callq 0x4110
movq %rax, %r14
leaq 0xe8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1198e(%rip), %rsi     # 0x17b5e
leaq 0x119af(%rip), %rdx     # 0x17b86
leaq 0xd8(%rsp), %rdi
callq 0x6fca
movq 0x28(%rsp), %rdx
subq 0x20(%rsp), %rdx
sarq $0x5, %rdx
movb $0x1, %bpl
leaq 0xd8(%rsp), %rsi
movq %r14, %rdi
callq 0x6c2a
xorl %ebp, %ebp
movq 0x1adba(%rip), %rsi     # 0x20fc8
movq 0x1add3(%rip), %rdx     # 0x20fe8
movq %r14, %rdi
callq 0x44c0
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6245
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42b0
jmp 0x6245
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x630d
movq %r14, %rdi
callq 0x41e0
jmp 0x630d
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x6317
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42b0
jmp 0x6317
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x62e5
movq 0x88(%rsp), %rsi
jmp 0x62d5
jmp 0x62df
movq %rax, %rbx
jmp 0x630d
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x62e5
movq 0xa8(%rsp), %rsi
jmp 0x62d5
jmp 0x62df
movq %rax, %rbx
jmp 0x62f2
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x62e5
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x42b0
jmp 0x62e5
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x62f2
movq %r14, %rdi
callq 0x41e0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x630d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42b0
leaq 0x20(%rsp), %rdi
callq 0x6e08
movq %rbx, %rdi
callq 0x44f0
nop