// File: /workspace/github_cpp_makefile_star2_O3/6851-2021[P]Cache-Oblivious-Data-Structures/static_search_trees/test_simple_sst.cpp
// Function: test_get_update_4(bool)
void test_get_update_4(bool recursive) {
    // -- 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;
        simple_static_search_tree tree(t_size, recursive);
        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 %r13d, %r13d
movzbl %dil, %eax
movl %eax, 0x4(%rsp)
leaq 0x8(%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, %r12d
subl %ecx, %r12d
negl %ecx
leal (%rax,%rcx), %ebx
incl %ebx
movq %r14, %rdi
movl %ebx, %esi
movl 0x4(%rsp), %edx
callq 0x224e
testl %r12d, %r12d
js 0x2e89
leal 0x1(%r12), %ebp
xorl %r15d, %r15d
movq %r14, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x2454
incl %r15d
cmpl %r15d, %ebp
jne 0x2e2b
movl %r12d, %r15d
movl %r15d, %edx
imull %r15d, %edx
movq %r14, %rdi
movl %r15d, %esi
callq 0x2454
leal -0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, %r15d
jg 0x2e44
testl %r12d, %r12d
js 0x2e89
xorl %r15d, %r15d
movl %r15d, %r12d
imull %r15d, %r12d
movq %r14, %rdi
movl %r12d, %esi
callq 0x247e
cmpl %eax, %r15d
jne 0x2ee5
incl %r15d
cmpl %r15d, %ebp
jne 0x2e6a
movq %r14, %rdi
callq 0x22b6
incl %r13d
cmpl $0x64, %r13d
jne 0x2de2
movq 0x4133(%rip), %rbx      # 0x6fd8
leaq 0x14c8(%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 0x2f83
movq 0x40ec(%rip), %rdi      # 0x6fd8
leaq 0x1457(%rip), %rsi      # 0x434a
movl $0x29, %edx
callq 0x1130
movq 0x40d4(%rip), %rdi      # 0x6fd8
movl %r12d, %esi
callq 0x11b0
movq %rax, %r14
leaq 0x1405(%rip), %rsi      # 0x431b
movl $0xa, %edx
movq %rax, %rdi
callq 0x1130
movq %r14, %rdi
movl %r15d, %esi
callq 0x11b0
movq %rax, %r14
leaq 0x13ee(%rip), %rsi      # 0x4326
movl $0xd, %edx
movq %rax, %rdi
callq 0x1130
movq %r14, %rdi
movl %ebx, %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 0x8(%rsp), %rdi
callq 0x22b6
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2f98
jmp 0x2f98
jmp 0x2f98
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x22b6
movq %rbx, %rdi
callq 0x11c0