// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq %rdi, %rbx
callq 0x56a4
leaq 0xd8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x43e0
leaq 0x8(%rsp), %rdi
pushq $0x2f
popq %rdx
movq %r15, %rsi
callq 0x11f0e
leaq 0xd8(%rsp), %rdi
callq 0x4120
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
subq %rsi, %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x5950
pushq $0x8
popq %rbp
leaq 0x20(%rsp), %r14
cmpq 0x40(%rsp), %rsi
je 0x5838
movq %r14, %rdi
movq %rsi, 0x48(%rsp)
callq 0x43e0
decl %ebp
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %rax
addq %r14, %rax
movq %rax, 0x50(%rsp)
xorl %r12d, %r12d
cmpq 0x50(%rsp), %r14
je 0x5813
movsbl (%r14), %r13d
leal -0x30(%r13), %r15d
cmpl $0x9, %r15d
ja 0x57d0
leal (%r12,%r13), %eax
addl $-0x30, %eax
movl %eax, 0x4(%rsp)
subl $0x1, %r15d
jb 0x5804
cmpl $0x8, %r12d
jge 0x5854
leal 0x1(%r12), %r13d
movl %ebp, %edi
movl %r12d, %esi
callq 0x5131
cltq
orl $-0x1, 0x48(%rbx,%rax,4)
movl %r13d, %r12d
jmp 0x57a5
cmpl $0x8, %r12d
jge 0x58ad
movl %ebp, %edi
movl %r12d, %esi
callq 0x5131
movl %eax, %r15d
movl %r13d, %edi
callq 0x77d4
movq %rbx, %rdi
movl %r15d, %esi
movl %eax, %edx
callq 0x5a44
incl %r12d
movl %r12d, %eax
jmp 0x5808
movl 0x4(%rsp), %eax
incq %r14
movl %eax, %r12d
jmp 0x5781
cmpl $0x8, %r12d
jne 0x5900
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x4120
movq 0x48(%rsp), %rsi
addq $0x20, %rsi
jmp 0x5752
leaq 0x8(%rsp), %rdi
callq 0x63ce
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x4150
movq %rax, %r14
leaq 0xe353(%rip), %rsi      # 0x13bb9
leaq 0x98(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0x6302
movb $0x1, %bpl
movq 0x20(%rsp), %rdx
leaq 0x98(%rsp), %rsi
movq %r14, %rdi
callq 0x633d
xorl %ebp, %ebp
movq 0x1772f(%rip), %rsi     # 0x1cfc8
movq 0x17748(%rip), %rdx     # 0x1cfe8
movq %r14, %rdi
callq 0x4520
jmp 0x59ad
pushq $0x8
popq %rdi
callq 0x4150
movq %rax, %r14
leaq 0xe2fa(%rip), %rsi      # 0x13bb9
leaq 0x78(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0x6302
movb $0x1, %bpl
movq 0x20(%rsp), %rdx
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
callq 0x633d
xorl %ebp, %ebp
movq 0x176dc(%rip), %rsi     # 0x1cfc8
movq 0x176f5(%rip), %rdx     # 0x1cfe8
movq %r14, %rdi
callq 0x4520
jmp 0x59ad
pushq $0x8
popq %rdi
callq 0x4150
movq %rax, %r14
leaq 0xe2c3(%rip), %rsi      # 0x13bd5
leaq 0x58(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0x6302
movb $0x1, %bpl
movq 0x20(%rsp), %rdx
leaq 0x58(%rsp), %rsi
movq %r14, %rdi
callq 0x633d
xorl %ebp, %ebp
movq 0x17689(%rip), %rsi     # 0x1cfc8
movq 0x176a2(%rip), %rdx     # 0x1cfe8
movq %r14, %rdi
callq 0x4520
jmp 0x59ad
pushq $0x8
popq %rdi
callq 0x4150
movq %rax, %r14
leaq 0xe22e(%rip), %rsi      # 0x13b90
leaq 0xb8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x6302
movq 0x10(%rsp), %rdx
subq 0x8(%rsp), %rdx
sarq $0x5, %rdx
movb $0x1, %bpl
leaq 0xb8(%rsp), %rsi
movq %r14, %rdi
callq 0x6271
xorl %ebp, %ebp
movq 0x1762a(%rip), %rsi     # 0x1cfc8
movq 0x17643(%rip), %rdx     # 0x1cfe8
movq %r14, %rdi
callq 0x4520
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x4120
testb %bpl, %bpl
jne 0x59c7
jmp 0x5a31
movq %rax, %rbx
movq %r14, %rdi
callq 0x4240
jmp 0x5a31
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x4120
jmp 0x5a3b
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
jmp 0x5a10
jmp 0x5a1c
movq %rax, %rbx
jmp 0x5a31
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0x5a10
jmp 0x5a1c
movq %rax, %rbx
jmp 0x5a27
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x4120
testb %bpl, %bpl
jne 0x5a1f
jmp 0x5a27
movq %rax, %rbx
movq %r14, %rdi
callq 0x4240
leaq 0x20(%rsp), %rdi
callq 0x4120
leaq 0x8(%rsp), %rdi
callq 0x63ce
movq %rbx, %rdi
callq 0x4550
nop