// File: codeandkey[P]neocortex/src/tt.cpp
// Function: neocortex::tt::resize(int)
void tt::resize(int mb) {
	std::lock_guard<std::shared_mutex> lock(tt_resize_mutex);
	if (tt_buffer) delete[] tt_buffer;
	if (tt_mutex_buffer) delete[] tt_mutex_buffer;

	tt_buffer_size = mb * 1024 * 1024 / (sizeof(tt::entry) + sizeof(std::mutex));
	tt_buffer = new tt::entry[tt_buffer_size];
	tt_mutex_buffer = new std::mutex[tt_buffer_size];

	neocortex_debug("Transposition table resized to %d mb (%d entries)\n", mb, tt_buffer_size);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl %edi, -0x4(%rbp)
leaq -0x10(%rbp), %rdi
leaq 0x20d77(%rip), %rsi     # 0x3cd50
callq 0x1c480
cmpq $0x0, 0x20d5a(%rip)     # 0x3cd40
je 0x1c004
movq 0x20d51(%rip), %rax     # 0x3cd40
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x1c002
movq -0x50(%rbp), %rdi
callq 0x5500
jmp 0x1c004
cmpq $0x0, 0x20d7c(%rip)     # 0x3cd88
je 0x1c02a
movq 0x20d73(%rip), %rax     # 0x3cd88
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x1c028
movq -0x58(%rbp), %rdi
callq 0x5500
jmp 0x1c02a
movl -0x4(%rbp), %eax
shll $0x14, %eax
cltq
movabsq $-0x1c71c71c71c71c71, %rcx # imm = 0xE38E38E38E38E38F
mulq %rcx
shrq $0x6, %rdx
movl %edx, %eax
movl %eax, 0x20cfd(%rip)     # 0x3cd48
movslq 0x20cf6(%rip), %rax     # 0x3cd48
movq %rax, -0x68(%rbp)
movl $0x20, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x5030
movq %rax, -0x60(%rbp)
jmp 0x1c077
movq -0x68(%rbp), %rax
cmpq $0x0, %rax
je 0x1c0bd
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rdx
shlq $0x5, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x78(%rbp)
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0x1c4b0
movq -0x80(%rbp), %rax
movq -0x78(%rbp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, -0x70(%rbp)
jne 0x1c09b
movq -0x60(%rbp), %rax
movq %rax, 0x20c78(%rip)     # 0x3cd40
movslq 0x20c79(%rip), %rax     # 0x3cd48
movq %rax, -0x90(%rbp)
movl $0x28, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x5030
movq %rax, -0x88(%rbp)
jmp 0x1c0fa
movq -0x90(%rbp), %rax
cmpq $0x0, %rax
je 0x1c15e
movq -0x88(%rbp), %rax
movq -0x90(%rbp), %rcx
imulq $0x28, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0xa0(%rbp)
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x18fd0
movq -0xa8(%rbp), %rax
movq -0xa0(%rbp), %rcx
addq $0x28, %rax
cmpq %rcx, %rax
movq %rax, -0x98(%rbp)
jne 0x1c12d
movq -0x88(%rbp), %rax
movq %rax, 0x20c1c(%rip)     # 0x3cd88
leaq -0x41(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x56d0
movq -0xb0(%rbp), %rdx
leaq 0xbf9e(%rip), %rsi      # 0x28128
leaq -0x40(%rbp), %rdi
callq 0x89b0
jmp 0x1c195
movl -0x4(%rbp), %esi
movl 0x20baa(%rip), %edx     # 0x3cd48
leaq -0x40(%rbp), %rdi
callq 0x1c4f0
jmp 0x1c1a9
leaq -0x40(%rbp), %rdi
callq 0x5230
leaq -0x41(%rbp), %rdi
callq 0x5480
leaq -0x10(%rbp), %rdi
callq 0x1c710
addq $0xb0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x1c207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x1c1fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5230
leaq -0x41(%rbp), %rdi
callq 0x5480
leaq -0x10(%rbp), %rdi
callq 0x1c710
movq -0x18(%rbp), %rdi
callq 0x56c0
nopl (%rax)