// File: yangwanyuan[P]HLKVDS/src/IndexManager.cc
// Function: hlkvds::IndexManager::GetHashEntry(hlkvds::KVSlice*)
bool IndexManager::GetHashEntry(KVSlice *slice) {
    const Kvdb_Digest *digest = &slice->GetDigest();
    uint32_t hash_index = KeyDigestHandle::Hash(digest) % htSize_;
    HashEntry entry;
    entry.SetKeyDigest(*digest);

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

    if (entry_list->search(entry)) {
        vector<HashEntry> tmp_vec = entry_list->get();
        for (vector<HashEntry>::iterator iter = tmp_vec.begin(); iter!=tmp_vec.end(); iter++) {
            if (iter->GetKeyDigest() == *digest) {
                entry = *iter;
                slice->SetHashEntry(&entry);
                __DEBUG("IndexManger: entry : header_offset = %lu, data_offset = %u, next_header=%u",
                        entry.GetHeaderOffset(), entry.GetDataOffsetInSeg(),
                        entry.GetNextHeadOffsetInSeg());
                return true;
            }
        }
    }
    return false;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x16d90
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x2a0b0
movq 0x10(%rsp), %rcx
movl 0x8(%rcx), %ecx
xorl %edx, %edx
divl %ecx
movl %edx, 0xa4(%rsp)
leaq 0x88(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x25040
movq 0x18(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0x25560
jmp 0x26ccf
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl 0xa4(%rsp), %ecx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
leaq 0x8(%rax,%rcx), %rsi
leaq 0x70(%rsp), %rdi
callq 0xb5f0
jmp 0x26cf7
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl 0xa4(%rsp), %ecx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x27b80
movb %al, 0xf(%rsp)
jmp 0x26d2f
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x26d3c
jmp 0x26eae
movq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x277b0
jmp 0x26d4d
leaq 0x50(%rsp), %rdi
callq 0x27870
movq %rax, 0x48(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x278e0
movq %rax, 0x40(%rsp)
leaq 0x48(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x278a0
testb $0x1, %al
jne 0x26d83
jmp 0x26e84
leaq 0x48(%rsp), %rdi
callq 0x27910
movq %rax, %rsi
leaq 0x2c(%rsp), %rdi
callq 0x276a0
jmp 0x26d9c
movq 0xa8(%rsp), %rsi
leaq 0x2c(%rsp), %rdi
callq 0x29db0
movb %al, 0xe(%rsp)
jmp 0x26db4
leaq 0x2c(%rsp), %rdi
callq 0x29d50
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0x26dcb
jmp 0x26e6c
leaq 0x48(%rsp), %rdi
callq 0x27e30
movq %rax, %rsi
leaq 0x88(%rsp), %rdi
callq 0x25500
jmp 0x26de7
movq 0xb0(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x41310
jmp 0x26dfe
movb $0x1, 0xc7(%rsp)
movl $0x1, 0x28(%rsp)
jmp 0x26e8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
jmp 0x26ef0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
jmp 0x26ee6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
jmp 0x26ea2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x80(%rsp)
movl %eax, 0x7c(%rsp)
leaq 0x2c(%rsp), %rdi
callq 0x29d50
jmp 0x26ea2
jmp 0x26e6e
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x27930
movq %rax, 0x20(%rsp)
jmp 0x26d5c
movl $0x0, 0x28(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x27970
movl 0x28(%rsp), %eax
testl %eax, %eax
jne 0x26ebe
jmp 0x26ea0
jmp 0x26eae
leaq 0x50(%rsp), %rdi
callq 0x27970
jmp 0x26ee6
movb $0x0, 0xc7(%rsp)
movl $0x1, 0x28(%rsp)
leaq 0x70(%rsp), %rdi
callq 0xb830
leaq 0x88(%rsp), %rdi
callq 0x253b0
movb 0xc7(%rsp), %al
andb $0x1, %al
addq $0xc8, %rsp
retq
leaq 0x70(%rsp), %rdi
callq 0xb830
leaq 0x88(%rsp), %rdi
callq 0x253b0
movq 0x80(%rsp), %rdi
callq 0x8820
nopw (%rax,%rax)