// File: yangwanyuan[P]HLKVDS/src/Tier.cc
// Function: hlkvds::FastTier::GetKeyByHashEntry[abi:cxx11](hlkvds::HashEntry*)
std::string FastTier::GetKeyByHashEntry(HashEntry *entry) {
    uint64_t key_offset = 0;

    if (!vol_->CalcKeyOffsetPhyFromEntry(entry, key_offset)) {
        return "";
    }
    __DEBUG("key offset: %lu",key_offset);
    uint16_t key_len = entry->GetKeySize();
    char *mkey = new char[key_len+1];
    if (!vol_->Read(mkey, key_len, key_offset)) {
        __ERROR("Could not read data at position");
        delete[] mkey;
        return "";
    }
    mkey[key_len] = '\0';
    string res(mkey, key_len);
    //__INFO("Iterator key is %s, key_offset = %lu, key_len = %u", mkey, key_offset, key_len);
    delete[] mkey;

    return res;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0x48(%rsp)
movq %rdi, %rax
movq %rax, 0x50(%rsp)
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdx, 0x90(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x58(%rsp)
movq $0x0, 0x88(%rsp)
movq 0x1d8(%rax), %rdi
movq 0x90(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x513b0
testb $0x1, %al
jne 0x4beb1
leaq 0x87(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x8830
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rdx
leaq 0x6f4e(%rip), %rsi      # 0x52dc6
callq 0x8680
jmp 0x4be7f
leaq 0x87(%rsp), %rdi
callq 0x8540
jmp 0x4c09d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x87(%rsp), %rdi
callq 0x8540
jmp 0x4c0aa
movq 0x90(%rsp), %rdi
callq 0x16800
movw %ax, 0x72(%rsp)
movzwl 0x72(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rdi
movq $-0x1, %rax
cmpq $0x0, %rdi
cmovlq %rax, %rdi
callq 0x8040
movq %rax, %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x68(%rsp)
movq 0x1d8(%rax), %rdi
movq 0x68(%rsp), %rsi
movzwl 0x72(%rsp), %eax
movl %eax, %edx
movq 0x88(%rsp), %rcx
callq 0x50ed0
testb $0x1, %al
jne 0x4bff4
jmp 0x4bf19
movq 0x250b8(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, 0x38(%rsp)
callq 0x8480
movq 0x38(%rsp), %rdi
movq %rax, %rdx
leaq 0x6575(%rip), %rsi      # 0x524b1
leaq 0x692d(%rip), %rcx      # 0x52870
leaq 0x8598(%rip), %r8       # 0x544e2
movl $0x138, %r9d            # imm = 0x138
movb $0x0, %al
callq 0x86f0
movq 0x2507a(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x686c(%rip), %rsi      # 0x527d4
movb $0x0, %al
callq 0x86f0
movq 0x25062(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x6e45(%rip), %rsi      # 0x52dc5
movb $0x0, %al
callq 0x86f0
movq 0x68(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x4bfa1
movq 0x30(%rsp), %rdi
callq 0x8610
leaq 0x67(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x8830
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rdx
leaq 0x6e05(%rip), %rsi      # 0x52dc6
callq 0x8680
jmp 0x4bfc8
leaq 0x67(%rsp), %rdi
callq 0x8540
jmp 0x4c09d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x67(%rsp), %rdi
callq 0x8540
jmp 0x4c0aa
movq 0x68(%rsp), %rax
movzwl 0x72(%rsp), %ecx
movb $0x0, (%rax,%rcx)
movb $0x0, 0x66(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movzwl 0x72(%rsp), %eax
movq %rax, 0x18(%rsp)
leaq 0x65(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x8830
movq 0x48(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0x8570
jmp 0x4c045
leaq 0x65(%rsp), %rdi
callq 0x8540
movq 0x68(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x4c069
movq 0x8(%rsp), %rdi
callq 0x8610
movb $0x1, 0x66(%rsp)
testb $0x1, 0x66(%rsp)
jne 0x4c09b
jmp 0x4c091
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x65(%rsp), %rdi
callq 0x8540
jmp 0x4c0aa
movq 0x48(%rsp), %rdi
callq 0x8928
jmp 0x4c09d
movq 0x50(%rsp), %rax
addq $0xa8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0x8820
nopw %cs:(%rax,%rax)