// 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_1()
void test_get_update_1() {
    // Test with a tree of size 15.
    int n = 15;
    CA_static_search_tree tree(n);
    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) {
        a[i] = i;
        tree.update(i, 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);
        tree.print_tree();
        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 %r14
pushq %rbx
subq $0x60, %rsp
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0xf, %esi
callq 0x1f72
callq 0x1060
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
movl %eax, 0x20(%rsp)
xorl %r14d, %r14d
movl %r14d, 0x20(%rsp,%r14,4)
movq %rbx, %rdi
movl %r14d, %esi
movl %r14d, %edx
callq 0x219e
incq %r14
cmpq $0xf, %r14
jne 0x293f
movl 0x54(%rsp), %ebx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x21ce
movl %eax, %ebp
cmpl $0xd, %eax
jne 0x29b9
movl 0x34(%rsp), %ebp
leaq 0x8(%rsp), %rdi
movl %ebp, %esi
callq 0x21ce
movl %eax, %r14d
cmpl $0x5, %eax
jne 0x29e6
movl 0x20(%rsp), %ebp
leaq 0x8(%rsp), %rdi
movl %ebp, %esi
callq 0x21ce
movl %eax, %r14d
testl %eax, %eax
je 0x2a1b
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x28a8
leaq 0x183e(%rip), %rdi      # 0x41f5
jmp 0x29fc
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x28a8
leaq 0x17af(%rip), %rdi      # 0x417e
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1040
leaq 0x8(%rsp), %rdi
callq 0x2206
jmp 0x2a08
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x28a8
leaq 0x17be(%rip), %rdi      # 0x41ba
movl %ebp, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1040
leaq 0x8(%rsp), %rdi
callq 0x1fd8
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x21ce
movl %eax, %ebp
cmpl $0xd, %eax
jne 0x2a76
movq 0x45a3(%rip), %rbx      # 0x6fd8
leaq 0x17f4(%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 0x4571(%rip), %rdi      # 0x6fd8
callq 0x1030
movq %rax, %rdi
callq 0x10a0
jmp 0x2a08
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x28a8
leaq 0x16f2(%rip), %rdi      # 0x417e
movl %ebx, %esi
movl %ebp, %edx
jmp 0x2a01
jmp 0x2a97
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x1fd8
movq %rbx, %rdi
callq 0x11c0