// File: /workspace/github_cpp_makefile_star2_O3/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 %r14
pushq %rbx
subq $0xe8, %rsp
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movl $0x8, %esi
callq 0x134c
movaps 0x124b(%rip), %xmm0     # 0x44c0
movq %rsp, %rcx
movaps %xmm0, 0x10(%rcx)
movaps 0x122d(%rip), %xmm0     # 0x44b0
movaps %xmm0, (%rcx)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x7, %edx
callq 0x1a02
movq 0x3d3c(%rip), %rbx      # 0x6fd8
leaq 0x116e(%rip), %rsi      # 0x4411
movl $0xc, %edx
movq %rbx, %rdi
callq 0x1140
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x1100
movsbl %al, %esi
movq 0x3d0a(%rip), %rdi      # 0x6fd8
callq 0x1030
movq %rax, %rdi
callq 0x10b0
xorl %ebx, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17bc
cmpl %eax, %ebx
jne 0x3400
incl %ebx
cmpl $0x8, %ebx
jne 0x32e2
movabsq $0x110000000a, %rax     # imm = 0x110000000A
movq %rsp, %rcx
movq %rax, 0x14(%rcx)
movl $0x14, 0x1c(%rcx)
leaq 0x28(%rsp), %rdi
movl $0x5, %esi
movl $0x7, %edx
callq 0x1a02
xorl %ebx, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17bc
cmpl %eax, %ebx
jne 0x3400
incl %ebx
cmpl $0x5, %ebx
jne 0x332e
movl $0x5, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17bc
cmpl $0x5, %eax
jne 0x340f
incl %ebx
cmpl $0xb, %ebx
jne 0x3351
movl $0xb, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17bc
cmpl $0x6, %eax
jne 0x3421
incl %ebx
cmpl $0x12, %ebx
jne 0x3375
movl $0x12, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17bc
cmpl $0x7, %eax
jne 0x3433
incl %ebx
cmpl $0x15, %ebx
jne 0x3399
movl $0x15, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17bc
cmpl $-0x1, %eax
jne 0x3445
incl %ebx
cmpl $0x1a, %ebx
jne 0x33bd
movq 0x3bfe(%rip), %rdi      # 0x6fd8
leaq 0x1076(%rip), %rsi      # 0x4457
movl $0x1c, %edx
callq 0x1140
leaq 0x28(%rsp), %rdi
callq 0x13e6
addq $0xe8, %rsp
popq %rbx
popq %r14
retq
leaq 0x1017(%rip), %rdi      # 0x441e
movl %ebx, %esi
movl %eax, %edx
movl %ebx, %ecx
jmp 0x3455
leaq 0x1008(%rip), %rdi      # 0x441e
movl %ebx, %esi
movl %eax, %edx
movl $0x5, %ecx
jmp 0x3455
leaq 0xff6(%rip), %rdi       # 0x441e
movl %ebx, %esi
movl %eax, %edx
movl $0x6, %ecx
jmp 0x3455
leaq 0xfe4(%rip), %rdi       # 0x441e
movl %ebx, %esi
movl %eax, %edx
movl $0x7, %ecx
jmp 0x3455
leaq 0xfd2(%rip), %rdi       # 0x441e
movl %ebx, %esi
movl %eax, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x1040
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1160
jmp 0x3472
jmp 0x3472
jmp 0x3472
jmp 0x3472
jmp 0x3472
jmp 0x3472
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x13e6
movq %rbx, %rdi
callq 0x11e0