// 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_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 0x1fda
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 0x2204
incq %r14
cmpq $0xf, %r14
jne 0x29bf
movl 0x54(%rsp), %ebx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x2234
movl %eax, %ebp
cmpl $0xd, %eax
jne 0x2a39
movl 0x34(%rsp), %ebp
leaq 0x8(%rsp), %rdi
movl %ebp, %esi
callq 0x2234
movl %eax, %r14d
cmpl $0x5, %eax
jne 0x2a66
movl 0x20(%rsp), %ebp
leaq 0x8(%rsp), %rdi
movl %ebp, %esi
callq 0x2234
movl %eax, %r14d
testl %eax, %eax
je 0x2a9b
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x2928
leaq 0x17be(%rip), %rdi      # 0x41f5
jmp 0x2a7c
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x2928
leaq 0x172f(%rip), %rdi      # 0x417e
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1040
leaq 0x8(%rsp), %rdi
callq 0x225c
jmp 0x2a88
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x2928
leaq 0x173e(%rip), %rdi      # 0x41ba
movl %ebp, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1040
leaq 0x8(%rsp), %rdi
callq 0x2040
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x2234
movl %eax, %ebp
cmpl $0xd, %eax
jne 0x2af6
movq 0x4523(%rip), %rbx      # 0x6fd8
leaq 0x1774(%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 0x44f1(%rip), %rdi      # 0x6fd8
callq 0x1030
movq %rax, %rdi
callq 0x10a0
jmp 0x2a88
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x2928
leaq 0x1672(%rip), %rdi      # 0x417e
movl %ebx, %esi
movl %ebp, %edx
jmp 0x2a81
jmp 0x2b17
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x11c0