// File: yangwanyuan[P]HLKVDS/src/MetaStor.cc
// Function: hlkvds::MetaStor::loadIndex(unsigned int, unsigned long)
bool MetaStor::loadIndex(uint32_t ht_size, uint64_t index_size) {
    idxMgr_->InitMeta(ht_size, index_size, sbMgr_->GetDataTheorySize(), sbMgr_->GetEntryCount());

    uint64_t length = index_size;
    char *buff = new char[length];
    memset(buff, 0, length);

    if ((uint64_t) metaDev_->pRead(buff, length, idxOff_) != length) {
        __ERROR("Could not read Index region from device at %ld\n", idxOff_);
        delete[] buff;
        return false;
    }

    if(!idxMgr_->Set(buff, length)){
        __ERROR("Can't Set Index Region, Load Failed!");
        delete[] buff;
        return false;
    }

    delete[] buff;
    return true;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x78(%rsp)
movl %esi, 0x74(%rsp)
movq %rdx, 0x68(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x20(%rax), %rcx
movq %rcx, 0x30(%rsp)
movl 0x74(%rsp), %ecx
movl %ecx, 0x3c(%rsp)
movq 0x68(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq 0x18(%rax), %rdi
callq 0x36270
movq %rax, %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x48(%rsp)
movq 0x18(%rax), %rdi
callq 0x36280
movq 0x30(%rsp), %rdi
movl 0x3c(%rsp), %esi
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
movl %eax, %r8d
callq 0x256f0
movq 0x68(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0x8040
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rdx
xorl %esi, %esi
callq 0x8280
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x40(%rax), %rcx
movq (%rdi), %rax
callq *0x50(%rax)
cmpq 0x60(%rsp), %rax
je 0x353f6
jmp 0x35358
movq 0x3bc79(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, 0x28(%rsp)
callq 0x8480
movq 0x28(%rsp), %rdi
movq %rax, %rdx
leaq 0x1d136(%rip), %rsi     # 0x524b1
leaq 0x1e1a0(%rip), %rcx     # 0x53522
leaq 0x1dec4(%rip), %r8      # 0x5324d
movl $0x134, %r9d            # imm = 0x134
movb $0x0, %al
callq 0x86f0
movq 0x50(%rsp), %rax
movq 0x3bc36(%rip), %rcx     # 0x70fd8
movq (%rcx), %rdi
movq 0x40(%rax), %rdx
leaq 0x1e17c(%rip), %rsi     # 0x5352c
movb $0x0, %al
callq 0x86f0
movq 0x3bc1a(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x1d9fd(%rip), %rsi     # 0x52dc5
movb $0x0, %al
callq 0x86f0
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x353e9
movq 0x20(%rsp), %rdi
callq 0x8610
movb $0x0, 0x87(%rsp)
jmp 0x354cc
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
callq 0x25b30
testb $0x1, %al
jne 0x354aa
jmp 0x35418
movq 0x3bbb9(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, 0x18(%rsp)
callq 0x8480
movq 0x18(%rsp), %rdi
movq %rax, %rdx
leaq 0x1d076(%rip), %rsi     # 0x524b1
leaq 0x1e0e0(%rip), %rcx     # 0x53522
leaq 0x1de04(%rip), %r8      # 0x5324d
movl $0x13a, %r9d            # imm = 0x13A
movb $0x0, %al
callq 0x86f0
movq 0x3bb7b(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x1e096(%rip), %rsi     # 0x534fd
movb $0x0, %al
callq 0x86f0
movq 0x3bb63(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x1d946(%rip), %rsi     # 0x52dc5
movb $0x0, %al
callq 0x86f0
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x354a0
movq 0x10(%rsp), %rdi
callq 0x8610
movb $0x0, 0x87(%rsp)
jmp 0x354cc
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x354c4
movq 0x8(%rsp), %rdi
callq 0x8610
movb $0x1, 0x87(%rsp)
movb 0x87(%rsp), %al
andb $0x1, %al
addq $0x88, %rsp
retq
nopl (%rax)