// 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_4()
void test_get_update_4() {
    // -- 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 < 100; i++) {
        // limit size to the range [0...10000]
        // no point in doing more.
        int t_size = 1 + rand() % 10000;
        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, j*j);
        }
        for (int j = 0; j < t_size; j++) {
            if (tree.get(j * j) != j) {
                cout << "test_get_update_4 failed: expected value " << j*j << " at index " << j << ", tree size: " << t_size << endl;
                return;
            }
        }
    }
    cout << "test_get_update_4: OK" << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %r12d, %r12d
leaq 0x10(%rsp), %r14
xorl %r13d, %r13d
callq 0x1060
cltq
imulq $0x68db8bad, %rax, %rcx # imm = 0x68DB8BAD
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x2c, %rcx
addl %edx, %ecx
imull $0x2710, %ecx, %ecx     # imm = 0x2710
movl %eax, %ebp
subl %ecx, %ebp
negl %ecx
leal (%rax,%rcx), %esi
incl %esi
movq %r14, %rdi
movl %esi, 0x4(%rsp)
callq 0x1fda
testl %ebp, %ebp
js 0x2e8f
leal 0x1(%rbp), %ebx
xorl %r15d, %r15d
movq %r14, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x2204
incl %r15d
cmpl %r15d, %ebx
jne 0x2e79
movl %ebp, %r15d
testl %ebp, %ebp
js 0x2eb4
movl %r15d, %edx
imull %r15d, %edx
movq %r14, %rdi
movl %r15d, %esi
callq 0x2204
leal -0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, %r15d
jg 0x2e96
movq %r13, 0x8(%rsp)
movl %r12d, (%rsp)
testl %ebp, %ebp
js 0x2ef7
movl %ebp, %r13d
shrl $0x1f, %r13d
leal 0x1(%rbp), %ebx
xorl %r15d, %r15d
movl %r15d, %r12d
imull %r15d, %r12d
movq %r14, %rdi
movl %r12d, %esi
callq 0x2234
cmpl %eax, %r15d
jne 0x2f04
cmpl %ebp, %r15d
leal 0x1(%r15), %eax
setge %r13b
movl %eax, %r15d
cmpl %eax, %ebx
jne 0x2ece
movq %r14, %rdi
callq 0x2040
jmp 0x2fa8
movl $0x29, %edx
movq 0x40c8(%rip), %rdi      # 0x6fd8
leaq 0x1433(%rip), %rsi      # 0x434a
callq 0x1130
movq 0x40b5(%rip), %rdi      # 0x6fd8
movl %r12d, %esi
callq 0x11b0
movq %rax, %r12
movl $0xa, %edx
movq %rax, %rdi
leaq 0x13de(%rip), %rsi      # 0x431b
callq 0x1130
movq %r12, %rdi
movl %r15d, %esi
callq 0x11b0
movq %rax, %r15
movl $0xd, %edx
movq %rax, %rdi
leaq 0x13c7(%rip), %rsi      # 0x4326
callq 0x1130
movq %r15, %rdi
movl 0x4(%rsp), %esi
callq 0x11b0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq %r14, %rdi
callq 0x2040
testb $0x1, %r13b
je 0x3014
movq 0x8(%rsp), %rax
cmpl $0x63, %eax
leal 0x1(%rax), %eax
setae %r12b
movl %eax, %r13d
cmpl $0x64, %eax
jne 0x2e37
leaq 0x13aa(%rip), %rsi      # 0x4374
movl $0x15, %edx
movq 0x4002(%rip), %rbx      # 0x6fd8
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 $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb $0x1, (%rsp)
jne 0x2fc3
jmp 0x3005
jmp 0x3022
jmp 0x3022
jmp 0x3022
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x11c0