// 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_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 %r12
pushq %rbx
subq $0x60, %rsp
movl %edi, %edx
movq %rsp, %r14
movq %r14, %rdi
movl $0xf, %esi
callq 0x224e
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 %ebx, %r12d
movl %r12d, %ebp
callq 0x1060
movslq %eax, %r12
imulq $0x66666667, %r12, %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, %r12d
addl %ebp, %r12d
movl %r12d, 0x20(%rsp,%r15,4)
movq %r14, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x2454
incq %r15
cmpq $0xf, %r15
jne 0x294a
xorl %r14d, %r14d
movq %rsp, %r15
movl 0x20(%rsp,%r14,4), %edx
movq %r15, %rdi
movl %r14d, %esi
callq 0x2454
incq %r14
cmpq $0xf, %r14
jne 0x2996
movl 0x54(%rsp), %ebp
movq %rsp, %rdi
movl %ebp, %esi
callq 0x247e
movl %eax, %r14d
cmpl $0xd, %eax
jne 0x2a08
movl 0x34(%rsp), %r14d
movq %rsp, %rdi
movl %r14d, %esi
callq 0x247e
movl %eax, %r15d
cmpl $0x5, %eax
jne 0x2a25
movq %rsp, %rdi
movl %ebx, %esi
callq 0x247e
movl %eax, %r14d
testl %eax, %eax
je 0x2a5d
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x28a8
leaq 0x17f1(%rip), %rdi      # 0x41f5
movl %ebx, %esi
jmp 0x2a20
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x28a8
leaq 0x1760(%rip), %rdi      # 0x417e
movl %ebp, %esi
movl %r14d, %edx
jmp 0x2a41
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x28a8
leaq 0x177f(%rip), %rdi      # 0x41ba
movl %r14d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1040
movq %rsp, %rdi
callq 0x22b6
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rdi
movl %ebp, %esi
callq 0x247e
movl %eax, %ebx
cmpl $0xd, %eax
jne 0x2ab6
movq 0x4563(%rip), %rbx      # 0x6fd8
leaq 0x17b4(%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 0x4531(%rip), %rdi      # 0x6fd8
callq 0x1030
movq %rax, %rdi
callq 0x10a0
jmp 0x2a48
leaq 0x20(%rsp), %rdi
movl $0xf, %esi
callq 0x28a8
leaq 0x16b2(%rip), %rdi      # 0x417e
movl %ebp, %esi
movl %ebx, %edx
jmp 0x2a41
jmp 0x2ad9
jmp 0x2ad9
movq %rax, %rbx
movq %rsp, %rdi
callq 0x22b6
movq %rbx, %rdi
callq 0x11c0