// File: rocket323[P]fishdb/tests/test_main.cpp
// Function: test_btree_simple()
MU_TEST(test_btree_simple)
{
    bt = BTree::Open("test2.fdb");
    if (bt == NULL)
    {
        printf("open test2.fdb failed\n");
        return;
    }
    srand(time(NULL));

    int N = 50;
    char big_data[6 * 1025];
    for (int i = 0; i < N; ++i)
    {
        int keyNum = rand() % 10000;
        int valNum = rand() % 10000;
        std::ostringstream key_oss;
        std::ostringstream val_oss;
        key_oss << "key" << keyNum;
        val_oss << "val" << valNum;
        std::string key = key_oss.str();
        std::string val(big_data, sizeof(big_data));
        if (i < N / 2)
            val = val_oss.str();

        std::string v;
        bt->Put(key, val);
        int ret = bt->Get(key, v);
        mu_check(ret == 0);
        mu_check(val == v);
    }

    auto iter = bt->NewIterator();
    printf("iterating...\n");
    for (iter->SeekToFirst(); iter->Valid(); iter->Next())
    {
        std::cout << iter->Key() << std::endl;
    }
    delete iter;
    bt->Close();
    delete bt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c90, %rsp           # imm = 0x1C90
leaq -0x21(%rbp), %rdi
movq %rdi, -0x1c30(%rbp)
callq 0x3440
movq -0x1c30(%rbp), %rdx
leaq 0x114d9(%rip), %rsi     # 0x150a2
leaq -0x20(%rbp), %rdi
callq 0x3350
jmp 0x3bd4
leaq -0x58(%rbp), %rdi
movq %rdi, -0x1c40(%rbp)
leaq -0x59(%rbp), %rsi
callq 0x4c60
movq -0x1c40(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movl $0x2, %edx
callq 0x8a00
movq %rax, -0x1c38(%rbp)
jmp 0x3c06
movq -0x1c38(%rbp), %rax
movq %rax, 0x1a674(%rip)     # 0x1e288
leaq -0x58(%rbp), %rdi
callq 0x4cf0
leaq -0x20(%rbp), %rdi
callq 0x3160
leaq -0x21(%rbp), %rdi
callq 0x32b0
cmpq $0x0, 0x1a651(%rip)     # 0x1e288
jne 0x3c86
leaq 0x1146c(%rip), %rdi     # 0x150ac
movb $0x0, %al
callq 0x3050
jmp 0x41ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3c78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4cf0
leaq -0x20(%rbp), %rdi
callq 0x3160
leaq -0x21(%rbp), %rdi
callq 0x32b0
jmp 0x41d3
xorl %eax, %eax
movl %eax, %edi
callq 0x3210
movl %eax, %edi
callq 0x3230
movl $0x32, -0x60(%rbp)
movl $0x0, -0x1874(%rbp)
movl -0x1874(%rbp), %eax
cmpl -0x60(%rbp), %eax
jge 0x40a8
callq 0x3090
movslq %eax, %rcx
imulq $0x68db8bad, %rcx, %rcx # imm = 0x68DB8BAD
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x2c, %rcx
addl %edx, %ecx
imull $0x2710, %ecx, %ecx     # imm = 0x2710
subl %ecx, %eax
movl %eax, -0x1878(%rbp)
callq 0x3090
movslq %eax, %rcx
imulq $0x68db8bad, %rcx, %rcx # imm = 0x68DB8BAD
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x2c, %rcx
addl %edx, %ecx
imull $0x2710, %ecx, %ecx     # imm = 0x2710
subl %ecx, %eax
movl %eax, -0x187c(%rbp)
leaq -0x19f8(%rbp), %rdi
callq 0x3340
leaq -0x1b70(%rbp), %rdi
callq 0x3340
jmp 0x3d24
leaq 0x11398(%rip), %rsi     # 0x150c3
leaq -0x19f8(%rbp), %rdi
callq 0x3240
movq %rax, -0x1c48(%rbp)
jmp 0x3d40
movq -0x1c48(%rbp), %rdi
movl -0x1878(%rbp), %esi
callq 0x3420
jmp 0x3d54
leaq 0x1136c(%rip), %rsi     # 0x150c7
leaq -0x1b70(%rbp), %rdi
callq 0x3240
movq %rax, -0x1c50(%rbp)
jmp 0x3d70
movq -0x1c50(%rbp), %rdi
movl -0x187c(%rbp), %esi
callq 0x3420
jmp 0x3d84
leaq -0x1b90(%rbp), %rdi
leaq -0x19f8(%rbp), %rsi
callq 0x3270
jmp 0x3d99
leaq -0x1bb1(%rbp), %rdi
movq %rdi, -0x1c58(%rbp)
callq 0x3440
movq -0x1c58(%rbp), %rcx
leaq -0x1bb0(%rbp), %rdi
leaq -0x1870(%rbp), %rsi
movl $0x1806, %edx           # imm = 0x1806
callq 0x32d0
jmp 0x3dcd
leaq -0x1bb1(%rbp), %rdi
callq 0x32b0
movl -0x1874(%rbp), %eax
movl %eax, -0x1c5c(%rbp)
movl -0x60(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x1c5c(%rbp), %eax
cmpl %ecx, %eax
jge 0x3e86
leaq -0x1bd8(%rbp), %rdi
leaq -0x1b70(%rbp), %rsi
callq 0x3270
jmp 0x3e15
leaq -0x1bb0(%rbp), %rdi
leaq -0x1bd8(%rbp), %rsi
callq 0x3310
leaq -0x1bd8(%rbp), %rdi
callq 0x3160
jmp 0x3e86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x4097
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x408b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1bb1(%rbp), %rdi
callq 0x32b0
jmp 0x407f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x4073
leaq -0x1bf8(%rbp), %rdi
callq 0x3370
movq 0x1a3ef(%rip), %rdi     # 0x1e288
leaq -0x1b90(%rbp), %rsi
leaq -0x1bb0(%rbp), %rdx
callq 0x9260
jmp 0x3eae
movq 0x1a3d3(%rip), %rdi     # 0x1e288
leaq -0x1b90(%rbp), %rsi
leaq -0x1bf8(%rbp), %rdx
callq 0x8f80
movl %eax, -0x1c60(%rbp)
jmp 0x3ed0
movl -0x1c60(%rbp), %eax
movl %eax, -0x1bfc(%rbp)
movl 0x1a3c2(%rip), %eax     # 0x1e2a4
addl $0x1, %eax
movl %eax, 0x1a3b9(%rip)     # 0x1e2a4
cmpl $0x0, -0x1bfc(%rbp)
je 0x3f63
leaq 0x1a3d5(%rip), %rdi     # 0x1e2d0
movl $0x400, %esi            # imm = 0x400
leaq 0x111c4(%rip), %rdx     # 0x150cb
leaq 0x111d3(%rip), %rcx     # 0x150e1
leaq 0x111de(%rip), %r8      # 0x150f3
movl $0x73, %r9d
leaq 0x111e5(%rip), %rax     # 0x15107
movq %rax, (%rsp)
movb $0x0, %al
callq 0x33d0
movl $0x1, 0x1a389(%rip)     # 0x1e2c0
movl $0x1, -0x1c00(%rbp)
jmp 0x4010
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1bf8(%rbp), %rdi
callq 0x3160
jmp 0x4073
leaq 0x111a6(%rip), %rdi     # 0x15110
xorl %eax, %eax
callq 0x3050
jmp 0x3f73
jmp 0x3f75
jmp 0x3f77
jmp 0x3f79
jmp 0x3f7b
movl 0x1a323(%rip), %eax     # 0x1e2a4
addl $0x1, %eax
movl %eax, 0x1a31a(%rip)     # 0x1e2a4
leaq -0x1bb0(%rbp), %rdi
leaq -0x1bf8(%rbp), %rsi
callq 0x4d10
testb $0x1, %al
jne 0x3ff0
leaq 0x1a328(%rip), %rdi     # 0x1e2d0
movl $0x400, %esi            # imm = 0x400
leaq 0x11117(%rip), %rdx     # 0x150cb
leaq 0x11126(%rip), %rcx     # 0x150e1
leaq 0x11131(%rip), %r8      # 0x150f3
movl $0x74, %r9d
leaq 0x11143(%rip), %rax     # 0x15112
movq %rax, (%rsp)
movb $0x0, %al
callq 0x33d0
movl $0x1, 0x1a2dc(%rip)     # 0x1e2c0
movl $0x1, -0x1c00(%rbp)
jmp 0x4010
leaq 0x11119(%rip), %rdi     # 0x15110
xorl %eax, %eax
callq 0x3050
jmp 0x4000
jmp 0x4002
jmp 0x4004
jmp 0x4006
movl $0x0, -0x1c00(%rbp)
leaq -0x1bf8(%rbp), %rdi
callq 0x3160
leaq -0x1bb0(%rbp), %rdi
callq 0x3160
leaq -0x1b90(%rbp), %rdi
callq 0x3160
leaq -0x1b70(%rbp), %rdi
callq 0x3080
leaq -0x19f8(%rbp), %rdi
callq 0x3080
movl -0x1c00(%rbp), %eax
testl %eax, %eax
je 0x405d
jmp 0x4058
jmp 0x41ca
jmp 0x405f
movl -0x1874(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1874(%rbp)
jmp 0x3ca7
leaq -0x1bb0(%rbp), %rdi
callq 0x3160
leaq -0x1b90(%rbp), %rdi
callq 0x3160
leaq -0x1b70(%rbp), %rdi
callq 0x3080
leaq -0x19f8(%rbp), %rdi
callq 0x3080
jmp 0x41d3
movq 0x1a1d9(%rip), %rdi     # 0x1e288
callq 0x8b80
movq %rax, -0x1c08(%rbp)
leaq 0x11059(%rip), %rdi     # 0x1511b
movb $0x0, %al
callq 0x3050
movq -0x1c08(%rbp), %rdi
callq 0x7160
movq -0x1c08(%rbp), %rdi
callq 0x7b00
testb $0x1, %al
jne 0x40e7
jmp 0x4166
movq -0x1c08(%rbp), %rsi
leaq -0x1c28(%rbp), %rdi
movq %rdi, -0x1c70(%rbp)
callq 0x7b20
movq -0x1c70(%rbp), %rsi
movq 0x19ec9(%rip), %rdi     # 0x1dfd8
callq 0x31f0
movq %rax, -0x1c68(%rbp)
jmp 0x411d
movq -0x1c68(%rbp), %rdi
movq 0x19e95(%rip), %rsi     # 0x1dfc0
callq 0x3290
jmp 0x4132
leaq -0x1c28(%rbp), %rdi
callq 0x3160
movq -0x1c08(%rbp), %rdi
callq 0x76e0
jmp 0x40d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1c28(%rbp), %rdi
callq 0x3160
jmp 0x41d3
movq -0x1c08(%rbp), %rax
movq %rax, -0x1c78(%rbp)
cmpq $0x0, %rax
je 0x4192
movq -0x1c78(%rbp), %rdi
callq 0x4da0
movq -0x1c78(%rbp), %rdi
callq 0x3220
movq 0x1a0ef(%rip), %rdi     # 0x1e288
callq 0x8b60
movq 0x1a0e3(%rip), %rax     # 0x1e288
movq %rax, -0x1c80(%rbp)
cmpq $0x0, %rax
je 0x41ca
movq -0x1c80(%rbp), %rdi
callq 0x4dc0
movq -0x1c80(%rbp), %rdi
callq 0x3220
addq $0x1c90, %rsp           # imm = 0x1C90
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x3430
nopl (%rax)