// File: /workspace/github_cpp_makefile_star2_O2/6851-2021[P]Cache-Oblivious-Data-Structures/static_search_trees/test_co_sst.cpp
// Function: test_range_update_small()
void test_range_update_small() {
    const int n = 8;
    co_static_search_tree tree(n);
    int arr[] = {0, 1, 2, 3, 4, 5, 6, 7};
    tree.range_update(0, n - 1, arr);
    cout << "First Update" << endl;
    for (int i = 0; i < n; ++i)
    {
        int result = tree.get(i);
        if (result != i)
        {
            printf("Incorrect index for query value %d, got %d, expected %d\n", i, result, i);
            exit(-1);
        }
    }

    arr[5] = 10;
    arr[6] = 17;
    arr[7] = 20;
    tree.range_update(5, 7, arr);

    for (int i = 0; i < 5 ; ++i) {
        int result = tree.get(i);
        if (result != i)
        {
            printf("Incorrect index for query value %d, got %d, expected %d\n", i, result, i);
            exit(-1);
        }
    }
    for (int i = 5; i <= 10 ; ++i) {
        int result = tree.get(i);
        int expected = 5;
        if (result != expected)
        {
            printf("Incorrect index for query value %d, got %d, expected %d\n", i, result, expected);
            exit(-1);
        }
    }

    for (int i = 11; i <= 17 ; ++i) {
        int result = tree.get(i);
        int expected = 6;
        if (result != expected)
        {
            printf("Incorrect index for query value %d, got %d, expected %d\n", i, result, expected);
            exit(-1);
        }
    }

    for (int i = 18; i <= 20 ; ++i) {
        int result = tree.get(i);
        int expected = 7;
        if (result != expected)
        {
            printf("Incorrect index for query value %d, got %d, expected %d\n", i, result, expected);
            exit(-1);
        }
    }

    for (int i = 21; i <= 25 ; ++i) {
        int result = tree.get(i);
        int expected = -1;
        if (result != expected)
        {
            printf("Incorrect index for query value %d, got %d, expected %d\n", i, result, expected);
            exit(-1);
        }
    }
    cout << "Range Update Small: Success\n";
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0xe0, %rsp
leaq 0x20(%rsp), %rbx
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x133c
movaps 0x1638(%rip), %xmm0     # 0x4490
movq %rsp, %rcx
movaps %xmm0, 0x10(%rcx)
movaps 0x161a(%rip), %xmm0     # 0x4480
movaps %xmm0, (%rcx)
pushq $0x7
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x188e
movq 0x415b(%rip), %rdi      # 0x6fd8
leaq 0x155d(%rip), %rsi      # 0x43e1
callq 0x1100
movq %rax, %rdi
callq 0x10a0
xorl %ebx, %ebx
leaq 0x20(%rsp), %r14
cmpl $0x8, %ebx
je 0x2eb3
movq %r14, %rdi
movl %ebx, %esi
callq 0x16ba
cmpl %eax, %ebx
jne 0x2fb1
incl %ebx
jmp 0x2e98
movabsq $0x110000000a, %rax     # imm = 0x110000000A
movq %rsp, %rcx
movq %rax, 0x14(%rcx)
movl $0x14, 0x1c(%rcx)
leaq 0x20(%rsp), %rdi
pushq $0x5
popq %rbx
pushq $0x7
popq %rdx
movl %ebx, %esi
callq 0x188e
xorl %ebp, %ebp
leaq 0x20(%rsp), %r14
cmpl $0x5, %ebp
je 0x2eff
movq %r14, %rdi
movl %ebp, %esi
callq 0x16ba
cmpl %eax, %ebp
jne 0x2fc0
incl %ebp
jmp 0x2ee4
leaq 0x20(%rsp), %r14
cmpl $0xb, %ebx
je 0x2f20
movq %r14, %rdi
movl %ebx, %esi
callq 0x16ba
cmpl $0x5, %eax
jne 0x2fcf
incl %ebx
jmp 0x2f04
pushq $0xb
popq %rbx
leaq 0x20(%rsp), %r14
cmpl $0x12, %ebx
je 0x2f44
movq %r14, %rdi
movl %ebx, %esi
callq 0x16ba
cmpl $0x6, %eax
jne 0x2fda
incl %ebx
jmp 0x2f28
pushq $0x12
popq %rbx
leaq 0x20(%rsp), %r14
cmpl $0x15, %ebx
je 0x2f68
movq %r14, %rdi
movl %ebx, %esi
callq 0x16ba
cmpl $0x7, %eax
jne 0x2fe5
incl %ebx
jmp 0x2f4c
pushq $0x15
popq %rbx
leaq 0x20(%rsp), %r14
cmpl $0x1a, %ebx
je 0x2f88
movq %r14, %rdi
movl %ebx, %esi
callq 0x16ba
cmpl $-0x1, %eax
jne 0x3002
incl %ebx
jmp 0x2f70
movq 0x4049(%rip), %rdi      # 0x6fd8
leaq 0x1491(%rip), %rsi      # 0x4427
callq 0x1100
leaq 0x20(%rsp), %rdi
callq 0x13b4
addq $0xe0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1436(%rip), %rdi      # 0x43ee
movl %ebx, %esi
movl %eax, %edx
movl %ebx, %ecx
jmp 0x2ff3
leaq 0x1427(%rip), %rdi      # 0x43ee
movl %ebp, %esi
movl %eax, %edx
movl %ebp, %ecx
jmp 0x2ff3
leaq 0x1418(%rip), %rdi      # 0x43ee
pushq $0x5
jmp 0x2fee
leaq 0x140d(%rip), %rdi      # 0x43ee
pushq $0x6
jmp 0x2fee
leaq 0x1402(%rip), %rdi      # 0x43ee
pushq $0x7
popq %rcx
movl %ebx, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x1030
pushq $-0x1
popq %rdi
callq 0x1150
leaq 0x13e5(%rip), %rdi      # 0x43ee
pushq $-0x1
popq %rbp
movl %ebx, %esi
movl %eax, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x1030
movl %ebp, %edi
callq 0x1150
jmp 0x302c
jmp 0x302c
jmp 0x302c
jmp 0x302c
jmp 0x302c
jmp 0x302c
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x13b4
movq %rbx, %rdi
callq 0x11d0