// File: vygr[P]C-Chess/chess.cpp
// Function: score(score_board const&, int, int, int, int)
auto score(const score_board &sbrd, int colour, int alpha, int beta, int ply)
{
	static auto trans_table = std::unordered_map<std::string, int>{};
	static auto trans_lru = std::list<std::string>{};
	if (ply < 2) return score_impl(sbrd, colour, alpha, beta, ply);
	std::string key; key.reserve(90);
	key += sbrd.brd; key += ":";
	key += std::to_string(colour); key += ":";
	key += std::to_string(ply); key += ":";
	key += std::to_string(alpha); key += ":";
	key += std::to_string(beta);
	auto search = trans_table.find(key);
	if (search != end(trans_table)) return search->second;
	auto score = score_impl(sbrd, colour, alpha, beta, ply);
	if (score == timeout_value || score == -timeout_value) return score;
	trans_table[key] = score;
	trans_lru.push_back(key);
	if (trans_lru.size() > max_score_entries)
	{
		trans_table.erase(trans_lru.front());
		trans_lru.pop_front();
	}
	return score;
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x108(%rsp)
movl %esi, 0x104(%rsp)
movl %edx, 0x100(%rsp)
movl %ecx, 0xfc(%rsp)
movl %r8d, 0xf8(%rsp)
cmpb $0x0, 0x210ad(%rip)     # 0x264c0
jne 0x546b
leaq 0x210a4(%rip), %rdi     # 0x264c0
callq 0x23a0
cmpl $0x0, %eax
je 0x546b
leaq 0x2105b(%rip), %rdi     # 0x26488
xorl %esi, %esi
movl $0x38, %edx
callq 0x2110
leaq 0x21048(%rip), %rdi     # 0x26488
callq 0xa930
leaq 0x54f4(%rip), %rdi      # 0xa940
leaq 0x21035(%rip), %rsi     # 0x26488
leaq 0x20d96(%rip), %rdx     # 0x261f0
callq 0x21d0
leaq 0x2105a(%rip), %rdi     # 0x264c0
callq 0x2150
cmpb $0x0, 0x2106e(%rip)     # 0x264e0
jne 0x54ca
leaq 0x21065(%rip), %rdi     # 0x264e0
callq 0x23a0
cmpl $0x0, %eax
je 0x54ca
leaq 0x2103c(%rip), %rdi     # 0x264c8
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
leaq 0x21029(%rip), %rdi     # 0x264c8
callq 0xa950
leaq 0x54b5(%rip), %rdi      # 0xa960
leaq 0x21016(%rip), %rsi     # 0x264c8
leaq 0x20d37(%rip), %rdx     # 0x261f0
callq 0x21d0
leaq 0x2101b(%rip), %rdi     # 0x264e0
callq 0x2150
cmpl $0x2, 0xf8(%rsp)
jge 0x550a
movq 0x108(%rsp), %rdi
movl 0x104(%rsp), %esi
movl 0x100(%rsp), %edx
movl 0xfc(%rsp), %ecx
movl 0xf8(%rsp), %r8d
callq 0x58d0
movl %eax, 0x114(%rsp)
jmp 0x58b2
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x22f0
movq 0x28(%rsp), %rdi
movl $0x5a, %esi
callq 0x2330
jmp 0x552d
movq 0x108(%rsp), %rsi
addq $0x8, %rsi
leaq 0xd8(%rsp), %rdi
callq 0x2290
jmp 0x5548
leaq 0x15705(%rip), %rsi     # 0x1ac54
leaq 0xd8(%rsp), %rdi
callq 0x2200
jmp 0x555e
movl 0x104(%rsp), %esi
leaq 0xa8(%rsp), %rdi
callq 0xa970
jmp 0x5574
leaq 0xd8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x2290
jmp 0x558b
leaq 0xa8(%rsp), %rdi
callq 0x2140
leaq 0x156b5(%rip), %rsi     # 0x1ac54
leaq 0xd8(%rsp), %rdi
callq 0x2200
jmp 0x55ae
movl 0xf8(%rsp), %esi
leaq 0x88(%rsp), %rdi
callq 0xa970
jmp 0x55c4
leaq 0xd8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x2290
jmp 0x55db
leaq 0x88(%rsp), %rdi
callq 0x2140
leaq 0x15665(%rip), %rsi     # 0x1ac54
leaq 0xd8(%rsp), %rdi
callq 0x2200
jmp 0x55fe
movl 0x100(%rsp), %esi
leaq 0x68(%rsp), %rdi
callq 0xa970
jmp 0x5611
leaq 0xd8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2290
jmp 0x5625
leaq 0x68(%rsp), %rdi
callq 0x2140
leaq 0x1561e(%rip), %rsi     # 0x1ac54
leaq 0xd8(%rsp), %rdi
callq 0x2200
jmp 0x5645
movl 0xfc(%rsp), %esi
leaq 0x48(%rsp), %rdi
callq 0xa970
jmp 0x5658
leaq 0xd8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x2290
jmp 0x566c
leaq 0x48(%rsp), %rdi
callq 0x2140
leaq 0x20e0b(%rip), %rdi     # 0x26488
leaq 0xd8(%rsp), %rsi
callq 0xaab0
movq %rax, 0x20(%rsp)
jmp 0x5691
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x20de6(%rip), %rdi     # 0x26488
callq 0xab00
movq %rax, 0x18(%rsp)
jmp 0x56ae
movq 0x18(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xaae0
testb $0x1, %al
jne 0x56d0
jmp 0x579c
leaq 0x40(%rsp), %rdi
callq 0xab30
movl 0x20(%rax), %eax
movl %eax, 0x114(%rsp)
movl $0x1, 0x34(%rsp)
jmp 0x5894
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0x58a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x2140
jmp 0x58a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x2140
jmp 0x58a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x2140
jmp 0x58a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x2140
jmp 0x58a3
movq 0x108(%rsp), %rdi
movl 0x104(%rsp), %esi
movl 0x100(%rsp), %edx
movl 0xfc(%rsp), %ecx
movl 0xf8(%rsp), %r8d
callq 0x58d0
movl %eax, 0x14(%rsp)
jmp 0x57cc
movl 0x14(%rsp), %eax
movl %eax, 0x30(%rsp)
cmpl $0x61a80, 0x30(%rsp)    # imm = 0x61A80
je 0x57e8
cmpl $0xfff9e580, 0x30(%rsp) # imm = 0xFFF9E580
jne 0x5800
movl 0x30(%rsp), %eax
movl %eax, 0x114(%rsp)
movl $0x1, 0x34(%rsp)
jmp 0x5894
movl 0x30(%rsp), %eax
movl %eax, 0x4(%rsp)
leaq 0x20c79(%rip), %rdi     # 0x26488
leaq 0xd8(%rsp), %rsi
callq 0xab50
movq %rax, 0x8(%rsp)
jmp 0x5823
movq 0x8(%rsp), %rax
movl 0x4(%rsp), %ecx
movl %ecx, (%rax)
leaq 0x20c93(%rip), %rdi     # 0x264c8
leaq 0xd8(%rsp), %rsi
callq 0xab80
jmp 0x5844
leaq 0x20c7d(%rip), %rdi     # 0x264c8
callq 0xabc0
cmpq $0x186a0, %rax          # imm = 0x186A0
jbe 0x5881
leaq 0x20c69(%rip), %rdi     # 0x264c8
callq 0xac20
movq %rax, %rsi
leaq 0x20c1a(%rip), %rdi     # 0x26488
callq 0xabf0
jmp 0x5875
leaq 0x20c4c(%rip), %rdi     # 0x264c8
callq 0xac50
movl 0x30(%rsp), %eax
movl %eax, 0x114(%rsp)
movl $0x1, 0x34(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x2140
jmp 0x58b2
leaq 0xd8(%rsp), %rdi
callq 0x2140
jmp 0x58c1
movl 0x114(%rsp), %eax
addq $0x118, %rsp            # imm = 0x118
retq
movq 0xd0(%rsp), %rdi
callq 0x2380
nop