// File: /workspace/github_cpp_makefile_star2_O1/chahk0129[P]hash_bench/./index/cuckoo_hash.h
// Function: CuckooHash<char [32]>::Delete(char (&) [32])
bool CuckooHash<Key_t>::Delete(Key_t& key) {
    size_t f_hash, s_hash;
    if constexpr(sizeof(Key_t) > 8){
        f_hash = hash_funcs[0](key, sizeof(Key_t), _seed);
        s_hash = hash_funcs[1](key, sizeof(Key_t), _seed);
    }
    else{
        f_hash = hash_funcs[0](&key, sizeof(Key_t), _seed);
        s_hash = hash_funcs[1](&key, sizeof(Key_t), _seed);
    }

RETRY:
    while(resizing_lock){
        asm("nop");
    }

    auto f_idx = f_hash % capacity;
    auto s_idx = s_hash % capacity;

    { // try first hashing
        unique_lock<shared_mutex> lock(mutex[f_idx/locksize]);
        if constexpr(sizeof(Key_t) > 8){
            if(memcmp(table[f_idx].key, key, sizeof(Key_t)) == 0){
                memcpy(table[f_idx].key, INVALID<Key_t>, sizeof(Key_t));
                return true;
            }
        }
        else{
            if(memcmp(&table[f_idx].key, &key, sizeof(Key_t)) == 0){
                memcpy(&table[f_idx].key, &INVALID<Key_t>, sizeof(Key_t));
                return true;
            }
        }
    }

    { // try second hashing
        unique_lock<shared_mutex> lock(mutex[s_idx/locksize]);
        if constexpr(sizeof(Key_t) > 8){
            if(memcmp(table[s_idx].key, key, sizeof(Key_t)) == 0){
                memcpy(table[s_idx].key, INVALID<Key_t>, sizeof(Key_t));
                return true;
            }
        }
        else{
            if(memcmp(&table[s_idx].key, &key, sizeof(Key_t)) == 0){
                memcpy(&table[s_idx].key, &INVALID<Key_t>, sizeof(Key_t));
                return true;
            }
        }
    }
                                                                           
  return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rdi), %rdx
movl $0x20, %esi
movq %rbx, %rdi
callq 0x2050
movl 0x8(%r14), %ebp
xorl $0x20, %ebp
xorl %ecx, %ecx
imull $0x5bd1e995, (%rbx,%rcx), %edx # imm = 0x5BD1E995
movl %edx, %esi
shrl $0x18, %esi
xorl %edx, %esi
imull $0x5bd1e995, %esi, %edx # imm = 0x5BD1E995
imull $0x5bd1e995, %ebp, %ebp # imm = 0x5BD1E995
xorl %edx, %ebp
addq $0x4, %rcx
cmpq $0x20, %rcx
jne 0xaada
jmp 0xab03
nop
cmpl $0x0, 0xc8(%r14)
jne 0xab02
movq 0x30(%r14), %r13
xorl %edx, %edx
divq %r13
movq %rdx, %r15
movslq 0xdc(%r14), %rcx
movq %rdx, %rax
xorl %edx, %edx
divq %rcx
imulq $0x38, %rax, %rax
addq 0xd0(%r14), %rax
leaq 0x8(%rsp), %r12
movq %rax, (%r12)
movb $0x0, 0x8(%r12)
movq %r12, %rdi
callq 0xa0ba
movb $0x1, 0x8(%r12)
movq 0x38(%r14), %rax
leaq (%r15,%r15,4), %rcx
movdqu (%rax,%rcx,8), %xmm0
movdqu 0x10(%rax,%rcx,8), %xmm1
movdqu (%rbx), %xmm2
pcmpeqb %xmm0, %xmm2
movdqu 0x10(%rbx), %xmm0
pcmpeqb %xmm1, %xmm0
pand %xmm2, %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0xac46
movl %ebp, %eax
shrl $0xd, %eax
xorl %ebp, %eax
imull $0x5bd1e995, %eax, %ecx # imm = 0x5BD1E995
movl %ecx, %eax
shrl $0xf, %eax
xorl %ecx, %eax
xorl %edx, %edx
divq %r13
movq %rdx, %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x9de6
movslq 0xdc(%r14), %rcx
movq %r15, %rax
xorl %edx, %edx
divq %rcx
imulq $0x38, %rax, %rax
addq 0xd0(%r14), %rax
movq %rax, (%r12)
movb $0x0, 0x8(%r12)
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0xa0ba
movb $0x1, 0x8(%r12)
movq 0x38(%r14), %rax
leaq (%r15,%r15,4), %rcx
movdqu (%rax,%rcx,8), %xmm0
movdqu 0x10(%rax,%rcx,8), %xmm1
movdqu (%rbx), %xmm2
pcmpeqb %xmm0, %xmm2
movdqu 0x10(%rbx), %xmm0
pcmpeqb %xmm1, %xmm0
pand %xmm2, %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
sete %bl
jne 0xac3a
leaq (%rax,%rcx,8), %rax
movaps 0x96b6(%rip), %xmm0     # 0x142e0
movups %xmm0, 0x10(%rax)
movdqa 0x969a(%rip), %xmm0     # 0x142d0
movdqu %xmm0, (%rax)
leaq 0x8(%rsp), %rdi
callq 0x9de6
jmp 0xac6d
leaq (%rax,%rcx,8), %rax
movaps 0x968f(%rip), %xmm0     # 0x142e0
movups %xmm0, 0x10(%rax)
movdqa 0x9673(%rip), %xmm0     # 0x142d0
movdqu %xmm0, (%rax)
leaq 0x8(%rsp), %rdi
callq 0x9de6
movb $0x1, %bl
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq