// File: yangwanyuan[P]HLKVDS/src/IndexManager.cc
// Function: hlkvds::IndexManager::RemoveEntry(hlkvds::HashEntry)
void IndexManager::RemoveEntry(HashEntry entry) {
    Kvdb_Digest digest = entry.GetKeyDigest();

    uint32_t hash_index = KeyDigestHandle::Hash(&digest) % htSize_;

    std::unique_lock<std::mutex> meta_lck(mtx_, std::defer_lock);
    std::lock_guard<std::mutex> l(hashtable_[hash_index].slotMtx_);
    LinkedList<HashEntry> *entry_list = hashtable_[hash_index].entryList_;

    HashEntry *entry_inMem = entry_list->getRef(entry);
    if (!entry_inMem) {
        __DEBUG("Already remove the index entry");
        return;
    }
    HashEntry::LogicStamp *lts = entry.GetLogicStamp();
    HashEntry::LogicStamp *lts_inMem = entry_inMem->GetLogicStamp();
    KVTime &t = lts->GetSegTime();
    KVTime &t_inMem = lts_inMem->GetSegTime();
    if (t_inMem == t && entry_inMem->GetDataSize() == 0) {
        entry_list->remove(entry);
        dataStor_->ModifyDeathEntry(entry);

        meta_lck.lock();
        keyCounter_--;
        meta_lck.unlock();

        __DEBUG("Remove the index entry!");
    }
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rsi, 0x40(%rsp)
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0xe4(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x276a0
movq 0x50(%rsp), %rdi
callq 0x2a0b0
movl %eax, 0x5c(%rsp)
jmp 0x2697b
movq 0x48(%rsp), %rsi
movl 0x5c(%rsp), %eax
movl 0x8(%rsi), %ecx
xorl %edx, %edx
divl %ecx
movl %edx, 0xe0(%rsp)
addq $0x48, %rsi
leaq 0xc0(%rsp), %rdi
callq 0x16db0
movq 0x48(%rsp), %rax
movq (%rax), %rax
movl 0xe0(%rsp), %ecx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
leaq 0x8(%rax,%rcx), %rsi
leaq 0xb0(%rsp), %rdi
callq 0xb5f0
jmp 0x269ce
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rax
movq (%rax), %rax
movl 0xe0(%rsp), %ecx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x252e0
jmp 0x26a12
movq 0x38(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x27be0
movq %rax, 0x30(%rsp)
jmp 0x26a2b
leaq 0x88(%rsp), %rdi
callq 0x253b0
movq 0x30(%rsp), %rax
movq %rax, 0xa0(%rsp)
cmpq $0x0, 0xa0(%rsp)
jne 0x26ad5
movl $0x1, 0x84(%rsp)
jmp 0x26bec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
jmp 0x26c35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
jmp 0x26c28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
jmp 0x26c1b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x253b0
jmp 0x26c1b
movq 0x40(%rsp), %rdi
callq 0x27c50
movq %rax, 0x28(%rsp)
jmp 0x26ae6
movq 0x28(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x27c50
movq %rax, 0x20(%rsp)
jmp 0x26b04
movq 0x20(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x78(%rsp), %rdi
callq 0x27cd0
movq %rax, 0x18(%rsp)
jmp 0x26b1f
movq 0x18(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rdi
callq 0x27cd0
movq %rax, 0x10(%rsp)
jmp 0x26b3a
movq 0x10(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x50890
movb %al, 0xf(%rsp)
jmp 0x26b59
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x26b63
jmp 0x26be1
movq 0xa0(%rsp), %rdi
callq 0x16580
movw %ax, 0xc(%rsp)
jmp 0x26b77
movw 0xc(%rsp), %ax
movzwl %ax, %eax
cmpl $0x0, %eax
jne 0x26be1
movq 0x40(%rsp), %rsi
movq 0xa8(%rsp), %rdi
callq 0x27ce0
jmp 0x26b98
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rax
movq 0x30(%rax), %rdi
movq (%rdi), %rax
movq 0xa0(%rax), %rax
callq *%rax
jmp 0x26bb4
leaq 0xc0(%rsp), %rdi
callq 0x16dd0
jmp 0x26bc3
movq 0x48(%rsp), %rax
movl 0x18(%rax), %ecx
decl %ecx
movl %ecx, 0x18(%rax)
leaq 0xc0(%rsp), %rdi
callq 0x16e30
jmp 0x26bdf
jmp 0x26be1
movl $0x0, 0x84(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xb830
leaq 0xc0(%rsp), %rdi
callq 0x15c30
leaq 0xe4(%rsp), %rdi
callq 0x29d50
addq $0x108, %rsp            # imm = 0x108
retq
leaq 0xb0(%rsp), %rdi
callq 0xb830
leaq 0xc0(%rsp), %rdi
callq 0x15c30
leaq 0xe4(%rsp), %rdi
callq 0x29d50
movq 0xd8(%rsp), %rdi
callq 0x8820
nop