// File: /workspace/github_cpp_makefile_star2_O3/chahk0129[P]hash_bench/./index/linear_probing.h
// Function: LinearProbingHash<char [32]>::resize(unsigned long)
void LinearProbingHash<Key_t>::resize(size_t _capacity){
    unique_lock<shared_mutex>* lock[nlocks];
    for(int i=0; i<nlocks; i++){
	lock[i] = new unique_lock<shared_mutex>(mutex[i]);
    }
    int prev_nlocks = nlocks;
    nlocks = _capacity / locksize + 1;
    shared_mutex* old_mutex = mutex;

    Pair<Key_t>* new_dict = new Pair<Key_t>[_capacity];
    for(int i=0; i<capacity; i++){
	if constexpr(sizeof(Key_t) > 8){
	    if(memcmp(dict[i].key, INVALID<Key_t>, sizeof(Key_t)) != 0){
		auto key_hash = h(dict[i].key, sizeof(Key_t)) % _capacity;
		auto loc = getLocation(key_hash, _capacity, new_dict);
		memcpy(&new_dict[loc], &dict[i], sizeof(Pair<Key_t>));
	    }
	}
	else{
	    if(memcmp(&dict[i].key, &INVALID<Key_t>, sizeof(Key_t)) != 0){
		auto key_hash = h(&dict[i].key, sizeof(Key_t)) % _capacity;
		auto loc = getLocation(key_hash, _capacity, new_dict);
		memcpy(&new_dict[loc], &dict[i], sizeof(Pair<Key_t>));
	    }
	}
    }
    mutex = new shared_mutex[nlocks];
    old_cap = capacity;
    old_dic = dict;
    capacity = _capacity;
    dict = new_dict;
    auto tmp = old_dic;
    old_cap = 0;
    old_dic = nullptr;
    for(int i=0; i<prev_nlocks; i++){
	delete lock[i];
    }
    delete[] old_mutex;
    //delete[] tmp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %r13
movl 0x48(%rdi), %r15d
movq %rsp, %rcx
leaq 0xf(,%r15,8), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x38(%rbp)
movq %rcx, %rsp
testl %r15d, %r15d
jle 0xaae7
xorl %ebx, %ebx
xorl %r12d, %r12d
movl $0x10, %edi
callq 0x21f0
movq %rax, %r15
movq 0x40(%r13), %rax
addq %rbx, %rax
movq %rax, (%r15)
movb $0x0, 0x8(%r15)
movq %r15, %rdi
callq 0xad3c
movb $0x1, 0x8(%r15)
movq -0x38(%rbp), %rax
movq %r15, (%rax,%r12,8)
incq %r12
movslq 0x48(%r13), %r15
addq $0x38, %rbx
cmpq %r15, %r12
jl 0xaaa6
movslq 0x4c(%r13), %rcx
movq %r14, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rbx
incl %ebx
movl %ebx, 0x48(%r13)
movq %r13, -0x30(%rbp)
movq 0x40(%r13), %r13
movl $0x28, %ecx
movq %r14, %rax
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x2030
movq %rax, %r12
testq %r14, %r14
je 0xab4f
leaq (,%r14,8), %rax
leaq (%rax,%rax,4), %rax
xorl %ecx, %ecx
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%r12,%rcx)
movdqu %xmm0, (%r12,%rcx)
addq $0x28, %rcx
cmpq %rcx, %rax
jne 0xab39
movq -0x30(%rbp), %rsi
movq 0x10(%rsi), %rax
testq %rax, %rax
movq %r13, -0x40(%rbp)
je 0xac56
cmpq $0x1, %r14
movq %r14, %rcx
adcq $0x0, %rcx
movq %rcx, -0x48(%rbp)
movq 0x18(%rsi), %rcx
xorl %r13d, %r13d
leaq (,%r13,4), %rbx
addq %r13, %rbx
movdqu (%rcx,%rbx,8), %xmm0
movdqu 0x10(%rcx,%rbx,8), %xmm1
pcmpeqb 0xa748(%rip), %xmm1     # 0x152e0
pcmpeqb 0xa730(%rip), %xmm0     # 0x152d0
pand %xmm1, %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0xac47
leaq (%rcx,%rbx,8), %rdi
movl $0x20, %esi
movl $0xc70697, %edx         # imm = 0xC70697
callq 0x2050
movq -0x30(%rbp), %rsi
movq %rax, %rdx
movq -0x48(%rbp), %rcx
movq %rdx, %rax
xorl %edx, %edx
divq %r14
leaq (%rdx,%rdx,4), %rax
movdqu (%r12,%rax,8), %xmm0
movdqu 0x10(%r12,%rax,8), %xmm1
pcmpeqb 0xa6ed(%rip), %xmm1     # 0x152e0
pcmpeqb 0xa6d5(%rip), %xmm0     # 0x152d0
pand %xmm1, %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0xac19
incq %rdx
decq %rcx
jne 0xabd2
movq $-0x1, %rdx
leaq (%rdx,%rdx,4), %rax
movq 0x18(%rsi), %rcx
movq 0x20(%rcx,%rbx,8), %rdx
movq %rdx, 0x20(%r12,%rax,8)
movdqu (%rcx,%rbx,8), %xmm0
movdqu 0x10(%rcx,%rbx,8), %xmm1
movdqu %xmm1, 0x10(%r12,%rax,8)
movdqu %xmm0, (%r12,%rax,8)
movq 0x10(%rsi), %rax
incq %r13
cmpq %r13, %rax
ja 0xab7a
movl 0x48(%rsi), %ebx
movslq %ebx, %r13
movl $0x38, %ecx
movq %r13, %rax
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x2030
movq %rax, %rbx
testl %r13d, %r13d
je 0xaca7
imulq $0x38, %r13, %rax
addq $-0x38, %rax
shrq $0x3, %rax
movabsq $0x2492492492492493, %rcx # imm = 0x2492492492492493
mulq %rcx
imulq $0x38, %rdx, %rdx
addq $0x38, %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20e0
movq -0x30(%rbp), %rax
movq %rbx, 0x40(%rax)
movq %r14, 0x10(%rax)
movq %r12, 0x18(%rax)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x20(%rax)
testl %r15d, %r15d
movq -0x40(%rbp), %r12
jle 0xacf9
movl %r15d, %r14d
xorl %r15d, %r15d
movq -0x38(%rbp), %rax
movq (%rax,%r15,8), %rbx
testq %rbx, %rbx
je 0xace4
movq %rbx, %rdi
callq 0xaa52
movl $0x10, %esi
movq %rbx, %rdi
callq 0x2200
incq %r15
cmpq %r15, %r14
jne 0xaccf
testq %r12, %r12
je 0xad14
movq %r12, %rdi
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2230
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x10, %esi
movq %r15, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x2330
nop