// File: yangwanyuan[P]HLKVDS/src/Kvdb_Impl.cc
// Function: hlkvds::KVDS::Create_KVDS(char const*, hlkvds::Options)
KVDS* KVDS::Create_KVDS(const char* filename, Options opts) {
    if (filename == NULL) {
        return NULL;
    }

    KVDS* kvds = new KVDS(filename, opts);

    if (!kvds->openAllDevices(kvds->paths_)) {
        delete kvds;
        return NULL;
    }

    int datastor_type = opts.datastor_type;
    kvds->dataStor_ = DataStor::Create(kvds->options_, kvds->bdVec_, kvds->sbMgr_, kvds->idxMgr_, datastor_type);

    if (kvds->dataStor_ == NULL) {
        delete kvds;
        return NULL;
    }

    kvds->idxMgr_->InitDataStor(kvds->dataStor_);
    kvds->metaStor_->InitDataStor(kvds->dataStor_);

    if (!kvds->metaStor_->CreateMetaData()) {
        delete kvds;
        return NULL;
    }

    __INFO("\nCreate KVDS Success!!!");
    kvds->printDbStates();

    kvds->dataStor_->InitSegmentBuffer();
    kvds->startThds();

    kvds->isOpen_ = true;

    return kvds;

}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
leaq 0x150(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %rdi, 0x138(%rsp)
cmpq $0x0, 0x138(%rsp)
jne 0x2b5fb
movq $0x0, 0x140(%rsp)
jmp 0x2b971
movl $0xc0, %edi
callq 0x84f0
movq %rax, %rdi
movq 0xa0(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x98(%rsp)
movq 0x138(%rsp), %rsi
movups 0x40(%rax), %xmm0
movaps %xmm0, 0x120(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups 0x30(%rax), %xmm3
movaps %xmm3, 0x110(%rsp)
movaps %xmm2, 0x100(%rsp)
movaps %xmm1, 0xf0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movaps 0x120(%rsp), %xmm0
movq %rsp, %rax
movups %xmm0, 0x40(%rax)
movaps 0xe0(%rsp), %xmm0
movaps 0xf0(%rsp), %xmm1
movaps 0x100(%rsp), %xmm2
movaps 0x110(%rsp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x2c450
jmp 0x2b6a3
movq 0x98(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x130(%rsp), %rsi
movq %rsi, 0x80(%rsp)
addq $0x8, %rsi
leaq 0xb0(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x81a0
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x2b990
movb %al, 0x97(%rsp)
jmp 0x2b6fa
movb 0x97(%rsp), %al
xorb $-0x1, %al
movb %al, 0x7f(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x8928
movb 0x7f(%rsp), %al
testb $0x1, %al
jne 0x2b71e
jmp 0x2b799
movq 0x130(%rsp), %rax
movq %rax, 0x70(%rsp)
cmpq $0x0, %rax
je 0x2b73c
movq 0x70(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x140(%rsp)
jmp 0x2b971
movq 0x98(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
callq 0x84b0
jmp 0x2b981
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x8928
jmp 0x2b981
movq 0xa0(%rsp), %rax
movl 0x3c(%rax), %eax
movl %eax, 0xac(%rsp)
movq 0x130(%rsp), %rdi
addq $0x50, %rdi
movq 0x130(%rsp), %rsi
addq $0xa0, %rsi
movq 0x130(%rsp), %rax
movq 0x28(%rax), %rdx
movq 0x130(%rsp), %rax
movq 0x30(%rax), %rcx
movl 0xac(%rsp), %r8d
callq 0x21b30
movq %rax, %rcx
movq 0x130(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x130(%rsp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x2b838
movq 0x130(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpq $0x0, %rax
je 0x2b827
movq 0x68(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x140(%rsp)
jmp 0x2b971
movq 0x130(%rsp), %rax
movq 0x30(%rax), %rdi
movq 0x130(%rsp), %rax
movq 0x48(%rax), %rsi
callq 0x25610
movq 0x130(%rsp), %rax
movq 0x40(%rax), %rdi
movq 0x130(%rsp), %rax
movq 0x48(%rax), %rsi
callq 0x34150
movq 0x130(%rsp), %rax
movq 0x40(%rax), %rdi
callq 0x34460
testb $0x1, %al
jne 0x2b8b6
movq 0x130(%rsp), %rax
movq %rax, 0x60(%rsp)
cmpq $0x0, %rax
je 0x2b8a5
movq 0x60(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x140(%rsp)
jmp 0x2b971
jmp 0x2b8b8
movq 0x45719(%rip), %rax     # 0x70fd8
movq (%rax), %rax
movq %rax, 0x58(%rsp)
callq 0x8480
movq 0x58(%rsp), %rdi
movq %rax, %rdx
leaq 0x26ae1(%rip), %rsi     # 0x523bc
leaq 0x2770e(%rip), %rcx     # 0x52ff0
leaq 0x27713(%rip), %r8      # 0x52ffc
movl $0x30, %r9d
movb $0x0, %al
callq 0x86f0
movq 0x456db(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x27706(%rip), %rsi     # 0x5300d
movb $0x0, %al
callq 0x86f0
movq 0x456c3(%rip), %rax     # 0x70fd8
movq (%rax), %rdi
leaq 0x274a6(%rip), %rsi     # 0x52dc5
movb $0x0, %al
callq 0x86f0
movq 0x130(%rsp), %rdi
callq 0x2bbf0
movq 0x130(%rsp), %rax
movq 0x48(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x130(%rsp), %rdi
callq 0x2bc40
movq 0x130(%rsp), %rax
movb $0x1, 0xb8(%rax)
movq 0x130(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x140(%rsp), %rax
addq $0x148, %rsp            # imm = 0x148
retq
movq 0xd8(%rsp), %rdi
callq 0x8820
nop