// File: /workspace/github_cpp_makefile_star2_O2/yangwanyuan[P]HLKVDS/src/Tier.cc
// Function: hlkvds::FastTier::WriteBatchData(hlkvds::WriteBatch*)
Status FastTier::WriteBatchData(WriteBatch *batch) {
    uint32_t seg_id = 0;
    bool ret = false;

    ret = allocSegment(seg_id);
    if (!ret) {
        __ERROR("Cann't get a new Empty Segment.\n");
        return Status::Aborted("Can't allocate a Empty Segment.");
    }

    SegForSlice *seg = new SegForSlice(vol_, idxMgr_);
    for (std::list<KVSlice *>::iterator iter = batch->batch_.begin();
            iter != batch->batch_.end(); iter++) {
        if (seg->TryPut(*iter)) {
            seg->Put(*iter);
        }
        else {
            __ERROR("The Batch is too large, can't put in one segment");
            delete seg;
            return Status::Aborted("Batch is too large.");
        }
    }

    seg->SetSegId(seg_id);
    ret = seg->WriteSegToDevice();
    if(!ret) {
        __ERROR("Write batch segment to device failed");
        vol_->FreeForFailed(seg_id);
        delete seg;
        return Status::IOError("could not write batch segment to device ");
    }

    uint32_t free_size = seg->GetFreeSize();
    vol_->Use(seg_id, free_size);
    seg->UpdateToIndex();
    delete seg;
    return Status::OK();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xc(%rsp), %rsi
andl $0x0, (%rsi)
movq %r15, %rdi
callq 0x1ba7e
testb %al, %al
je 0x1b900
pushq $0x50
popq %rdi
callq 0x6410
movq %rax, %r14
movq 0x10(%r15), %rdx
movq 0x1d8(%r15), %rsi
movq %rax, %rdi
callq 0x19436
movq %r12, %r13
movq (%r13), %r13
cmpq %r12, %r13
je 0x1b8a0
movq 0x10(%r13), %rsi
movq %r14, %rdi
callq 0x18962
testb %al, %al
je 0x1b95e
movq 0x10(%r13), %rsi
movq %r14, %rdi
callq 0x1897c
jmp 0x1b875
movl 0xc(%rsp), %eax
movl %eax, (%r14)
movq %r14, %rdi
callq 0x18a22
testb %al, %al
je 0x1b9dc
movl 0x18(%r14), %edx
subl 0x14(%r14), %edx
movq 0x1d8(%r15), %rdi
movl 0xc(%rsp), %esi
callq 0x1df82
movq %r14, %rdi
callq 0x19452
movq %r14, %rdi
callq 0x18894
movq %r14, %rdi
callq 0x63f0
andl $0x0, (%rbx)
andq $0x0, 0x8(%rbx)
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x166d1(%rip), %r15     # 0x31fd8
movq (%r15), %r14
callq 0x63c0
leaq 0x398f(%rip), %rsi      # 0x1f2a5
leaq 0x3baa(%rip), %rcx      # 0x1f4c7
leaq 0x5aa4(%rip), %r8       # 0x213c8
pushq $0x7c
popq %r9
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6580
movq (%r15), %rcx
leaq 0x3b97(%rip), %rdi      # 0x1f4d6
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
callq 0x6750
movq (%r15), %rsi
pushq $0xa
popq %rdi
callq 0x64b0
leaq 0x3b9b(%rip), %rsi      # 0x1f4f7
jmp 0x1b9cf
movq 0x16673(%rip), %r12     # 0x31fd8
movq (%r12), %r15
callq 0x63c0
leaq 0x3930(%rip), %rsi      # 0x1f2a5
leaq 0x3b4b(%rip), %rcx      # 0x1f4c7
leaq 0x5a45(%rip), %r8       # 0x213c8
movq %r15, %rdi
movq %rax, %rdx
movl $0x87, %r9d
xorl %eax, %eax
callq 0x6580
movq (%r12), %rcx
leaq 0x3b76(%rip), %rdi      # 0x1f517
pushq $0x30
popq %rsi
pushq $0x1
popq %rdx
callq 0x6750
movq (%r12), %rsi
pushq $0xa
popq %rdi
callq 0x64b0
movq %r14, %rdi
callq 0x18894
movq %r14, %rdi
callq 0x63f0
leaq 0x3b79(%rip), %rsi      # 0x1f548
movq %rbx, %rdi
callq 0xb30a
jmp 0x1b8ef
movq 0x165f5(%rip), %r13     # 0x31fd8
movq (%r13), %r12
callq 0x63c0
leaq 0x38b2(%rip), %rsi      # 0x1f2a5
leaq 0x3acd(%rip), %rcx      # 0x1f4c7
leaq 0x59c7(%rip), %r8       # 0x213c8
movq %r12, %rdi
movq %rax, %rdx
movl $0x90, %r9d
xorl %eax, %eax
callq 0x6580
movq (%r13), %rcx
leaq 0x3b3d(%rip), %rdi      # 0x1f55c
pushq $0x24
popq %rsi
pushq $0x1
popq %rdx
callq 0x6750
movq (%r13), %rsi
pushq $0xa
popq %rdi
callq 0x64b0
movq 0x1d8(%r15), %rdi
movl 0xc(%rsp), %esi
callq 0x1df6e
movq %r14, %rdi
callq 0x18894
movq %r14, %rdi
callq 0x63f0
leaq 0x3b24(%rip), %rsi      # 0x1f581
movq %rbx, %rdi
callq 0xb31e
jmp 0x1b8ef
movq %rax, %rbx
movq %r14, %rdi
callq 0x63f0
movq %rbx, %rdi
callq 0x6680
nop