// File: /workspace/github_cpp_makefile_star2_O2/yangwanyuan[P]HLKVDS/src/DS_MultiVolume_Impl.cc
// Function: hlkvds::DS_MultiVolume_Impl::CreateAllComponents(unsigned long)
bool DS_MultiVolume_Impl::CreateAllComponents(uint64_t sst_offset) {
    segSize_ = options_.segment_size;

    uint32_t align_bit = log2(ALIGNED_SIZE);
    if (segSize_ != (segSize_ >> align_bit) << align_bit) {
        __ERROR("Segment Size is not page aligned!");
        return false;
    }

    maxValueLen_ = segSize_ - SegBase::SizeOfSegOnDisk() - IndexManager::SizeOfHashEntryOnDisk();
    volNum_ = bdVec_.size();

    //Create Pure Volumes
    if (volNum_ > 1) {
        for (uint32_t i = 1; i < volNum_; i++ ) {
            BlockDevice * bdev = bdVec_[i];
            uint64_t device_capacity = bdev->GetDeviceCapacity();
            uint32_t seg_num = calcSegNumForPureVolume(device_capacity, segSize_);
            segTotalNum_ += seg_num;
            Volume *vol = new Volume(bdev, idxMgr_, options_, i, 0, segSize_, seg_num, 0);
            volMap_.insert( pair<int, Volume *>(i, vol) );
        }
    }

    //Create Meta Volumes
    BlockDevice * bdev = bdVec_[0];
    uint64_t device_capacity = bdev->GetDeviceCapacity();
    uint32_t seg_num = calcSegNumForMetaVolume(device_capacity, sst_offset, segTotalNum_, segSize_);
    segTotalNum_ += seg_num;
    sstLengthOnDisk_ = calcSSTsLengthOnDiskBySegNum(segTotalNum_);
    uint64_t start_off = sst_offset + sstLengthOnDisk_;
    Volume *vol = new Volume(bdev, idxMgr_, options_, 0, start_off, segSize_, seg_num, 0);
    volMap_.insert( make_pair(0, vol) );

    initSBReservedContentForCreate();

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq 0x8(%rdi), %rax
movl 0x44(%rax), %r12d
movl %r12d, 0xd8(%rdi)
testw $0xfff, %r12w           # imm = 0xFFF
jne 0xa3cb
movq %rdi, %rbx
movq %rsi, 0x28(%rsp)
leal -0x4a(%r12), %eax
movl %eax, 0xdc(%rdi)
movq 0x10(%rdi), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
subq %rcx, %rax
shrq $0x3, %rax
movl %eax, 0xe0(%rdi)
cmpl $0x2, %eax
jb 0xa315
movq %r12, 0x20(%rsp)
leaq 0x28(%rbx), %rcx
movq %rcx, 0x30(%rsp)
pushq $0x1
popq %r12
movl %eax, %eax
movq 0x10(%rbx), %rcx
movq (%rcx), %rcx
cmpq %rax, %r12
jae 0xa310
movq (%rcx,%r12,8), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x30(%rax)
movl 0xd8(%rbx), %r15d
xorl %edx, %edx
divq %r15
movq %rax, %rbp
addl %ebp, 0xe4(%rbx)
pushq $0x58
popq %rdi
callq 0x6410
movq %rax, %r14
movq 0x8(%rbx), %rcx
movq 0x20(%rbx), %rdx
andl $0x0, 0x10(%rsp)
movl %ebp, 0x8(%rsp)
movl %r15d, (%rsp)
movq %rax, %rdi
movq %r13, %rsi
movl %r12d, %r8d
xorl %r9d, %r9d
callq 0x1dc4c
movl %r12d, 0x38(%rsp)
movq %r14, 0x40(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xccc8
incq %r12
movl 0xe0(%rbx), %eax
jmp 0xa287
movq 0x20(%rsp), %r12
movq (%rcx), %r15
movq (%r15), %rax
movq %r15, %rdi
callq *0x30(%rax)
movl 0xd8(%rbx), %r8d
movl 0xe4(%rbx), %ecx
movq %rbx, %rdi
movq %rax, %rsi
movq 0x28(%rsp), %r13
movq %r13, %rdx
callq 0xa446
movl %eax, %ebp
movl 0xe4(%rbx), %esi
addl %eax, %esi
movl %esi, 0xe4(%rbx)
callq 0xa4c0
movq %rax, 0xe8(%rbx)
addq %rax, %r13
pushq $0x58
popq %rdi
callq 0x6410
movq %rax, %r14
movq 0x8(%rbx), %rcx
movq 0x20(%rbx), %rdx
movl 0xd8(%rbx), %eax
andl $0x0, 0x10(%rsp)
movl %ebp, 0x8(%rsp)
movl %eax, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
xorl %r8d, %r8d
movq %r13, %r9
callq 0x1dc4c
leaq 0x28(%rbx), %rdi
leaq 0x38(%rsp), %rsi
andl $0x0, (%rsi)
movq %r14, 0x8(%rsi)
callq 0xccc8
movq %rbx, %rdi
callq 0xa4e4
testw $0xfff, %r12w           # imm = 0xFFF
sete %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x27c06(%rip), %r14     # 0x31fd8
movq (%r14), %rbx
callq 0x63c0
leaq 0x14ec4(%rip), %rsi     # 0x1f2a5
leaq 0x1525e(%rip), %rcx     # 0x1f646
leaq 0x14f71(%rip), %r8      # 0x1f360
movq %rbx, %rdi
movq %rax, %rdx
movl $0x134, %r9d            # imm = 0x134
xorl %eax, %eax
callq 0x6580
movq (%r14), %rcx
leaq 0x171db(%rip), %rdi     # 0x215e7
pushq $0x21
popq %rsi
pushq $0x1
popq %rdx
callq 0x6750
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x64b0
jmp 0xa3b3
jmp 0xa426
movq %rax, %rbx
movq %r14, %rdi
callq 0x63f0
movq %rbx, %rdi
callq 0x6680
nop