// File: 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
movq %rsp, %rbp
subq $0xb0, %rsp
movb %dil, %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0xf, -0x8(%rbp)
movl -0x8(%rbp), %esi
movb -0x1(%rbp), %al
leaq -0x28(%rbp), %rdi
andb $0x1, %al
movzbl %al, %edx
callq 0x2bb0
callq 0x1050
movl $0xa, %ecx
cltd
idivl %ecx
movl %edx, -0x70(%rbp)
movl $0x1, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x5506
movl -0x74(%rbp), %eax
decl %eax
cltq
movl -0x70(%rbp,%rax,4), %eax
movl %eax, -0x94(%rbp)
callq 0x1050
movl -0x94(%rbp), %ecx
movslq %eax, %rdx
imulq $0x66666667, %rdx, %rsi # imm = 0x66666667
movq %rsi, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rsi
addl %edx, %esi
addl %esi, %esi
movl %esi, %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %eax
addl %eax, %ecx
movslq -0x74(%rbp), %rax
movl %ecx, -0x70(%rbp,%rax,4)
movslq -0x74(%rbp), %rax
movl %eax, %esi
movl -0x70(%rbp,%rax,4), %edx
leaq -0x28(%rbp), %rdi
callq 0x2fc0
jmp 0x54dc
jmp 0x54de
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x5475
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2c40
jmp 0x570c
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x5546
movslq -0x88(%rbp), %rax
movl %eax, %esi
movl -0x70(%rbp,%rax,4), %edx
leaq -0x28(%rbp), %rdi
callq 0x2fc0
jmp 0x5533
jmp 0x5535
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x5510
movl -0x3c(%rbp), %esi
leaq -0x28(%rbp), %rdi
callq 0x3030
movl %eax, -0x98(%rbp)
jmp 0x555a
movl -0x98(%rbp), %eax
movl %eax, -0x8c(%rbp)
cmpl $0xd, -0x8c(%rbp)
je 0x55a5
movl -0x8(%rbp), %esi
leaq -0x70(%rbp), %rdi
callq 0x53c0
jmp 0x557d
movl -0x3c(%rbp), %esi
movl -0x8c(%rbp), %edx
leaq 0x1ba1(%rip), %rdi      # 0x712e
xorl %eax, %eax
callq 0x1030
jmp 0x5596
movl $0x1, -0x90(%rbp)
jmp 0x56fa
movl -0x5c(%rbp), %esi
leaq -0x28(%rbp), %rdi
callq 0x3030
movl %eax, -0x9c(%rbp)
jmp 0x55b9
movl -0x9c(%rbp), %eax
movl %eax, -0x8c(%rbp)
cmpl $0x5, -0x8c(%rbp)
je 0x5604
movl -0x8(%rbp), %esi
leaq -0x70(%rbp), %rdi
callq 0x53c0
jmp 0x55dc
movl -0x5c(%rbp), %esi
movl -0x8c(%rbp), %edx
leaq 0x1b7e(%rip), %rdi      # 0x716a
xorl %eax, %eax
callq 0x1030
jmp 0x55f5
movl $0x1, -0x90(%rbp)
jmp 0x56fa
movl -0x70(%rbp), %esi
leaq -0x28(%rbp), %rdi
callq 0x3030
movl %eax, -0xa0(%rbp)
jmp 0x5618
movl -0xa0(%rbp), %eax
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x8c(%rbp)
je 0x5663
movl -0x8(%rbp), %esi
leaq -0x70(%rbp), %rdi
callq 0x53c0
jmp 0x563b
movl -0x70(%rbp), %esi
movl -0x8c(%rbp), %edx
leaq 0x1b5a(%rip), %rdi      # 0x71a5
xorl %eax, %eax
callq 0x1030
jmp 0x5654
movl $0x1, -0x90(%rbp)
jmp 0x56fa
movl -0x3c(%rbp), %esi
leaq -0x28(%rbp), %rdi
callq 0x3030
movl %eax, -0xa4(%rbp)
jmp 0x5677
movl -0xa4(%rbp), %eax
movl %eax, -0x8c(%rbp)
cmpl $0xd, -0x8c(%rbp)
je 0x56bf
movl -0x8(%rbp), %esi
leaq -0x70(%rbp), %rdi
callq 0x53c0
jmp 0x569a
movl -0x3c(%rbp), %esi
movl -0x8c(%rbp), %edx
leaq 0x1a84(%rip), %rdi      # 0x712e
xorl %eax, %eax
callq 0x1030
jmp 0x56b3
movl $0x1, -0x90(%rbp)
jmp 0x56fa
movq 0x4912(%rip), %rdi      # 0x9fd8
leaq 0x1b13(%rip), %rsi      # 0x71e0
callq 0x10d0
movq %rax, -0xb0(%rbp)
jmp 0x56db
movq -0xb0(%rbp), %rdi
movq 0x48df(%rip), %rsi      # 0x9fc8
callq 0x1110
jmp 0x56f0
movl $0x0, -0x90(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2c40
addq $0xb0, %rsp
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x1190
nopw %cs:(%rax,%rax)