// File: /workspace/github_cpp_makefile_star2_O1/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 0x10f9(%rip), %xmm0     # 0x4490
movq %rsp, %rcx
movaps %xmm0, 0x10(%rcx)
movaps 0x10db(%rip), %xmm0     # 0x4480
movaps %xmm0, (%rcx)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x7, %edx
callq 0x1a1a
movq 0x3c1a(%rip), %rbx      # 0x6fd8
leaq 0x101c(%rip), %rsi      # 0x43e1
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 0x3be8(%rip), %rdi      # 0x6fd8
callq 0x1030
movq %rax, %rdi
callq 0x10b0
xorl %ebx, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17e2
cmpl %eax, %ebx
jne 0x3522
incl %ebx
cmpl $0x8, %ebx
jne 0x3404
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 0x1a1a
xorl %ebx, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17e2
cmpl %eax, %ebx
jne 0x3522
incl %ebx
cmpl $0x5, %ebx
jne 0x3450
movl $0x5, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17e2
cmpl $0x5, %eax
jne 0x3531
incl %ebx
cmpl $0xb, %ebx
jne 0x3473
movl $0xb, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17e2
cmpl $0x6, %eax
jne 0x3543
incl %ebx
cmpl $0x12, %ebx
jne 0x3497
movl $0x12, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17e2
cmpl $0x7, %eax
jne 0x3555
incl %ebx
cmpl $0x15, %ebx
jne 0x34bb
movl $0x15, %ebx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
callq 0x17e2
cmpl $-0x1, %eax
jne 0x3567
incl %ebx
cmpl $0x1a, %ebx
jne 0x34df
movq 0x3adc(%rip), %rdi      # 0x6fd8
leaq 0xf24(%rip), %rsi       # 0x4427
movl $0x1c, %edx
callq 0x1140
leaq 0x28(%rsp), %rdi
callq 0x13e6
addq $0xe8, %rsp
popq %rbx
popq %r14
retq
leaq 0xec5(%rip), %rdi       # 0x43ee
movl %ebx, %esi
movl %eax, %edx
movl %ebx, %ecx
jmp 0x3577
leaq 0xeb6(%rip), %rdi       # 0x43ee
movl %ebx, %esi
movl %eax, %edx
movl $0x5, %ecx
jmp 0x3577
leaq 0xea4(%rip), %rdi       # 0x43ee
movl %ebx, %esi
movl %eax, %edx
movl $0x6, %ecx
jmp 0x3577
leaq 0xe92(%rip), %rdi       # 0x43ee
movl %ebx, %esi
movl %eax, %edx
movl $0x7, %ecx
jmp 0x3577
leaq 0xe80(%rip), %rdi       # 0x43ee
movl %ebx, %esi
movl %eax, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x1040
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1160
jmp 0x3594
jmp 0x3594
jmp 0x3594
jmp 0x3594
jmp 0x3594
jmp 0x3594
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x13e6
movq %rbx, %rdi
callq 0x11e0