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

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

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

    free(align_buf);
    return true;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0x0, 0x34(%rsp)
callq 0x117e0
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdx
leaq 0x28(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x8230
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jge 0x35ffe
jmp 0x35f86
movq 0x3b04b(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x8480
movq 0x10(%rsp), %rdi
movq %rax, %rdx
leaq 0x1c508(%rip), %rsi     # 0x524b1
leaq 0x1d49f(%rip), %rcx     # 0x5344f
leaq 0x1d296(%rip), %r8      # 0x5324d
movl $0x106, %r9d            # imm = 0x106
movb $0x0, %al
callq 0x86f0
movq 0x3b00d(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x1d494(%rip), %rsi     # 0x53469
movb $0x0, %al
callq 0x86f0
movq 0x3aff5(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x1cdd8(%rip), %rsi     # 0x52dc5
movb $0x0, %al
callq 0x86f0
movb $0x0, 0x47(%rsp)
jmp 0x36172
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
xorl %esi, %esi
callq 0x8280
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x49450
testb $0x1, %al
jne 0x360b3
jmp 0x36031
movq 0x3afa0(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, 0x8(%rsp)
callq 0x8480
movq 0x8(%rsp), %rdi
movq %rax, %rdx
leaq 0x1c45d(%rip), %rsi     # 0x524b1
leaq 0x1d3f4(%rip), %rcx     # 0x5344f
leaq 0x1d1eb(%rip), %r8      # 0x5324d
movl $0x10c, %r9d            # imm = 0x10C
movb $0x0, %al
callq 0x86f0
movq 0x3af62(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x1d41f(%rip), %rsi     # 0x5349f
movb $0x0, %al
callq 0x86f0
movq 0x3af4a(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x1cd2d(%rip), %rsi     # 0x52dc5
movb $0x0, %al
callq 0x86f0
movq 0x28(%rsp), %rdi
callq 0x85b0
movb $0x0, 0x47(%rsp)
jmp 0x36172
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x38(%rax), %rcx
movq (%rdi), %rax
callq *0x48(%rax)
cmpq 0x20(%rsp), %rax
je 0x36163
jmp 0x360dd
movq 0x3aef4(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, (%rsp)
callq 0x8480
movq (%rsp), %rdi
movq %rax, %rdx
leaq 0x1c3b3(%rip), %rsi     # 0x524b1
leaq 0x1d34a(%rip), %rcx     # 0x5344f
leaq 0x1d141(%rip), %r8      # 0x5324d
movl $0x112, %r9d            # imm = 0x112
movb $0x0, %al
callq 0x86f0
movq 0x18(%rsp), %rax
movq 0x3aeb3(%rip), %rcx     # 0x70fd8
movq (%rcx), %rdi
movq 0x38(%rax), %rdx
leaq 0x1d392(%rip), %rsi     # 0x534c5
movb $0x0, %al
callq 0x86f0
movq 0x3ae97(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x1cc7a(%rip), %rsi     # 0x52dc5
movb $0x0, %al
callq 0x86f0
movq 0x28(%rsp), %rdi
callq 0x85b0
movb $0x0, 0x47(%rsp)
jmp 0x36172
movq 0x28(%rsp), %rdi
callq 0x85b0
movb $0x1, 0x47(%rsp)
movb 0x47(%rsp), %al
andb $0x1, %al
addq $0x48, %rsp
retq
nopl (%rax)