// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsp, %rbx
movq %rbx, %rdi
movl $0x4c4b40, %esi         # imm = 0x4C4B40
callq 0x1fda
xorl %ebp, %ebp
movq %rbx, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x2204
incl %ebp
cmpl $0x4c4b40, %ebp         # imm = 0x4C4B40
jne 0x3057
movl $0x4c4b3f, %ebx         # imm = 0x4C4B3F
movl $0x98967e, %ebp         # imm = 0x98967E
movq %rsp, %r14
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x2204
decl %ebx
addl $-0x2, %ebp
cmpl $-0x2, %ebp
jne 0x307a
xorl %ebp, %ebp
movl $0x98967e, %r14d        # imm = 0x98967E
movl $0x4c4b3f, %r13d        # imm = 0x4C4B3F
movq %rsp, %r15
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %r15, %rdi
movl %ebp, %esi
callq 0x2234
cmpl %eax, %ebx
jne 0x30f5
movq %r15, %rdi
movl %r14d, %esi
callq 0x2234
cmpl %eax, %r13d
jne 0x317c
cmpl $0x4c4b3f, %ebx         # imm = 0x4C4B3F
leal 0x1(%rbx), %eax
setae %r12b
addl $0x2, %ebp
addl $-0x2, %r14d
decl %r13d
movl %eax, %ebx
cmpl $0x4c4b40, %eax         # imm = 0x4C4B40
jne 0x30a6
movq %rsp, %rdi
callq 0x2040
jmp 0x321f
movq 0x3edc(%rip), %rdi      # 0x6fd8
leaq 0x1287(%rip), %rsi      # 0x438a
movl $0x29, %edx
callq 0x1130
movq 0x3ec4(%rip), %rdi      # 0x6fd8
movl %ebp, %esi
callq 0x11b0
movq %rax, %r14
leaq 0x11f6(%rip), %rsi      # 0x431b
movl $0xa, %edx
movq %rax, %rdi
callq 0x1130
movq %r14, %rdi
movl %ebx, %esi
callq 0x11b0
movq %rax, %rbx
leaq 0x11e0(%rip), %rsi      # 0x4326
movl $0xd, %edx
movq %rax, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0x4c4b40, %esi         # imm = 0x4C4B40
callq 0x11b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10f0
jmp 0x31fe
movq 0x3e55(%rip), %rdi      # 0x6fd8
leaq 0x1200(%rip), %rsi      # 0x438a
movl $0x29, %edx
callq 0x1130
movq 0x3e3d(%rip), %rdi      # 0x6fd8
movl %ebp, %esi
callq 0x11b0
movq %rax, %r14
leaq 0x116f(%rip), %rsi      # 0x431b
movl $0xa, %edx
movq %rax, %rdi
callq 0x1130
movq %r14, %rdi
movl %ebx, %esi
callq 0x11b0
movq %rax, %rbx
leaq 0x1159(%rip), %rsi      # 0x4326
movl $0xd, %edx
movq %rax, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0x4c4b40, %esi         # imm = 0x4C4B40
callq 0x11b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq %rsp, %rdi
callq 0x2040
testb $0x1, %r12b
je 0x3261
movq 0x3db2(%rip), %rbx      # 0x6fd8
leaq 0x1187(%rip), %rsi      # 0x43b4
movl $0x15, %edx
movq %rbx, %rdi
callq 0x1130
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3276
jmp 0x3276
jmp 0x3276
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x11c0