// File: /workspace/github_cpp_makefile_star2_O1/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 0x172ec
movq (%rbx), %rax
movl $0xa, %ecx
movq %rsp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
callq 0x13944
movq %rax, %r12
leaq 0x130(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x186ab(%rip), %rsi     # 0x22004
leaq 0x186ac(%rip), %rdx     # 0x2200c
leaq 0x120(%rsp), %rdi
callq 0xa6dc
leaq 0x150(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1868d(%rip), %rsi     # 0x2200d
leaq 0x18690(%rip), %rdx     # 0x22017
leaq 0x140(%rsp), %rdi
callq 0xa6dc
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 0x13dfa
xorl %edx, %edx
cmpl $0x0, 0x50(%rsp)
sete %dl
leaq 0x18652(%rip), %r15     # 0x22026
leaq 0x1863d(%rip), %r14     # 0x22018
movq %r14, %rsi
cmoveq %r15, %rsi
addq $0xd, %rdx
movq 0x2a5e3(%rip), %rbx     # 0x33fd0
movq %rbx, %rdi
callq 0x6460
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq 0x2a5bd(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62d0
leaq 0x140(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x18602(%rip), %rcx     # 0x22035
movl $0xe, %r8d
xorl %esi, %esi
callq 0x65e0
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 0x13dfa
movups 0xa8(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
xorl %edx, %edx
cmpl $0x0, 0x50(%rsp)
sete %dl
cmoveq %r15, %r14
addq $0xd, %rdx
movq 0x2a538(%rip), %rbx     # 0x33fd0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6460
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq 0x2a50f(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62d0
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 0x13f66
movups 0x68(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
cmpl $0x0, 0x50(%rsp)
je 0x9b49
movq 0x2a4b1(%rip), %r14     # 0x33fd0
leaq 0x1851e(%rip), %rsi     # 0x22044
movl $0xa, %edx
movq %r14, %rdi
callq 0x6460
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6410
jmp 0x9b94
movq 0x2a480(%rip), %rdi     # 0x33fd0
leaq 0x184f8(%rip), %rsi     # 0x2204f
movl $0x15, %edx
callq 0x6460
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x2a458(%rip), %rdi     # 0x33fd0
callq 0x6460
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq %r14, %rdi
callq 0x6050
movq %rax, %rdi
callq 0x62d0
movq 0x120(%rsp), %rdx
leaq 0x68(%rsp), %rdi
movq %r12, %rsi
movl $0x8, %ecx
callq 0x13f42
movups 0x68(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x50(%rsp)
sete %al
leaq 0x18497(%rip), %rcx     # 0x22073
leaq 0x18482(%rip), %rsi     # 0x22065
cmoveq %rcx, %rsi
leaq 0xd(%rax,%rax), %rdx
movq 0x2a3dd(%rip), %rbx     # 0x33fd0
movq %rbx, %rdi
callq 0x6460
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq 0x2a3b7(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62d0
leaq 0xc8(%rsp), %rdi
callq 0x20f60
movq 0x120(%rsp), %rsi
movq 0x140(%rsp), %rcx
leaq 0xc8(%rsp), %rdi
movl $0x8, %edx
movl $0xe, %r8d
callq 0x20fe8
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x18418(%rip), %rsi     # 0x22083
leaq 0x1841a(%rip), %rdx     # 0x2208c
leaq 0x68(%rsp), %rdi
callq 0xa6dc
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x183fe(%rip), %rsi     # 0x2208d
leaq 0x18402(%rip), %rdx     # 0x22098
leaq 0xe0(%rsp), %rdi
callq 0xa6dc
movq 0x68(%rsp), %rsi
movq 0xe0(%rsp), %rcx
leaq 0xc8(%rsp), %rdi
movl $0x9, %edx
movl $0xb, %r8d
callq 0x20fe8
leaq 0x183ca(%rip), %rsi     # 0x22099
leaq 0x183ce(%rip), %rcx     # 0x220a4
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20fe8
leaq 0x183b6(%rip), %rsi     # 0x220ab
leaq 0x183ba(%rip), %rcx     # 0x220b6
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20fe8
leaq 0x183a2(%rip), %rsi     # 0x220bd
leaq 0x183a6(%rip), %rcx     # 0x220c8
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20fe8
leaq 0x1838e(%rip), %rsi     # 0x220cf
leaq 0x18392(%rip), %rcx     # 0x220da
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20fe8
leaq 0x1837a(%rip), %rsi     # 0x220e1
leaq 0x1837e(%rip), %rcx     # 0x220ec
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20fe8
leaq 0x18366(%rip), %rsi     # 0x220f3
leaq 0x1836a(%rip), %rcx     # 0x220fe
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20fe8
leaq 0x18352(%rip), %rsi     # 0x22105
leaq 0x18356(%rip), %rcx     # 0x22110
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
movl $0x6, %r8d
callq 0x20fe8
movq 0x120(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
movl $0x8, %edx
callq 0x21068
leaq 0x88(%rsp), %rdi
leaq 0xc8(%rsp), %rdx
movq %r12, %rsi
callq 0x141d4
movups 0x88(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
xorl %edx, %edx
cmpl $0x0, 0x50(%rsp)
sete %dl
leaq 0x18309(%rip), %rax     # 0x2212b
leaq 0x182ee(%rip), %rsi     # 0x22117
cmoveq %rax, %rsi
addq $0x13, %rdx
movq 0x2a198(%rip), %rbx     # 0x33fd0
movq %rbx, %rdi
callq 0x6460
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq 0x2a172(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62d0
movq 0x120(%rsp), %rdx
leaq 0x88(%rsp), %rdi
leaq 0xa8(%rsp), %r8
movq %r12, %rsi
movl $0x8, %ecx
callq 0x13f66
movups 0x88(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
cmpl $0x0, 0x50(%rsp)
je 0x9ed5
movq 0x2a125(%rip), %r14     # 0x33fd0
leaq 0x18192(%rip), %rsi     # 0x22044
movl $0xa, %edx
movq %r14, %rdi
callq 0x6460
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6410
jmp 0x9f20
movq 0x2a0f4(%rip), %rdi     # 0x33fd0
leaq 0x1816c(%rip), %rsi     # 0x2204f
movl $0x15, %edx
callq 0x6460
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x2a0cc(%rip), %rdi     # 0x33fd0
callq 0x6460
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq %r14, %rdi
callq 0x6050
movq %rax, %rdi
callq 0x62d0
movq 0x68(%rsp), %rdx
leaq 0x88(%rsp), %rdi
leaq 0xa8(%rsp), %r8
movq %r12, %rsi
movl $0x9, %ecx
callq 0x13f66
movups 0x88(%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
cmpl $0x0, 0x50(%rsp)
je 0x9f9a
movq 0x2a060(%rip), %r14     # 0x33fd0
leaq 0x180cd(%rip), %rsi     # 0x22044
movl $0xa, %edx
movq %r14, %rdi
callq 0x6460
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6410
jmp 0x9fe5
movq 0x2a02f(%rip), %rdi     # 0x33fd0
leaq 0x180a7(%rip), %rsi     # 0x2204f
movl $0x15, %edx
callq 0x6460
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x2a007(%rip), %rdi     # 0x33fd0
callq 0x6460
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq %r14, %rdi
callq 0x6050
movq %rax, %rdi
callq 0x62d0
movq %r12, %rdi
callq 0x13902
movq %rax, %r14
testq %rax, %rax
je 0xa2b9
movq 0x29fbd(%rip), %rbx     # 0x33fd0
leaq 0x18126(%rip), %rsi     # 0x22140
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x6460
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq 0x29f8b(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62d0
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq %r12, 0x160(%rsp)
leaq 0x88(%rsp), %r15
movq 0x29f5e(%rip), %r12     # 0x33fd0
leaq 0x18ac8(%rip), %r13     # 0x22b41
leaq 0x100(%rsp), %rbp
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
testb %al, %al
je 0xa159
movq (%r14), %rax
movq %r15, %rdi
movq %r14, %rsi
callq *0x38(%rax)
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq %r12, %rdi
callq 0x6460
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x6460
movq (%r14), %rax
movq %rbp, %rdi
movq %r14, %rsi
callq *0x40(%rax)
movq 0x100(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq %rbx, %rdi
callq 0x6460
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6050
movq %rax, %rdi
callq 0x62d0
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0xa131
callq 0x6400
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xa14b
callq 0x6400
movq (%r14), %rax
movq %r14, %rdi
callq *0x28(%rax)
jmp 0xa081
movl $0x3, %edi
callq 0x6350
movq 0x29e66(%rip), %rbx     # 0x33fd0
leaq 0x17fee(%rip), %rsi     # 0x2215f
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x6460
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq 0x29e34(%rip), %rdi     # 0x33fd0
callq 0x6050
movq %rax, %rdi
callq 0x62d0
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
leaq 0x88(%rsp), %r15
movq 0x29e0f(%rip), %r12     # 0x33fd0
leaq 0x18979(%rip), %r13     # 0x22b41
leaq 0x100(%rsp), %rbp
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
testb %al, %al
je 0xa2a8
movq (%r14), %rax
movq %r15, %rdi
movq %r14, %rsi
callq *0x38(%rax)
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq %r12, %rdi
callq 0x6460
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x6460
movq (%r14), %rax
movq %rbp, %rdi
movq %r14, %rsi
callq *0x40(%rax)
movq 0x100(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq %rbx, %rdi
callq 0x6460
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6410
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6050
movq %rax, %rdi
callq 0x62d0
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0xa280
callq 0x6400
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xa29a
callq 0x6400
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
jmp 0xa1d0
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 0xa2dd
callq 0x6400
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0xa2f1
callq 0x6400
leaq 0xc8(%rsp), %rdi
callq 0x20f70
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xa318
callq 0x6400
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0xa332
callq 0x6400
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0xa34c
callq 0x6400
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa3b2
jmp 0xa3b2
jmp 0xa3b2
movq %rax, %rbx
leaq 0x78(%rsp), %r14
jmp 0xa414
jmp 0xa373
movq %rax, %rbx
jmp 0xa423
jmp 0xa38f
jmp 0xa38f
jmp 0xa38f
jmp 0xa397
jmp 0xa397
movq %rax, %rbx
jmp 0xa464
jmp 0xa3b2
movq %rax, %rbx
jmp 0xa430
movq %rax, %rbx
jmp 0xa44a
jmp 0xa3ab
jmp 0xa3b2
jmp 0xa3ab
jmp 0xa3b2
jmp 0xa3b2
jmp 0xa3ab
movq %rax, %rbx
jmp 0xa3db
jmp 0xa3b2
movq %rax, %rbx
leaq 0x78(%rsp), %r14
jmp 0xa3fa
jmp 0xa3be
movq %rax, %rbx
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0xa3db
callq 0x6400
leaq 0x78(%rsp), %r14
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xa3fa
callq 0x6400
leaq 0xf0(%rsp), %rax
movq 0xe0(%rsp), %rdi
cmpq %rax, %rdi
je 0xa414
callq 0x6400
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0xa423
callq 0x6400
leaq 0xc8(%rsp), %rdi
callq 0x20f70
leaq 0xb8(%rsp), %rax
movq 0xa8(%rsp), %rdi
cmpq %rax, %rdi
je 0xa44a
callq 0x6400
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0xa464
callq 0x6400
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0xa47e
callq 0x6400
movq %rbx, %rdi
callq 0x6680