// File: yangwanyuan[P]HLKVDS/tools/Benchmark.cc
// Function: Create_DB(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int, int, int)
int Create_DB(string filename, int db_size, int segment_K, int shards_num, int ds_type) {
    cout << "Start CreateDB, Please wait ..." << endl;
    int ht_size = db_size ;
    int segment_size = SEG_UNIT_SIZE * segment_K;

    Options opts;
    opts.hashtable_size = ht_size;
    opts.segment_size = segment_size;
    opts.shards_num = shards_num;
    opts.datastor_type = ds_type;

    KVTime tv_start;
    KVDS *db = KVDS::Create_KVDS(filename.c_str(), opts);

    KVTime tv_end;
    double diff_time = (tv_end - tv_start) / 1000000.0;

    cout << "Create DB use time: " << diff_time << "s" << endl;
    if (!db) {
        return -1;
    }
    delete db;
    return 0;
}

// Assembly:
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, 0x80(%rsp)
movq %rdi, 0x198(%rsp)
movl %esi, 0x194(%rsp)
movl %edx, 0x190(%rsp)
movl %ecx, 0x18c(%rsp)
movl %r8d, 0x188(%rsp)
movq 0x6f1d5(%rip), %rdi     # 0x77fd0
leaq 0x4e33e(%rip), %rsi     # 0x57140
callq 0x8520
movq %rax, %rdi
movq 0x6f18f(%rip), %rsi     # 0x77fa0
callq 0x8560
movl 0x194(%rsp), %eax
movl %eax, 0x184(%rsp)
movl 0x190(%rsp), %eax
shll $0xa, %eax
movl %eax, 0x180(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x3c2f0
movl 0x184(%rsp), %eax
movl %eax, 0x170(%rsp)
movl 0x180(%rsp), %eax
movl %eax, 0x174(%rsp)
movl 0x18c(%rsp), %eax
movl %eax, 0x148(%rsp)
movl 0x188(%rsp), %eax
movl %eax, 0x16c(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x555c0
movq 0x80(%rsp), %rdi
callq 0x8190
movq %rax, %rdi
movups 0x170(%rsp), %xmm0
movaps %xmm0, 0x100(%rsp)
movups 0x130(%rsp), %xmm0
movups 0x140(%rsp), %xmm1
movups 0x150(%rsp), %xmm2
movups 0x160(%rsp), %xmm3
movaps %xmm3, 0xf0(%rsp)
movaps %xmm2, 0xe0(%rsp)
movaps %xmm1, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps 0x100(%rsp), %xmm0
movq %rsp, %rax
movups %xmm0, 0x40(%rax)
movaps 0xc0(%rsp), %xmm0
movaps 0xd0(%rsp), %xmm1
movaps 0xe0(%rsp), %xmm2
movaps 0xf0(%rsp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x30d50
movq %rax, 0x88(%rsp)
jmp 0x8f34
movq 0x88(%rsp), %rax
movq %rax, 0x118(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x555c0
jmp 0x8f53
leaq 0xa0(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x55770
movq %rax, 0x78(%rsp)
jmp 0x8f6f
movq 0x78(%rsp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x4e087(%rip), %xmm1    # 0x57008
divsd %xmm1, %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x6f03b(%rip), %rdi     # 0x77fd0
leaq 0x4e1c4(%rip), %rsi     # 0x57160
callq 0x8520
movq %rax, 0x70(%rsp)
jmp 0x8fa8
movq 0x70(%rsp), %rdi
movsd 0x98(%rsp), %xmm0
callq 0x8940
movq %rax, 0x68(%rsp)
jmp 0x8fc2
movq 0x68(%rsp), %rdi
leaq 0x4e409(%rip), %rsi     # 0x573d7
callq 0x8520
movq %rax, 0x60(%rsp)
jmp 0x8fda
movq 0x60(%rsp), %rdi
movq 0x6efba(%rip), %rsi     # 0x77fa0
callq 0x8560
jmp 0x8fed
cmpq $0x0, 0x118(%rsp)
jne 0x904c
movl $0xffffffff, 0x1a4(%rsp) # imm = 0xFFFFFFFF
movl $0x1, 0x94(%rsp)
jmp 0x9080
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
jmp 0x90a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x557b0
jmp 0x90a9
movq 0x118(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpq $0x0, %rax
je 0x906a
movq 0x58(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movl $0x0, 0x1a4(%rsp)
movl $0x1, 0x94(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x557b0
leaq 0x120(%rsp), %rdi
callq 0x557b0
movl 0x1a4(%rsp), %eax
addq $0x1a8, %rsp            # imm = 0x1A8
retq
leaq 0x120(%rsp), %rdi
callq 0x557b0
movq 0xb8(%rsp), %rdi
callq 0x8880
nopw %cs:(%rax,%rax)