// File: /workspace/github_cpp_makefile_star2_O2/6851-2021[P]Cache-Oblivious-Data-Structures/static_search_trees/test_ca_sst.cpp
// Function: test_get_update_5()
void test_get_update_5() {
    // -- This is a bit of stress test
    // Test update all elements.
    // make value = key^2. Do multiple passes with random tree sizes.
    for (int i = 0; i < 1; i++) {
        // limit size to the range [0...10000]
        // no point in doing more.
        int t_size = 5000000;
        CA_static_search_tree tree(t_size);
        for (int j = 0; j < t_size; j++) {
            tree.update(j, j);
        }
        // now update them again but in BACKWARDS order.
        for (int j = t_size - 1; j >= 0; j--) {
            tree.update(j, 2*j);
        }
        // for (int j = 0; j < t_size; j++) {
        //     if (tree.get(2*j) != j) {
        //         cout << "test_get_update_5 failed: expected value " << j*j << " at index " << j << ", tree size: " << t_size << endl;
        //         return;
        //     }
        // }
        for (int j = 0; j < t_size; j++) {
            if (tree.get(2*j) != j) {
                cout << "test_get_update_5 failed: expected value " << 2*j << " at index " << j << ", tree size: " << t_size << endl;
                return;
            }
            if (tree.get(2*(t_size-j-1)) != (t_size-j-1)) {
                cout << "test_get_update_5 failed: expected value " << 2*j << " at index " << j << ", tree size: " << t_size << endl;
                return;
            }
        }
    }
    cout << "test_get_update_5: OK" << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x4c4b40, %esi         # imm = 0x4C4B40
callq 0x1cd2
xorl %ebp, %ebp
cmpl $0x4c4b40, %ebp         # imm = 0x4C4B40
je 0x2c7a
movq %rbx, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x1ece
incl %ebp
jmp 0x2c62
movl $0x4c4b3f, %ebx         # imm = 0x4C4B3F
movl $0x98967e, %ebp         # imm = 0x98967E
leaq 0x8(%rsp), %r14
testl %ebx, %ebx
js 0x2ca0
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x1ece
decl %ebx
addl $-0x2, %ebp
jmp 0x2c89
movl $0x98967e, %r14d        # imm = 0x98967E
movl $0x4c4b3f, %r12d        # imm = 0x4C4B3F
xorl %ebp, %ebp
leaq 0x8(%rsp), %r15
xorl %ebx, %ebx
cmpl $0x4c4b40, %ebx         # imm = 0x4C4B40
je 0x2d53
movq %r15, %rdi
movl %ebp, %esi
callq 0x1efc
cmpl %eax, %ebx
jne 0x2ced
movq %r15, %rdi
movl %r14d, %esi
callq 0x1efc
cmpl %eax, %r12d
jne 0x2ced
incl %ebx
addl $-0x2, %r14d
decl %r12d
addl $0x2, %ebp
jmp 0x2cb5
movq 0x32e4(%rip), %rdi      # 0x5fd8
leaq 0x68f(%rip), %rsi       # 0x338a
callq 0x10f0
movq %rax, %rdi
movl %ebp, %esi
callq 0x11a0
leaq 0x60a(%rip), %rsi       # 0x331b
movq %rax, %rdi
callq 0x10f0
movq %rax, %rdi
movl %ebx, %esi
callq 0x11a0
leaq 0x5fc(%rip), %rsi       # 0x3326
movq %rax, %rdi
callq 0x10f0
movq %rax, %rdi
movl $0x4c4b40, %esi         # imm = 0x4C4B40
callq 0x11a0
movq %rax, %rdi
callq 0x1090
leaq 0x8(%rsp), %rdi
callq 0x1d12
jmp 0x2d78
leaq 0x8(%rsp), %rdi
callq 0x1d12
movq 0x3274(%rip), %rdi      # 0x5fd8
leaq 0x649(%rip), %rsi       # 0x33b4
callq 0x10f0
movq %rax, %rdi
callq 0x1090
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2d8b
jmp 0x2d8b
jmp 0x2d8b
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x1d12
movq %rbx, %rdi
callq 0x11b0