// File: 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
movq %rsp, %rbp
subq $0xb0, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x1, -0x4(%rbp)
jge 0x5e35
movl $0x4c4b40, -0x8(%rbp)   # imm = 0x4C4B40
movl -0x8(%rbp), %esi
leaq -0x20(%rbp), %rdi
callq 0x2310
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x5c15
movl -0x24(%rbp), %edx
leaq -0x20(%rbp), %rdi
movl %edx, %esi
callq 0x2aa0
jmp 0x5bee
jmp 0x5bf0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5bd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x2390
jmp 0x5e60
movl -0x8(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jl 0x5c43
movl -0x38(%rbp), %esi
movl %esi, %edx
addl %edx, %edx
leaq -0x20(%rbp), %rdi
callq 0x2aa0
jmp 0x5c36
jmp 0x5c38
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x5c1e
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x5e0a
movl -0x3c(%rbp), %esi
addl %esi, %esi
leaq -0x20(%rbp), %rdi
callq 0x2af0
movl %eax, -0x44(%rbp)
jmp 0x5c69
movl -0x44(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x5d10
movq 0x435c(%rip), %rdi      # 0x9fd8
leaq 0x16b7(%rip), %rsi      # 0x733a
callq 0x10d0
movq %rax, -0x50(%rbp)
jmp 0x5c8e
movq -0x50(%rbp), %rdi
movl -0x3c(%rbp), %esi
addl %esi, %esi
callq 0x1180
movq %rax, -0x58(%rbp)
jmp 0x5ca2
movq -0x58(%rbp), %rdi
leaq 0x161e(%rip), %rsi      # 0x72cb
callq 0x10d0
movq %rax, -0x60(%rbp)
jmp 0x5cb8
movq -0x60(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x1180
movq %rax, -0x68(%rbp)
jmp 0x5cca
movq -0x68(%rbp), %rdi
leaq 0x1601(%rip), %rsi      # 0x72d6
callq 0x10d0
movq %rax, -0x70(%rbp)
jmp 0x5ce0
movq -0x70(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x1180
movq %rax, -0x78(%rbp)
jmp 0x5cf2
movq -0x78(%rbp), %rdi
movq 0x42cb(%rip), %rsi      # 0x9fc8
callq 0x1110
jmp 0x5d04
movl $0x1, -0x40(%rbp)
jmp 0x5e11
movl -0x8(%rbp), %eax
movl -0x3c(%rbp), %esi
notl %esi
addl %eax, %esi
addl %esi, %esi
leaq -0x20(%rbp), %rdi
callq 0x2af0
movl %eax, -0x7c(%rbp)
jmp 0x5d2a
movl -0x7c(%rbp), %eax
movl -0x8(%rbp), %ecx
subl -0x3c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x5dfa
movq 0x4293(%rip), %rdi      # 0x9fd8
leaq 0x15ee(%rip), %rsi      # 0x733a
callq 0x10d0
movq %rax, -0x88(%rbp)
jmp 0x5d5a
movq -0x88(%rbp), %rdi
movl -0x3c(%rbp), %esi
addl %esi, %esi
callq 0x1180
movq %rax, -0x90(%rbp)
jmp 0x5d74
movq -0x90(%rbp), %rdi
leaq 0x1549(%rip), %rsi      # 0x72cb
callq 0x10d0
movq %rax, -0x98(%rbp)
jmp 0x5d90
movq -0x98(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x1180
movq %rax, -0xa0(%rbp)
jmp 0x5da8
movq -0xa0(%rbp), %rdi
leaq 0x1520(%rip), %rsi      # 0x72d6
callq 0x10d0
movq %rax, -0xa8(%rbp)
jmp 0x5dc4
movq -0xa8(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x1180
movq %rax, -0xb0(%rbp)
jmp 0x5ddc
movq -0xb0(%rbp), %rdi
movq 0x41de(%rip), %rsi      # 0x9fc8
callq 0x1110
jmp 0x5df1
movl $0x1, -0x40(%rbp)
jmp 0x5e11
jmp 0x5dfc
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x5c4a
movl $0x0, -0x40(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x2390
movl -0x40(%rbp), %eax
testl %eax, %eax
je 0x5e25
jmp 0x5e23
jmp 0x5e57
jmp 0x5e27
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x5bb2
movq 0x419c(%rip), %rdi      # 0x9fd8
leaq 0x1521(%rip), %rsi      # 0x7364
callq 0x10d0
movq %rax, %rdi
movq 0x4176(%rip), %rsi      # 0x9fc8
callq 0x1110
addq $0xb0, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x1190
nopl (%rax)