// File: /workspace/github_cpp_makefile_star2_O2/dvjdjvu[P]bntree/./src/test.cpp
// Function: main
int main()
{
    uint64_t progress = 0;
    uint64_t percent = 0;
    time_point<system_clock> time;
    nanoseconds total_time(0);
    
    write_sequence write =  get_sequence<write_sequence>("./test/write.txt");
    modify_sequence modify =  get_sequence<modify_sequence>("./test/modify.txt");
    read_sequence read = get_sequence<read_sequence>("./test/read.txt");

    bntree st;
    //cout << "count: " << write.size() << endl;
    
    progress = 0;
    percent = write.size() / 100;
    
    for (const string &item : write)
    {
        time = system_clock::now();
        total_time += system_clock::now() - time;
        
        st.insert(item);
        
        if (++progress % (10 * percent) == 0)
        {
            cout << "time: " << duration_cast<milliseconds>(total_time).count()
                 << "ms progress: " << progress << " / " << write.size() << "\n";
        }
    }
    
    cout << "insert have done" << endl;
    
    cout << "\ncount: " << st.size() << " add end" << endl;
    //st.print();
    //return -1;
    
    progress = 0;
    percent = modify.size() / 100;

    modify_sequence::const_iterator mitr = modify.begin();
    read_sequence::const_iterator ritr = read.begin();
    
    for (int i = 0; mitr != modify.end() && ritr != read.end(); ++mitr, ++ritr, i++)
    {
        time = system_clock::now();

        st.erase(mitr->first);
        st.insert(mitr->second);
        
        data_t *d = st.get(ritr->first);
        
        total_time += system_clock::now() - time;
        if (ritr->second != d->key)
        {
            cout << "test failed " << i << endl;
            return 1;
        }

        if (++progress % (10 * percent) == 0)
        {
            cout << "time: " << duration_cast<milliseconds>(total_time).count()
                 << "ms progress: " << progress << " / " << modify.size() << "\n";
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
leaq 0x11c0(%rip), %rsi      # 0x4011
leaq 0x18(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x2080
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x335b
leaq 0x18(%rsp), %rdi
callq 0x20b0
leaq 0x11a2(%rip), %rsi      # 0x4022
leaq 0x18(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x2080
leaq 0x40(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x340c
leaq 0x18(%rsp), %rdi
callq 0x20b0
leaq 0x1185(%rip), %rsi      # 0x4034
leaq 0x18(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x2080
leaq 0x70(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x340c
leaq 0x18(%rsp), %rdi
callq 0x20b0
leaq 0x18(%rsp), %rdi
callq 0x236c
movq 0x58(%rsp), %r14
movq 0x60(%rsp), %rax
movq %rax, 0x8(%rsp)
subq %r14, %rax
sarq $0x5, %rax
movq $0x0, 0x10(%rsp)
pushq $0x64
popq %rcx
xorl %edx, %edx
divq %rcx
imulq $0xa, %rax, %rax
movq %rax, 0x38(%rsp)
pushq $0x1
popq %r15
leaq 0xe8(%rsp), %r12
leaq 0xc8(%rsp), %rbp
cmpq 0x8(%rsp), %r14
je 0x301d
callq 0x2040
movq %rax, %r13
callq 0x2040
movq %rax, %rbx
movq %r12, %rdi
movq %r14, %rsi
callq 0x21c0
movq %rbp, %rdi
leaq 0x10b2(%rip), %rsi      # 0x4007
leaq 0x7(%rsp), %rdx
callq 0x2080
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x250a
subq %r13, %rbx
addq %rbx, 0x10(%rsp)
movq %rbp, %rdi
callq 0x20b0
movq %r12, %rdi
callq 0x20b0
movq %r15, %rax
xorl %edx, %edx
divq 0x38(%rsp)
testq %rdx, %rdx
jne 0x3011
movq 0x303b(%rip), %rdi      # 0x5fd8
leaq 0x10a0(%rip), %rsi      # 0x4044
callq 0x2170
movq %rax, %rdi
movq 0x10(%rsp), %rax
cqto
movl $0xf4240, %ecx          # imm = 0xF4240
idivq %rcx
movq %rax, %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x107e(%rip), %rsi      # 0x404b
callq 0x2170
movq %rax, %rdi
movq %r15, %rsi
callq 0x2100
movq %rax, %rdi
leaq 0x1072(%rip), %rsi      # 0x4059
callq 0x2170
movq 0x60(%rsp), %rsi
subq 0x58(%rsp), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x2100
movq %rax, %rdi
leaq 0xffa(%rip), %rsi       # 0x4006
callq 0x2170
addq $0x20, %r14
incq %r15
jmp 0x2f25
movq 0x2fb4(%rip), %rdi      # 0x5fd8
leaq 0x1032(%rip), %rsi      # 0x405d
callq 0x2170
movq %rax, %rdi
callq 0x20c0
movq 0x2f99(%rip), %rdi      # 0x5fd8
leaq 0x1028(%rip), %rsi      # 0x406e
callq 0x2170
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x2988
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2100
leaq 0x100d(%rip), %rsi      # 0x4077
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20c0
movq 0x40(%rsp), %r15
movq 0x48(%rsp), %rcx
movq %rcx, %rax
subq %r15, %rax
pushq $0x28
popq %rsi
cqto
idivq %rsi
xorl %edx, %edx
pushq $0x64
popq %rsi
divq %rsi
movq 0x70(%rsp), %r13
imulq $0xa, %rax, %rax
movq %rax, 0x38(%rsp)
pushq $0x1
popq %rbp
leaq 0x18(%rsp), %rbx
cmpq %rcx, %r15
je 0x321c
cmpq 0x78(%rsp), %r13
je 0x321c
callq 0x2040
movq %rax, %r14
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x2840
addq $0x8, %r15
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0x21c0
leaq 0xa8(%rsp), %r12
movq %r12, %rdi
leaq 0xf0a(%rip), %rsi       # 0x4007
leaq 0x7(%rsp), %rdx
callq 0x2080
movq %rbp, 0x8(%rsp)
movq %rbx, %rdi
leaq 0x88(%rsp), %rbp
movq %rbp, %rsi
movq %r12, %rdx
callq 0x250a
movq %r12, %rdi
callq 0x20b0
movq %rbp, %rdi
callq 0x20b0
movq (%r13), %rsi
movq %rbx, %rdi
callq 0x2ade
movq %rax, %rbp
callq 0x2040
movq %rax, %rbx
addq $0x8, %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x34c9
testb %al, %al
jne 0x3220
subq %r14, %rbx
addq %rbx, 0x10(%rsp)
movq 0x8(%rsp), %rbp
movq %rbp, %rax
xorl %edx, %edx
divq 0x38(%rsp)
testq %rdx, %rdx
jne 0x3207
movq 0x2e51(%rip), %rdi      # 0x5fd8
leaq 0xeb6(%rip), %rsi       # 0x4044
callq 0x2170
movq %rax, %rdi
movq 0x10(%rsp), %rax
cqto
movl $0xf4240, %ecx          # imm = 0xF4240
idivq %rcx
movq %rax, %rsi
callq 0x2160
movq 0x8(%rsp), %rbp
movq %rax, %rdi
leaq 0xe8f(%rip), %rsi       # 0x404b
callq 0x2170
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2100
movq %rax, %rdi
leaq 0xe83(%rip), %rsi       # 0x4059
callq 0x2170
movq %rax, %rdi
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
movq %rax, %rsi
callq 0x2100
movq %rax, %rdi
leaq 0xe04(%rip), %rsi       # 0x4006
callq 0x2170
movq 0x48(%rsp), %rcx
incq %rbp
addq $0x20, %r15
addq $0x20, %r13
jmp 0x30ab
xorl %ebx, %ebx
jmp 0x324d
movq 0x2db1(%rip), %rdi      # 0x5fd8
leaq 0xe52(%rip), %rsi       # 0x4080
callq 0x2170
movq 0x8(%rsp), %rsi
decl %esi
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x20c0
pushq $0x1
popq %rbx
leaq 0x18(%rsp), %rdi
callq 0x2382
leaq 0x70(%rsp), %rdi
callq 0x34d4
leaq 0x40(%rsp), %rdi
callq 0x34d4
leaq 0x58(%rsp), %rdi
callq 0x34f6
movl %ebx, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3335
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x20b0
jmp 0x333f
movq %rax, %rbx
jmp 0x333f
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x20b0
jmp 0x3349
movq %rax, %rbx
jmp 0x3349
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x20b0
jmp 0x3353
movq %rax, %rbx
jmp 0x3353
jmp 0x3328
jmp 0x3328
movq %rax, %rbx
jmp 0x32f2
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x20b0
leaq 0x88(%rsp), %rdi
jmp 0x331b
jmp 0x3328
movq %rax, %rbx
jmp 0x3313
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x20b0
leaq 0xe8(%rsp), %rdi
callq 0x20b0
jmp 0x332b
jmp 0x3328
jmp 0x3328
jmp 0x3328
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x2382
leaq 0x70(%rsp), %rdi
callq 0x34d4
leaq 0x40(%rsp), %rdi
callq 0x34d4
leaq 0x58(%rsp), %rdi
callq 0x34f6
movq %rbx, %rdi
callq 0x2200