// File: /workspace/github_cpp_makefile_star2_O3/yangwanyuan[P]HLKVDS/tools/DbTest.cc
// Function: Open_DB_Test(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Open_DB_Test(string filename) {

    Options opts;
    KVDS *db = KVDS::Open_KVDS(filename.c_str(), opts);

    //DB Insert 
    string test_key = "test-key";
    int test_key_size = 8;
    string test_value = "test-value";
    int test_value_size = 10;

    Status s = db->Insert(test_key.c_str(), test_key_size, test_value.c_str(),
                          test_value_size);
    if (!s.ok()) {
        std::cout << "Insert Failed" << std::endl;
    } else {
        std::cout << "Insert Success" << std::endl;
    }

    test_value = "test-value-new";
    test_value_size = 14;
    s = db->Insert(test_key.c_str(), test_key_size, test_value.c_str(),
                   test_value_size);
    if (!s.ok()) {
        std::cout << "Insert Failed" << std::endl;
    } else {
        std::cout << "Insert Success" << std::endl;
    }

    //DB Get
    string get_data;
    s = db->Get(test_key.c_str(), test_key_size, get_data);
    if (!s.ok()) {
        std::cout << "Get Failed" << std::endl;
    } else {
        std::cout << "Get Success: data is " << get_data << std::endl;
    }

    //DB Delete
    s = db->Delete(test_key.c_str(), test_key_size);
    if (!s.ok()) {
        std::cout << "Delete Failed" << std::endl;
    } else {
        std::cout << "Delete Success!" << std::endl;
    }

    ////DB Get
    //if (!db->Get(test_key.c_str(), test_key_size, get_data)){
    //  std::cout << "Get Failed" << std::endl;
    //}else{
    //  std::cout << "Get Success: data is " << get_data << std::endl; 
    //}

    WriteBatch batch;
    batch.put(test_key.c_str(), test_key_size, test_value.c_str(),
                test_value_size);

    string test_key2 = "test-key2";
    int test_key2_size = 9;
    string test_value2 = "test-value2";
    int test_value2_size = 11;
    batch.put(test_key2.c_str(), test_key2_size, test_value2.c_str(),
                test_value2_size);
    batch.put("keykeykey3",10,"value3",6);
    batch.put("keykeykey4",10,"value4",6);
    batch.put("keykeykey5",10,"value5",6);
    batch.put("keykeykey6",10,"value6",6);
    batch.put("keykeykey7",10,"value7",6);
    batch.put("keykeykey8",10,"value8",6);
    batch.put("keykeykey9",10,"value9",6);
    batch.del(test_key.c_str(), test_key_size);

    s = db->InsertBatch(&batch);
    if (!s.ok()) {
        std::cout << "Insert Batch Failed" << std::endl;
    }
    else {
        std::cout << "Insert Batch Success" << std::endl;
    }

    //DB Get
    //string get_data;
    s = db->Get(test_key.c_str(), test_key_size, get_data);
    if (!s.ok()) {
        std::cout << "Get Failed" << std::endl;
    } else {
        std::cout << "Get Success: data is " << get_data << std::endl;
    }
    s = db->Get(test_key2.c_str(), test_key2_size, get_data);
    if (!s.ok()) {
        std::cout << "Get Failed" << std::endl;
    } else {
        std::cout << "Get Success: data is " << get_data << std::endl;
    }

    Iterator* it = db->NewIterator();
    //test iterator if compile iterator
    if ( it != NULL) {
        cout << "Iterator the db: First to Last" << endl;
        for(it->SeekToFirst(); it->Valid(); it->Next()) {
            cout << it->Key() << ": " << it->Value() << endl;
        }
        sleep(3);
        cout << "Iterator the db: Last to First" << endl;
        for(it->SeekToLast(); it->Valid(); it->Prev()) {
            cout << it->Key() << ": " << it->Value() << endl;
        }
        delete it;
    }
    delete db;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, %rbx
