// File: yangwanyuan[P]HLKVDS/src/Segment.cc
// Function: hlkvds::SegLatencyFriendly::fillEntryToSlice()
void SegLatencyFriendly::fillEntryToSlice() {
    uint32_t head_pos = SegBase::SizeOfSegOnDisk();
    int vol_id = vol_->GetId();

    for (list<KVSlice *>::iterator iter = sliceList_.begin(); iter
            != sliceList_.end(); iter++) {
        KVSlice *slice = *iter;
        slice->SetSegId(segId_);

        uint32_t data_offset = head_pos + IndexManager::SizeOfDataHeader() + slice->GetKeyLen();
        uint32_t next_offset = head_pos + IndexManager::SizeOfDataHeader() + slice->GetKeyLen() + slice->GetDataLen();
        DataHeader data_header(slice->GetDigest(), slice->GetKeyLen(), slice->GetDataLen(),
                               data_offset, next_offset);
        uint64_t seg_offset = 0;
        vol_->CalcSegOffsetFromId(segId_, seg_offset);
        uint64_t header_offset = seg_offset + head_pos;

        DataHeaderAddress addrs(vol_id, header_offset);
        HashEntry hash_entry(data_header, addrs, NULL);
        slice->SetHashEntry(&hash_entry);

        head_pos += IndexManager::SizeOfDataHeader() + slice->GetKeyLen() + slice->GetDataLen();
        __DEBUG("SegmentSlice: key=%s, data_offset=%u, header_offset=%lu, seg_id=%u, head_pos=%u", slice->GetKey(), data_offset, header_offset, segId_, head_pos);
    }

    if (head_pos != headPos_ ) {
        __ERROR("Segment fillEntryToSlice  Failed!!! head_pos= %u, headPos_=%u", head_pos, headPos_);
    }
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x40(%rsp)
callq 0x166a0
movq %rax, %rcx
movq 0x40(%rsp), %rax
movl %ecx, 0xdc(%rsp)
movq (%rax), %rdi
callq 0x238c0
movq 0x40(%rsp), %rdi
movl %eax, 0xd8(%rsp)
addq $0x28, %rdi
callq 0x16410
movq %rax, 0xd0(%rsp)
movq 0x40(%rsp), %rdi
addq $0x28, %rdi
callq 0x16460
movq %rax, 0xc8(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x16440
testb $0x1, %al
jne 0x43a39
jmp 0x43cef
leaq 0xd0(%rsp), %rdi
callq 0x16490
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq (%rcx), %rcx
movq %rcx, 0xc0(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x10(%rax), %esi
callq 0x413f0
movl 0xdc(%rsp), %eax
movl %eax, 0x20(%rsp)
callq 0x238d0
movq %rax, %rcx
movl 0x20(%rsp), %eax
addl %ecx, %eax
movl %eax, 0x24(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x44260
movw %ax, %cx
movl 0x24(%rsp), %eax
movzwl %cx, %ecx
addl %ecx, %eax
movl %eax, 0xbc(%rsp)
movl 0xdc(%rsp), %eax
movl %eax, 0x28(%rsp)
callq 0x238d0
movq %rax, %rcx
movl 0x28(%rsp), %eax
addl %ecx, %eax
movl %eax, 0x2c(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x44260
movw %ax, %cx
movl 0x2c(%rsp), %eax
movzwl %cx, %ecx
addl %ecx, %eax
movl %eax, 0x30(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x163a0
movw %ax, %cx
movl 0x30(%rsp), %eax
movzwl %cx, %ecx
addl %ecx, %eax
movl %eax, 0xb8(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x16d90
movq %rax, 0x38(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x44260
movw %ax, 0x36(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x163a0
movw 0x36(%rsp), %cx
movq 0x38(%rsp), %rsi
movl 0xbc(%rsp), %r8d
movl 0xb8(%rsp), %r9d
movzwl %cx, %edx
movzwl %ax, %ecx
leaq 0x98(%rsp), %rdi
callq 0x24d90
movq 0x40(%rsp), %rax
movq $0x0, 0x90(%rsp)
movq (%rax), %rdi
movl 0x10(%rax), %esi
leaq 0x90(%rsp), %rdx
callq 0x23960
jmp 0x43b84
movq 0x90(%rsp), %rax
movl 0xdc(%rsp), %ecx
addq %rcx, %rax
movq %rax, 0x78(%rsp)
movzwl 0xd8(%rsp), %esi
movq 0x78(%rsp), %rdx
leaq 0x6e(%rsp), %rdi
callq 0x238e0
jmp 0x43bb4
xorl %eax, %eax
movl %eax, %ecx
leaq 0x50(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x6e(%rsp), %rdx
callq 0x25210
jmp 0x43bd1
movq 0xc0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x41310
jmp 0x43be5
callq 0x238d0
movq %rax, 0x18(%rsp)
jmp 0x43bf1
movq 0xc0(%rsp), %rdi
callq 0x44260
movw %ax, 0x16(%rsp)
jmp 0x43c05
movq 0x18(%rsp), %rax
movw 0x16(%rsp), %cx
movzwl %cx, %ecx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x163a0
movw %ax, 0x14(%rsp)
jmp 0x43c2e
movq 0x8(%rsp), %rcx
movw 0x14(%rsp), %ax
movzwl %ax, %eax
addq %rax, %rcx
movl 0xdc(%rsp), %eax
addq %rcx, %rax
movl %eax, 0xdc(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x253b0
leaq 0x6e(%rsp), %rdi
callq 0x24e40
leaq 0x98(%rsp), %rdi
callq 0x24e00
leaq 0xd0(%rsp), %rdi
xorl %esi, %esi
callq 0x164c0
movq %rax, 0x48(%rsp)
jmp 0x43a05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0x43cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
jmp 0x43cd3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x253b0
leaq 0x6e(%rsp), %rdi
callq 0x24e40
leaq 0x98(%rsp), %rdi
callq 0x24e00
jmp 0x43d87
movq 0x40(%rsp), %rcx
movl 0xdc(%rsp), %eax
cmpl 0x18(%rcx), %eax
je 0x43d7f
jmp 0x43d02
movq 0x2d2cf(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, (%rsp)
callq 0x8480
movq (%rsp), %rdi
movq %rax, %rdx
leaq 0xe78e(%rip), %rsi      # 0x524b1
leaq 0x1049f(%rip), %rcx     # 0x541c9
leaq 0x1046f(%rip), %r8      # 0x541a0
movl $0x29b, %r9d            # imm = 0x29B
movb $0x0, %al
callq 0x86f0
movq 0x40(%rsp), %rax
movq 0x2d28e(%rip), %rcx     # 0x70fd8
movq (%rcx), %rdi
movl 0xdc(%rsp), %edx
movl 0x18(%rax), %ecx
leaq 0x104d7(%rip), %rsi     # 0x54235
movb $0x0, %al
callq 0x86f0
movq 0x2d26c(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0xf04f(%rip), %rsi      # 0x52dc5
movb $0x0, %al
callq 0x86f0
jmp 0x43d7f
addq $0xe8, %rsp
retq
movq 0x88(%rsp), %rdi
callq 0x8820
nopw %cs:(%rax,%rax)