// File: 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
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rsi, -0x168(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x7450
movq -0x168(%rbp), %rsi
leaq -0x48(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x5150
movq -0x160(%rbp), %rsi
leaq -0x28(%rbp), %rdi
movl $0x2f, %edx
callq 0x21e90
jmp 0x7568
leaq -0x48(%rbp), %rdi
callq 0x5230
leaq -0x28(%rbp), %rdi
callq 0x88c0
cmpq $0x8, %rax
je 0x7662
movb $0x1, -0x7a(%rbp)
movl $0x8, %edi
callq 0x51b0
movq %rax, -0x180(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x56d0
movq -0x178(%rbp), %rdx
leaq 0x1e5d9(%rip), %rsi     # 0x25b90
leaq -0x78(%rbp), %rdi
callq 0x89b0
jmp 0x75c2
leaq -0x28(%rbp), %rdi
callq 0x88c0
movq -0x180(%rbp), %rdi
movq %rax, %rdx
leaq -0x78(%rbp), %rsi
callq 0x88e0
jmp 0x75e0
movq -0x180(%rbp), %rdi
movb $0x0, -0x7a(%rbp)
movq 0x2b9de(%rip), %rsi     # 0x32fd0
movq 0x2b9ef(%rip), %rdx     # 0x32fe8
callq 0x5680
jmp 0x7b78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5230
jmp 0x7b6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x7640
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5230
leaq -0x79(%rbp), %rdi
callq 0x5480
testb $0x1, -0x7a(%rbp)
jne 0x7651
jmp 0x765d
movq -0x180(%rbp), %rdi
callq 0x5300
jmp 0x7b66
movl $0x8, -0x80(%rbp)
leaq -0x28(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x8a60
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rdi
callq 0x8a90
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x8ac0
testb $0x1, %al
jne 0x76b6
jmp 0x7b54
leaq -0x90(%rbp), %rdi
callq 0x8b00
movq %rax, %rsi
leaq -0xb8(%rbp), %rdi
callq 0x5150
jmp 0x76d3
movl -0x80(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x80(%rbp)
movl $0x0, -0xbc(%rbp)
leaq -0xb8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rdi
callq 0x5380
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rdi
callq 0x5200
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x8b20
testb $0x1, %al
jne 0x7736
jmp 0x7a40
leaq -0xd0(%rbp), %rdi
callq 0x8b60
movb (%rax), %al
movb %al, -0xd9(%rbp)
movsbl -0xd9(%rbp), %edi
callq 0x53b0
cmpl $0x0, %eax
je 0x78f1
movl $0x0, -0xe0(%rbp)
movl -0xe0(%rbp), %eax
movsbl -0xd9(%rbp), %ecx
subl $0x30, %ecx
cmpl %ecx, %eax
jge 0x78ec
cmpl $0x8, -0xbc(%rbp)
jl 0x787e
movb $0x1, -0x102(%rbp)
movl $0x8, %edi
callq 0x51b0
movq %rax, -0x190(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x56d0
movq -0x188(%rbp), %rdx
leaq 0x1e3f2(%rip), %rsi     # 0x25bb9
leaq -0x100(%rbp), %rdi
callq 0x89b0
jmp 0x77d5
leaq -0xb8(%rbp), %rdi
callq 0x5140
movq -0x190(%rbp), %rdi
movq %rax, %rdx
leaq -0x100(%rbp), %rsi
callq 0x8b80
jmp 0x77f9
movq -0x190(%rbp), %rdi
movb $0x0, -0x102(%rbp)
movq 0x2b7c2(%rip), %rsi     # 0x32fd0
movq 0x2b7d3(%rip), %rdx     # 0x32fe8
callq 0x5680
jmp 0x7b78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x7b66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x7856
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x5230
leaq -0x101(%rbp), %rdi
callq 0x5480
testb $0x1, -0x102(%rbp)
jne 0x786d
jmp 0x7879
movq -0x190(%rbp), %rdi
callq 0x5300
jmp 0x7b46
movq -0x170(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x1a0(%rbp)
movl -0x80(%rbp), %edi
movl -0xbc(%rbp), %esi
movl %esi, %eax
incl %eax
movl %eax, -0xbc(%rbp)
callq 0x6c20
movl %eax, -0x194(%rbp)
jmp 0x78b0
movq -0x1a0(%rbp), %rax
movl -0x194(%rbp), %ecx
movslq %ecx, %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0x7769
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x7b46
jmp 0x7a2d
cmpl $0x8, -0xbc(%rbp)
jl 0x79dd
movb $0x1, -0x12a(%rbp)
movl $0x8, %edi
callq 0x51b0
movq %rax, -0x1b0(%rbp)
leaq -0x129(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x56d0
movq -0x1a8(%rbp), %rdx
leaq 0x1e282(%rip), %rsi     # 0x25bb9
leaq -0x128(%rbp), %rdi
callq 0x89b0
jmp 0x7945
leaq -0xb8(%rbp), %rdi
callq 0x5140
movq -0x1b0(%rbp), %rdi
movq %rax, %rdx
leaq -0x128(%rbp), %rsi
callq 0x8b80
jmp 0x7969
movq -0x1b0(%rbp), %rdi
movb $0x0, -0x12a(%rbp)
movq 0x2b652(%rip), %rsi     # 0x32fd0
movq 0x2b663(%rip), %rdx     # 0x32fe8
callq 0x5680
jmp 0x7b78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x79b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x5230
leaq -0x129(%rbp), %rdi
callq 0x5480
testb $0x1, -0x12a(%rbp)
jne 0x79cc
jmp 0x79d8
movq -0x1b0(%rbp), %rdi
callq 0x5300
jmp 0x7b46
movl -0x80(%rbp), %edi
movl -0xbc(%rbp), %esi
movl %esi, %eax
incl %eax
movl %eax, -0xbc(%rbp)
callq 0x6c20
movl %eax, -0x1b4(%rbp)
jmp 0x79fd
movsbl -0xd9(%rbp), %edi
callq 0xbe40
movl %eax, -0x1b8(%rbp)
jmp 0x7a11
movl -0x1b8(%rbp), %edx
movl -0x1b4(%rbp), %esi
movq -0x170(%rbp), %rdi
callq 0x7b80
jmp 0x7a2b
jmp 0x7a2d
jmp 0x7a2f
leaq -0xd0(%rbp), %rdi
callq 0x8c50
jmp 0x771a
cmpl $0x8, -0xbc(%rbp)
je 0x7b29
movb $0x1, -0x152(%rbp)
movl $0x8, %edi
callq 0x51b0
movq %rax, -0x1c8(%rbp)
leaq -0x151(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x56d0
movq -0x1c0(%rbp), %rdx
leaq 0x1e14f(%rip), %rsi     # 0x25bd5
leaq -0x150(%rbp), %rdi
callq 0x89b0
jmp 0x7a94
leaq -0xb8(%rbp), %rdi
callq 0x5140
movq -0x1c8(%rbp), %rdi
movq %rax, %rdx
leaq -0x150(%rbp), %rsi
callq 0x8b80
jmp 0x7ab8
movq -0x1c8(%rbp), %rdi
movb $0x0, -0x152(%rbp)
movq 0x2b503(%rip), %rsi     # 0x32fd0
movq 0x2b514(%rip), %rdx     # 0x32fe8
callq 0x5680
jmp 0x7b78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x7b04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x5230
leaq -0x151(%rbp), %rdi
callq 0x5480
testb $0x1, -0x152(%rbp)
jne 0x7b1b
jmp 0x7b27
movq -0x1c8(%rbp), %rdi
callq 0x5300
jmp 0x7b46
leaq -0xb8(%rbp), %rdi
callq 0x5230
leaq -0x90(%rbp), %rdi
callq 0x8c70
jmp 0x769a
leaq -0xb8(%rbp), %rdi
callq 0x5230
jmp 0x7b66
leaq -0x28(%rbp), %rdi
callq 0x8c90
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x8c90
movq -0x50(%rbp), %rdi
callq 0x56c0
nopl (%rax,%rax)