// File: /workspace/github_cpp_makefile_star2_O2/yangwanyuan[P]HLKVDS/src/MetaStor.cc
// Function: hlkvds::MetaStor::PersistSSTsToDevice()
bool MetaStor::PersistSSTsToDevice() {
    int ret = false;
    char *align_buf;
    uint64_t length = sbMgr_->GetSSTRegionLength();
    ret = posix_memalign((void **)&align_buf, 4096, length);
    if (ret < 0) {
        __ERROR("Can't allocate memory for SSTs, Persist Failed!");
        return false;
    }
    memset(align_buf, 0, length);

    if (!dataStor_->GetAllSSTs(align_buf, length)) {
        __ERROR("Can't Get SSTs, Persist Failed!");
        free(align_buf);
        return false;
    }

    if ((uint64_t) metaDev_->pWrite(align_buf, length, sstOff_) != length) {
        __ERROR("Could not write SSTs at position %ld\n", sstOff_);
        free(align_buf);
        return false;
    }

    free(align_buf);

    uint64_t reserved_region_length = SuperBlockManager::ReservedRegionLength();

    char *reserved_content = new char[reserved_region_length];
    if ( !dataStor_->GetSBReservedContent(reserved_content, reserved_region_length) ) {
        delete[] reserved_content;
        return false;
    }

    if ( !sbMgr_->SetReservedContent(reserved_content, reserved_region_length) ) {
        delete[] reserved_content;
        return false;
    }

    delete[] reserved_content;
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x18(%rdi), %rax
movq 0x24(%rax), %rbx
movq %rsp, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdx
callq 0x6200
testl %eax, %eax
js 0x1412d
movq (%rsp), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x6250
movq 0x28(%r14), %rdi
movq (%rsp), %rsi
movq (%rdi), %rax
movq %rbx, %rdx
callq *0x70(%rax)
testb %al, %al
je 0x1418b
movq (%rsp), %rsi
movq 0x10(%r14), %rdi
movq 0x48(%r14), %rcx
movq (%rdi), %rax
movq %rbx, %rdx
callq *0x48(%rax)
cmpq %rbx, %rax
jne 0x141de
movq (%rsp), %rdi
callq 0x6470
movl $0xfc3, %edi            # imm = 0xFC3
callq 0x6040
movq %rax, %r15
movq 0x28(%r14), %rdi
movq (%rdi), %rax
movl $0xfc3, %edx            # imm = 0xFC3
movq %r15, %rsi
callq *0x60(%rax)
testb %al, %al
je 0x1411e
movq 0x18(%r14), %rdi
movl $0xfc3, %edx            # imm = 0xFC3
movq %r15, %rsi
callq 0x1ad10
movl %eax, %ebx
movq %r15, %rdi
callq 0x64c0
jmp 0x14243
movq %r15, %rdi
callq 0x64c0
xorl %ebx, %ebx
jmp 0x14243
movq 0x1dea4(%rip), %r15     # 0x31fd8
movq (%r15), %r14
callq 0x63c0
leaq 0xb162(%rip), %rsi      # 0x1f2a5
leaq 0xc35c(%rip), %rcx      # 0x204a6
leaq 0xbef2(%rip), %r8       # 0x20043
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
movl $0x1a1, %r9d            # imm = 0x1A1
xorl %eax, %eax
callq 0x6580
movq (%r15), %rcx
leaq 0xbfb4(%rip), %rdi      # 0x20124
pushq $0x2f
popq %rsi
pushq $0x1
popq %rdx
callq 0x6750
movq (%r15), %rsi
pushq $0xa
popq %rdi
callq 0x64b0
jmp 0x14243
movq 0x1de46(%rip), %r15     # 0x31fd8
movq (%r15), %r14
callq 0x63c0
leaq 0xb104(%rip), %rsi      # 0x1f2a5
leaq 0xc2fe(%rip), %rcx      # 0x204a6
leaq 0xbe94(%rip), %r8       # 0x20043
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
movl $0x1a7, %r9d            # imm = 0x1A7
xorl %eax, %eax
callq 0x6580
movq (%r15), %rcx
leaq 0xc2ec(%rip), %rdi      # 0x204ba
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
callq 0x6750
movq (%r15), %rsi
jmp 0x14232
movq 0x1ddf3(%rip), %r12     # 0x31fd8
movq (%r12), %r15
callq 0x63c0
leaq 0xb0b0(%rip), %rsi      # 0x1f2a5
leaq 0xc2aa(%rip), %rcx      # 0x204a6
leaq 0xbe40(%rip), %r8       # 0x20043
xorl %ebx, %ebx
movq %r15, %rdi
movq %rax, %rdx
movl $0x1ad, %r9d            # imm = 0x1AD
xorl %eax, %eax
callq 0x6580
movq (%r12), %rdi
movq 0x48(%r14), %rdx
leaq 0xc2b3(%rip), %rsi      # 0x204da
xorl %eax, %eax
callq 0x6580
movq (%r12), %rsi
pushq $0xa
popq %rdi
callq 0x64b0
movq (%rsp), %rdi
callq 0x6470
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop