// File: /workspace/github_cpp_makefile_star2_O1/6851-2021[P]Cache-Oblivious-Data-Structures/static_search_trees/test_simple_sst.cpp
// Function: test_get_update_1(bool)
void test_get_update_1(bool recursive) {
    // Test with a tree of size 15.
    int n = 15;
    simple_static_search_tree tree(n, recursive);
    int a[15];
    a[0] = rand() % 10;
    for (int i = 1; i < n; ++i) {
        a[i] = a[i - 1] + rand() % 10;
        tree.update(i, a[i]);
    }

    for (int i = 0; i < n; ++i) {
        tree.update(i, a[i]);
    }

    int index;

    index = tree.get(a[13]);
    if (index != 13)
    {
        print_array(a, n);
        printf("test_get_update_1 failed: expected %d at index 13, got: %d\n", a[13], index);
        return;
    }

    index = tree.get(a[5]);
    if (index != 5)
    {
        print_array(a, n);
        printf("test_get_update_1 failed: expected %d at index 5, got: %d\n", a[5], index);
        return;
    }

    index = tree.get(a[0]);
    if (index != 0)
    {
        print_array(a, n);
        printf("test_get_update_1 failed: expected %d at index 0, got: %d\n", a[0], index);
        return;
    }

    index = tree.get(a[13]);
    if (index != 13)
    {
        print_array(a, n);
        printf("test_get_update_1 failed: expected %d at index 13, got: %d\n", a[13], index);
        return;
    }
    cout << "test_get_update_1: OK" << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
movl %edi, %edx
movq %rsp, %r14
movq %r14, %rdi
movl $0xf, %esi
callq 0x22a4
callq 0x1060
movslq %eax, %rbx
imulq $0x66666667, %rbx, %rax # imm = 0x66666667
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rax
addl %ecx, %eax
addl %eax, %eax
leal (%rax,%rax,4), %eax
subl %eax, %ebx
movl %ebx, 0x20(%rsp)
movl $0x1, %r15d
movl 0x1c(%rsp,%r15,4), %ebp
callq 0x1060
movslq %eax, %rdx
imulq $0x66666667, %rdx, %rax # imm = 0x66666667
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rax
addl %ecx, %eax
addl %eax, %eax
leal (%rax,%rax,4), %eax
subl %eax, %edx
addl %ebp, %edx
movl %edx, 0x20(%rsp,%r15,4)
movq %r14, %rdi
movl %r15d, %esi
callq 0x24a8
incq %r15
cmpq $0xf, %r15
jne 0x29c5
xorl %r14d, %r14d
movq %rsp, %r15
movl 0x20(%rsp,%r14,4), %edx
movq %r15, %rdi
movl %r14d, %esi
callq 0x24a8
incq %r14
cmpq $0xf, %r14
jne 0x2a0e
movl 0x54(%rsp), %ebp
movq %rsp, %rdi
movl %ebp, %esi
callq 0x24d2
movl %eax, %r14d
cmpl $0xd, %eax
jne 0x2a80
movl 0x34(%rsp), %r14d
movq %rsp, %rdi
movl %r14d, %esi
callq 0x24d2
movl %eax, %r15d
cmpl $0x5, %eax
jne 0x2a9d
movq %rsp, %rdi
movl %ebx, %esi
callq 0x24d2
movl %eax, %r14d
testl %eax, %eax
je 0x2ad3
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x2928
leaq 0x1779(%rip), %rdi      # 0x41f5
movl %ebx, %esi
jmp 0x2a98
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x2928
leaq 0x16e8(%rip), %rdi      # 0x417e
movl %ebp, %esi
movl %r14d, %edx
jmp 0x2ab9
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x2928
leaq 0x1707(%rip), %rdi      # 0x41ba
movl %r14d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1040
movq %rsp, %rdi
callq 0x230c
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rdi
movl %ebp, %esi
callq 0x24d2
movl %eax, %ebx
cmpl $0xd, %eax
jne 0x2b2c
movq 0x44ed(%rip), %rbx      # 0x6fd8
leaq 0x173e(%rip), %rsi      # 0x4230
movl $0x15, %edx
movq %rbx, %rdi
callq 0x1130
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x10f0
movsbl %al, %esi
movq 0x44bb(%rip), %rdi      # 0x6fd8
callq 0x1030
movq %rax, %rdi
callq 0x10a0
jmp 0x2ac0
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x2928
leaq 0x163c(%rip), %rdi      # 0x417e
movl %ebp, %esi
movl %ebx, %edx
jmp 0x2ab9
jmp 0x2b4f
jmp 0x2b4f
movq %rax, %rbx
movq %rsp, %rdi
callq 0x230c
movq %rbx, %rdi
callq 0x11c0