leaq 0x168(%rsp), %r14
movq %r14, %rdi
callq 0x173dc
movq (%rbx), %rax
movl $0xa, %ecx
movq %rsp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
callq 0x13a56
movq %rax, %r12
leaq 0x130(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1852b(%rip), %rsi     # 0x22004
leaq 0x1852c(%rip), %rdx     # 0x2200c
leaq 0x120(%rsp), %rdi
callq 0xa862
leaq 0x150(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1850d(%rip), %rsi     # 0x2200d
leaq 0x18510(%rip), %rdx     # 0x22017
leaq 0x140(%rsp), %rdi
callq 0xa862
movq 0x120(%rsp), %rdx
movq 0x140(%rsp), %r8
movl $0x0, (%rsp)
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
movl $0x8, %ecx
movl $0xa, %r9d
callq 0x13f0e
xorl %edx, %edx
cmpl $0x0, 0x50(%rsp)
sete %dl
leaq 0x184d2(%rip), %r15     # 0x22026
leaq 0x184bd(%rip), %r14     # 0x22018
movq %r14, %rsi
cmoveq %r15, %rsi
addq $0xd, %rdx
movq 0x2a463(%rip), %rbx     # 0x33fd0
movq %rbx, %rdi
callq 0x6450
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq 0x2a43d(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62c0
leaq 0x140(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x18482(%rip), %rcx     # 0x22035
movl $0xe, %r8d
xorl %esi, %esi
callq 0x65d0
movq 0x120(%rsp), %rdx
movq 0x140(%rsp), %r8
movl $0x0, (%rsp)
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
movl $0x8, %ecx
movl $0xe, %r9d
callq 0x13f0e
movups 0xa8(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
xorl %edx, %edx
cmpl $0x0, 0x50(%rsp)
sete %dl
cmoveq %r15, %r14
addq $0xd, %rdx
movq 0x2a3b8(%rip), %rbx     # 0x33fd0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6450
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq 0x2a38f(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62c0
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x120(%rsp), %rdx
leaq 0x68(%rsp), %rdi
leaq 0xa8(%rsp), %r8
movq %r12, %rsi
movl $0x8, %ecx
callq 0x1407a
movups 0x68(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
cmpl $0x0, 0x50(%rsp)
je 0x9cc9
movq 0x2a331(%rip), %r14     # 0x33fd0
leaq 0x1839e(%rip), %rsi     # 0x22044
movl $0xa, %edx
movq %r14, %rdi
callq 0x6450
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6400
jmp 0x9d14
movq 0x2a300(%rip), %rdi     # 0x33fd0
leaq 0x18378(%rip), %rsi     # 0x2204f
movl $0x15, %edx
callq 0x6450
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x2a2d8(%rip), %rdi     # 0x33fd0
callq 0x6450
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq %r14, %rdi
callq 0x6050
movq %rax, %rdi
callq 0x62c0
movq 0x120(%rsp), %rdx
leaq 0x68(%rsp), %rdi
movq %r12, %rsi
movl $0x8, %ecx
callq 0x14056
movups 0x68(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x50(%rsp)
sete %al
leaq 0x18317(%rip), %rcx     # 0x22073
leaq 0x18302(%rip), %rsi     # 0x22065
cmoveq %rcx, %rsi
leaq 0xd(%rax,%rax), %rdx
movq 0x2a25d(%rip), %rbx     # 0x33fd0
movq %rbx, %rdi
callq 0x6450
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq 0x2a237(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62c0
leaq 0xc8(%rsp), %rdi
callq 0x20f08
movq 0x120(%rsp), %rsi
movq 0x140(%rsp), %rcx
leaq 0xc8(%rsp), %rdi
movl $0x8, %edx
movl $0xe, %r8d
callq 0x20f90
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x18298(%rip), %rsi     # 0x22083
leaq 0x1829a(%rip), %rdx     # 0x2208c
leaq 0x68(%rsp), %rdi
callq 0xa862
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1827e(%rip), %rsi     # 0x2208d
leaq 0x18282(%rip), %rdx     # 0x22098
leaq 0xe0(%rsp), %rdi
callq 0xa862
movq 0x68(%rsp), %rsi
movq 0xe0(%rsp), %rcx
leaq 0xc8(%rsp), %rdi
movl $0x9, %edx
movl $0xb, %r8d
callq 0x20f90
leaq 0x1824a(%rip), %rsi     # 0x22099
leaq 0x1824e(%rip), %rcx     # 0x220a4
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20f90
leaq 0x18236(%rip), %rsi     # 0x220ab
leaq 0x1823a(%rip), %rcx     # 0x220b6
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20f90
leaq 0x18222(%rip), %rsi     # 0x220bd
leaq 0x18226(%rip), %rcx     # 0x220c8
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20f90
leaq 0x1820e(%rip), %rsi     # 0x220cf
leaq 0x18212(%rip), %rcx     # 0x220da
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20f90
leaq 0x181fa(%rip), %rsi     # 0x220e1
leaq 0x181fe(%rip), %rcx     # 0x220ec
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20f90
leaq 0x181e6(%rip), %rsi     # 0x220f3
leaq 0x181ea(%rip), %rcx     # 0x220fe
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20f90
leaq 0x181d2(%rip), %rsi     # 0x22105
leaq 0x181d6(%rip), %rcx     # 0x22110
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20f90
movq 0x120(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
movl $0x8, %edx
callq 0x21010
leaq 0x88(%rsp), %rdi
leaq 0xc8(%rsp), %rdx
movq %r12, %rsi
callq 0x142e8
movups 0x88(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
xorl %edx, %edx
cmpl $0x0, 0x50(%rsp)
sete %dl
leaq 0x18189(%rip), %rax     # 0x2212b
leaq 0x1816e(%rip), %rsi     # 0x22117
cmoveq %rax, %rsi
addq $0x13, %rdx
movq 0x2a018(%rip), %rbx     # 0x33fd0
movq %rbx, %rdi
callq 0x6450
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq 0x29ff2(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62c0
movq 0x120(%rsp), %rdx
leaq 0x88(%rsp), %rdi
leaq 0xa8(%rsp), %r8
movq %r12, %rsi
movl $0x8, %ecx
callq 0x1407a
movups 0x88(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
cmpl $0x0, 0x50(%rsp)
je 0xa055
movq 0x29fa5(%rip), %r14     # 0x33fd0
leaq 0x18012(%rip), %rsi     # 0x22044
movl $0xa, %edx
movq %r14, %rdi
callq 0x6450
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6400
jmp 0xa0a0
movq 0x29f74(%rip), %rdi     # 0x33fd0
leaq 0x17fec(%rip), %rsi     # 0x2204f
movl $0x15, %edx
callq 0x6450
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x29f4c(%rip), %rdi     # 0x33fd0
callq 0x6450
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq %r14, %rdi
callq 0x6050
movq %rax, %rdi
callq 0x62c0
movq 0x68(%rsp), %rdx
leaq 0x88(%rsp), %rdi
leaq 0xa8(%rsp), %r8
movq %r12, %rsi
movl $0x9, %ecx
callq 0x1407a
movups 0x88(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
cmpl $0x0, 0x50(%rsp)
je 0xa11a
movq 0x29ee0(%rip), %r14     # 0x33fd0
leaq 0x17f4d(%rip), %rsi     # 0x22044
movl $0xa, %edx
movq %r14, %rdi
callq 0x6450
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6400
jmp 0xa165
movq 0x29eaf(%rip), %rdi     # 0x33fd0
leaq 0x17f27(%rip), %rsi     # 0x2204f
movl $0x15, %edx
callq 0x6450
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x29e87(%rip), %rdi     # 0x33fd0
callq 0x6450
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq %r14, %rdi
callq 0x6050
movq %rax, %rdi
callq 0x62c0
movq %r12, %rdi
callq 0x13a14
movq %rax, %r14
testq %rax, %rax
je 0xa439
movq 0x29e3d(%rip), %rbx     # 0x33fd0
leaq 0x17fa6(%rip), %rsi     # 0x22140
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x6450
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq 0x29e0b(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62c0
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq %r12, 0x160(%rsp)
leaq 0x88(%rsp), %r15
movq 0x29dde(%rip), %r12     # 0x33fd0
leaq 0x18948(%rip), %r13     # 0x22b41
leaq 0x100(%rsp), %rbp
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
testb %al, %al
je 0xa2d9
movq (%r14), %rax
movq %r15, %rdi
movq %r14, %rsi
callq *0x38(%rax)
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq %r12, %rdi
callq 0x6450
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x6450
movq (%r14), %rax
movq %rbp, %rdi
movq %r14, %rsi
callq *0x40(%rax)
movq 0x100(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq %rbx, %rdi
callq 0x6450
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6050
movq %rax, %rdi
callq 0x62c0
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0xa2b1
callq 0x63f0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xa2cb
callq 0x63f0
movq (%r14), %rax
movq %r14, %rdi
callq *0x28(%rax)
jmp 0xa201
movl $0x3, %edi
callq 0x6340
movq 0x29ce6(%rip), %rbx     # 0x33fd0
leaq 0x17e6e(%rip), %rsi     # 0x2215f
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x6450
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq 0x29cb4(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62c0
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
leaq 0x88(%rsp), %r15
movq 0x29c8f(%rip), %r12     # 0x33fd0
leaq 0x187f9(%rip), %r13     # 0x22b41
leaq 0x100(%rsp), %rbp
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
testb %al, %al
je 0xa428
movq (%r14), %rax
movq %r15, %rdi
movq %r14, %rsi
callq *0x38(%rax)
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq %r12, %rdi
callq 0x6450
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x6450
movq (%r14), %rax
movq %rbp, %rdi
movq %r14, %rsi
callq *0x40(%rax)
movq 0x100(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq %rbx, %rdi
callq 0x6450
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6400
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6050
movq %rax, %rdi
callq 0x62c0
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0xa400
callq 0x63f0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xa41a
callq 0x63f0
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
jmp 0xa350
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movq 0x160(%rsp), %r12
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0xa45d
callq 0x63f0
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xa471
callq 0x63f0
leaq 0xc8(%rsp), %rdi
callq 0x20f18
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xa498
callq 0x63f0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0xa4b2
callq 0x63f0
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0xa4cc
callq 0x63f0
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa532
jmp 0xa532
jmp 0xa532
movq %rax, %rbx
leaq 0x78(%rsp), %r14
jmp 0xa594
jmp 0xa4f3
movq %rax, %rbx
jmp 0xa5a3
jmp 0xa50f
jmp 0xa50f
jmp 0xa50f
jmp 0xa517
jmp 0xa517
movq %rax, %rbx
jmp 0xa5e4
jmp 0xa532
movq %rax, %rbx
jmp 0xa5b0
movq %rax, %rbx
jmp 0xa5ca
jmp 0xa52b
jmp 0xa532
jmp 0xa52b
jmp 0xa532
jmp 0xa532
jmp 0xa52b
movq %rax, %rbx
jmp 0xa55b
jmp 0xa532
movq %rax, %rbx
leaq 0x78(%rsp), %r14
jmp 0xa57a
jmp 0xa53e
movq %rax, %rbx
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0xa55b
callq 0x63f0
leaq 0x78(%rsp), %r14
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xa57a
callq 0x63f0
leaq 0xf0(%rsp), %rax
movq 0xe0(%rsp), %rdi
cmpq %rax, %rdi
je 0xa594
callq 0x63f0
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0xa5a3
callq 0x63f0
leaq 0xc8(%rsp), %rdi
callq 0x20f18
leaq 0xb8(%rsp), %rax
movq 0xa8(%rsp), %rdi
cmpq %rax, %rdi
je 0xa5ca
callq 0x63f0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0xa5e4
callq 0x63f0
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0xa5fe
callq 0x63f0
movq %rbx, %rdi
callq 0x6670