// File: /workspace/github_cpp_makefile_star2_O1/yangwanyuan[P]HLKVDS/src/Segment.cc
// Function: hlkvds::SegBase::fillEntryToSlice()
void SegBase::fillEntryToSlice() {
    uint32_t head_pos = SegBase::SizeOfSegOnDisk();
    uint32_t tail_pos = segSize_;
    int vol_id = vol_->GetId();
    for (list<KVSlice *>::iterator iter = sliceList_.begin(); iter
            != sliceList_.end(); iter++) {

        KVSlice *slice = *iter;
        slice->SetSegId(segId_);
        if (slice->IsAlignedData()) {
            uint32_t data_offset = tail_pos - ALIGNED_SIZE;
            uint32_t next_offset = head_pos + IndexManager::SizeOfDataHeader() + slice->GetKeyLen();
            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();
            tail_pos -= ALIGNED_SIZE;
            __DEBUG("SegmentSlice: key=%s, data_offset=%u, header_offset=%lu, seg_id=%u, head_pos=%u, tail_pos = %u", slice->GetKey(), data_offset, header_offset, segId_, head_pos, tail_pos);
        } else {
            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, tail_pos = %u", slice->GetKey(), data_offset, header_offset, segId_, head_pos, tail_pos);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %r14
movl 0x10(%rdi), %eax
movl %eax, 0x10(%rsp)
leaq 0x28(%rdi), %rax
movq 0x28(%rdi), %r13
movq %rax, 0x28(%rsp)
cmpq %rax, %r13
je 0x1c0d5
movq 0x8(%r14), %rax
movzwl 0x28(%rax), %eax
movw %ax, 0xe(%rsp)
movl $0x20, %ebx
leaq 0x50(%rsp), %r12
movq %r14, 0x20(%rsp)
movq 0x10(%r13), %rbp
movl (%r14), %eax
movl %eax, 0x30(%rbp)
movzwl 0x18(%rbp), %eax
movl %ebx, %r15d
cmpq $0x1000, %rax           # imm = 0x1000
jne 0x1bfe0
movl 0x10(%rsp), %r8d
addl $0xfffff000, %r8d       # imm = 0xFFFFF000
movzwl 0x8(%rbp), %eax
leal (%rbx,%rax), %r9d
addl $0x20, %r9d
movq 0x20(%rbp), %rsi
movzwl 0x8(%rbp), %edx
movzwl 0x18(%rbp), %ecx
leaq 0x30(%rsp), %rdi
movl %r8d, 0x10(%rsp)
callq 0x10d26
movq 0x8(%r14), %rcx
movl (%r14), %eax
cmpl %eax, 0x3c(%rcx)
jbe 0x1c01e
movb 0x40(%rcx), %cl
shlq %cl, %rax
jmp 0x1c020
movzwl 0x8(%rbp), %ecx
leal (%rbx,%rcx), %edx
leal (%rbx,%rcx), %r8d
addl $0x20, %r8d
leal 0x20(%rax,%rdx), %r9d
movq 0x20(%rbp), %rsi
movzwl 0x8(%rbp), %edx
movzwl 0x18(%rbp), %ecx
leaq 0x30(%rsp), %rdi
callq 0x10d26
movq 0x8(%r14), %rcx
movl (%r14), %eax
cmpl %eax, 0x3c(%rcx)
jbe 0x1c05d
movb 0x40(%rcx), %cl
shlq %cl, %rax
jmp 0x1c05f
xorl %eax, %eax
addq %rax, %r15
movzwl 0xe(%rsp), %eax
movw %ax, 0x16(%rsp)
movq %r15, 0x18(%rsp)
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
leaq 0x16(%rsp), %r14
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x10f8c
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1bab2
movzwl 0x8(%rbp), %ebp
addl $0x20, %ebp
jmp 0x1c0a1
xorl %eax, %eax
addq %rax, %r15
movzwl 0xe(%rsp), %eax
movw %ax, 0x16(%rsp)
movq %r15, 0x18(%rsp)
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
leaq 0x16(%rsp), %r14
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x10f8c
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1bab2
movzwl 0x8(%rbp), %eax
movzwl 0x18(%rbp), %ecx
leal (%rax,%rcx), %ebp
addl $0x20, %ebp
movq %r12, %rdi
callq 0x11066
movq %r14, %rdi
callq 0x10d6e
leaq 0x30(%rsp), %rdi
callq 0x10d62
addl %ebx, %ebp
movq (%r13), %r13
movl %ebp, %ebx
cmpq 0x28(%rsp), %r13
movq 0x20(%rsp), %r14
jne 0x1bf80
jmp 0x1c0da
movl $0x20, %ebp
cmpl 0x14(%r14), %ebp
movl 0x10(%rsp), %ecx
jne 0x1c0f9
cmpl 0x18(%r14), %ecx
jne 0x1c0f9
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14(%r14), %rdi
addq $0x18, %r14
movq %r14, %rsi
movl %ebp, %edx
callq 0x8664
jmp 0x1c0ea
jmp 0x1c10f
movq %rax, %rbx
jmp 0x1c123
jmp 0x1c116
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x11066
leaq 0x16(%rsp), %rdi
callq 0x10d6e
leaq 0x30(%rsp), %rdi
callq 0x10d62
movq %rbx, %rdi
callq 0x6680
nop