// File: /workspace/github_cpp_makefile_star2_O3/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
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, %ebx
subl %ecx, %ebx
negl %ecx
leal (%rax,%rcx), %esi
incl %esi
movq %r14, %rdi
movl %esi, 0xc(%rsp)
callq 0x1f72
testl %ebx, %ebx
js 0x2e09
leal 0x1(%rbx), %r13d
xorl %ebp, %ebp
movq %r14, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x219e
incl %ebp
cmpl %ebp, %r13d
jne 0x2db2
movl %ebx, %r15d
movl %r15d, %edx
imull %r15d, %edx
movq %r14, %rdi
movl %r15d, %esi
callq 0x219e
leal -0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, %r15d
jg 0x2dc8
testl %ebx, %ebx
js 0x2e09
xorl %ebp, %ebp
movl %ebp, %r15d
imull %ebp, %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x21ce
cmpl %eax, %ebp
jne 0x2e65
incl %ebp
cmpl %ebp, %r13d
jne 0x2dec
movq %r14, %rdi
callq 0x1fd8
incl %r12d
cmpl $0x64, %r12d
jne 0x2d70
movq 0x41b3(%rip), %rbx      # 0x6fd8
leaq 0x1548(%rip), %rsi      # 0x4374
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
jmp 0x2f04
movq 0x416c(%rip), %rdi      # 0x6fd8
leaq 0x14d7(%rip), %rsi      # 0x434a
movl $0x29, %edx
callq 0x1130
movq 0x4154(%rip), %rdi      # 0x6fd8
movl %r15d, %esi
callq 0x11b0
movq %rax, %r14
leaq 0x1485(%rip), %rsi      # 0x431b
movl $0xa, %edx
movq %rax, %rdi
callq 0x1130
movq %r14, %rdi
movl %ebp, %esi
callq 0x11b0
movq %rax, %r14
leaq 0x146f(%rip), %rsi      # 0x4326
movl $0xd, %edx
movq %rax, %rdi
callq 0x1130
movq %r14, %rdi
movl 0xc(%rsp), %esi
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
leaq 0x10(%rsp), %rdi
callq 0x1fd8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2f19
jmp 0x2f19
jmp 0x2f19
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1fd8
movq %rbx, %rdi
callq 0x11c0