// File: yangwanyuan[P]HLKVDS/src/Tier.cc
// Function: hlkvds::FastTier::CreateVolume(std::vector<hlkvds::BlockDevice*, std::allocator<hlkvds::BlockDevice*>>&, unsigned long, unsigned int)
bool FastTier::CreateVolume(std::vector<BlockDevice*> &bd_vec, uint64_t sst_offset, uint32_t medium_tier_total_seg_num) {
    segSize_ = options_.segment_size;

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

    BlockDevice *bdev = bd_vec[0];
    uint64_t device_capacity = bdev->GetDeviceCapacity();
    uint32_t seg_num = DS_MultiTier_Impl::CalcSegNumForFastTierVolume(device_capacity, sst_offset, segSize_, medium_tier_total_seg_num);
    segNum_ = seg_num;
    maxValueLen_ = segSize_ - SegBase::SizeOfSegOnDisk() - IndexManager::SizeOfHashEntryOnDisk();

    uint32_t seg_total_num = segNum_ + medium_tier_total_seg_num;
    sstLengthOnDisk_ = DS_MultiTier_Impl::CalcSSTsLengthOnDiskBySegNum(seg_total_num);

    uint64_t start_off = sst_offset + sstLengthOnDisk_;
    vol_ = new Volume(bdev, idxMgr_, options_, hlkvds::FastTierVolId, start_off, segSize_, segNum_, 0);

    initSBReservedContentForCreate();

    return true;
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq %rdx, 0x78(%rsp)
movl %ecx, 0x74(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x38(%rsp)
movq (%rax), %rcx
movl 0x44(%rcx), %ecx
movl %ecx, 0x1d0(%rax)
movl $0x1000, %edi           # imm = 0x1000
callq 0x16680
movq 0x38(%rsp), %rcx
cvttsd2si %xmm0, %rax
movl %eax, 0x70(%rsp)
movl 0x1d0(%rcx), %eax
movl 0x1d0(%rcx), %edx
movl 0x70(%rsp), %ecx
shrl %cl, %edx
movl 0x70(%rsp), %ecx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
je 0x4b64c
jmp 0x4b5d1
movq 0x25a00(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, 0x30(%rsp)
callq 0x8480
movq 0x30(%rsp), %rdi
movq %rax, %rdx
leaq 0x6ebd(%rip), %rsi      # 0x524b1
leaq 0x8f98(%rip), %rcx      # 0x54593
leaq 0x8ee0(%rip), %r8       # 0x544e2
movl $0xe7, %r9d
movb $0x0, %al
callq 0x86f0
movq 0x259c2(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x8f80(%rip), %rsi      # 0x545a0
movb $0x0, %al
callq 0x86f0
movq 0x259aa(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x778d(%rip), %rsi      # 0x52dc5
movb $0x0, %al
callq 0x86f0
movb $0x0, 0x97(%rsp)
jmp 0x4b7ad
movq 0x80(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x166e0
movq (%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
callq *%rax
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x60(%rsp)
movq 0x60(%rsp), %rdi
movq 0x78(%rsp), %rsi
movl 0x1d0(%rax), %edx
movl 0x74(%rsp), %ecx
callq 0x11540
movl %eax, %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x5c(%rsp)
movl 0x5c(%rsp), %ecx
movl %ecx, 0x1d4(%rax)
movl 0x1d0(%rax), %eax
movl %eax, 0x20(%rsp)
callq 0x166a0
movq %rax, %rcx
movl 0x20(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x24(%rsp)
callq 0x166b0
movl 0x24(%rsp), %ecx
movq %rax, %rdx
movq 0x38(%rsp), %rax
subl %edx, %ecx
movl %ecx, 0x1c0(%rax)
movl 0x1d4(%rax), %eax
movl 0x74(%rsp), %ecx
addl %ecx, %eax
movl %eax, 0x58(%rsp)
movl 0x58(%rsp), %edi
callq 0x114c0
movq 0x38(%rsp), %rcx
movq %rax, 0x1c8(%rcx)
movq 0x78(%rsp), %rax
movq 0x1c8(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0x50(%rsp)
movl $0x58, %edi
callq 0x84f0
movq %rax, %rdi
movq 0x38(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x28(%rsp)
movq 0x68(%rsp), %rsi
movq (%rax), %rcx
movq 0x10(%rax), %rdx
movq 0x50(%rsp), %r9
movl 0x1d0(%rax), %r8d
movl 0x1d4(%rax), %r10d
movq %rsp, %rax
movl %r10d, 0x8(%rax)
movl %r8d, (%rax)
movl $0x0, 0x10(%rax)
movl $0x64, %r8d
callq 0x50b10
jmp 0x4b773
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rax
movq %rax, 0x1d8(%rdi)
callq 0x4b7d0
movb $0x1, 0x97(%rsp)
jmp 0x4b7ad
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
callq 0x84b0
jmp 0x4b7be
movb 0x97(%rsp), %al
andb $0x1, %al
addq $0x98, %rsp
retq
movq 0x48(%rsp), %rdi
callq 0x8820
nopl (%rax,%rax)