// File: 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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movl $0x8, -0x4(%rbp)
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x148(%rbp)
movl $0x8, %esi
callq 0x1360
movq -0x148(%rbp), %rdi
movaps 0x11b8(%rip), %xmm0     # 0x7440
movaps %xmm0, -0xe0(%rbp)
movaps 0x119a(%rip), %xmm0     # 0x7430
movaps %xmm0, -0xf0(%rbp)
xorl %esi, %esi
movl $0x7, %edx
leaq -0xf0(%rbp), %rcx
callq 0x1ba0
jmp 0x62b2
movq 0x3d1f(%rip), %rdi      # 0x9fd8
leaq 0x10d1(%rip), %rsi      # 0x7391
callq 0x10e0
movq %rax, -0x150(%rbp)
jmp 0x62ce
movq -0x150(%rbp), %rdi
movq 0x3cec(%rip), %rsi      # 0x9fc8
callq 0x1120
jmp 0x62e3
movl $0x0, -0x100(%rbp)
cmpl $0x8, -0x100(%rbp)
jge 0x638f
movl -0x100(%rbp), %esi
leaq -0xc8(%rbp), %rdi
callq 0x18e0
movl %eax, -0x154(%rbp)
jmp 0x6314
movl -0x154(%rbp), %eax
movl %eax, -0x104(%rbp)
movl -0x104(%rbp), %eax
cmpl -0x100(%rbp), %eax
je 0x6379
movl -0x100(%rbp), %ecx
movl -0x104(%rbp), %edx
leaq 0x105d(%rip), %rdi      # 0x739e
xorl %eax, %eax
movl %ecx, %esi
callq 0x1030
jmp 0x634c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1140
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf8(%rbp)
movl %eax, -0xfc(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x1420
jmp 0x66d4
jmp 0x637b
movl -0x100(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x100(%rbp)
jmp 0x62ed
movl $0xa, -0xdc(%rbp)
movl $0x11, -0xd8(%rbp)
movl $0x14, -0xd4(%rbp)
leaq -0xc8(%rbp), %rdi
movl $0x5, %esi
movl $0x7, %edx
leaq -0xf0(%rbp), %rcx
callq 0x1ba0
jmp 0x63cc
movl $0x0, -0x108(%rbp)
cmpl $0x5, -0x108(%rbp)
jge 0x644e
movl -0x108(%rbp), %esi
leaq -0xc8(%rbp), %rdi
callq 0x18e0
movl %eax, -0x158(%rbp)
jmp 0x63f9
movl -0x158(%rbp), %eax
movl %eax, -0x10c(%rbp)
movl -0x10c(%rbp), %eax
cmpl -0x108(%rbp), %eax
je 0x643b
movl -0x108(%rbp), %ecx
movl -0x10c(%rbp), %edx
leaq 0xf78(%rip), %rdi       # 0x739e
xorl %eax, %eax
movl %ecx, %esi
callq 0x1030
jmp 0x6431
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1140
jmp 0x643d
movl -0x108(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x108(%rbp)
jmp 0x63d6
movl $0x5, -0x110(%rbp)
cmpl $0xa, -0x110(%rbp)
jg 0x64e5
movl -0x110(%rbp), %esi
leaq -0xc8(%rbp), %rdi
callq 0x18e0
movl %eax, -0x15c(%rbp)
jmp 0x647f
movl -0x15c(%rbp), %eax
movl %eax, -0x114(%rbp)
movl $0x5, -0x118(%rbp)
movl -0x114(%rbp), %eax
cmpl -0x118(%rbp), %eax
je 0x64cf
movl -0x110(%rbp), %esi
movl -0x114(%rbp), %edx
movl -0x118(%rbp), %ecx
leaq 0xee2(%rip), %rdi       # 0x739e
xorl %eax, %eax
callq 0x1030
jmp 0x64c5
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1140
jmp 0x64d1
movl -0x110(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x110(%rbp)
jmp 0x6458
movl $0xb, -0x11c(%rbp)
cmpl $0x11, -0x11c(%rbp)
jg 0x657c
movl -0x11c(%rbp), %esi
leaq -0xc8(%rbp), %rdi
callq 0x18e0
movl %eax, -0x160(%rbp)
jmp 0x6516
movl -0x160(%rbp), %eax
movl %eax, -0x120(%rbp)
movl $0x6, -0x124(%rbp)
movl -0x120(%rbp), %eax
cmpl -0x124(%rbp), %eax
je 0x6566
movl -0x11c(%rbp), %esi
movl -0x120(%rbp), %edx
movl -0x124(%rbp), %ecx
leaq 0xe4b(%rip), %rdi       # 0x739e
xorl %eax, %eax
callq 0x1030
jmp 0x655c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1140
jmp 0x6568
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x64ef
movl $0x12, -0x128(%rbp)
cmpl $0x14, -0x128(%rbp)
jg 0x6613
movl -0x128(%rbp), %esi
leaq -0xc8(%rbp), %rdi
callq 0x18e0
movl %eax, -0x164(%rbp)
jmp 0x65ad
movl -0x164(%rbp), %eax
movl %eax, -0x12c(%rbp)
movl $0x7, -0x130(%rbp)
movl -0x12c(%rbp), %eax
cmpl -0x130(%rbp), %eax
je 0x65fd
movl -0x128(%rbp), %esi
movl -0x12c(%rbp), %edx
movl -0x130(%rbp), %ecx
leaq 0xdb4(%rip), %rdi       # 0x739e
xorl %eax, %eax
callq 0x1030
jmp 0x65f3
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1140
jmp 0x65ff
movl -0x128(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x128(%rbp)
jmp 0x6586
movl $0x15, -0x134(%rbp)
cmpl $0x19, -0x134(%rbp)
jg 0x66aa
movl -0x134(%rbp), %esi
leaq -0xc8(%rbp), %rdi
callq 0x18e0
movl %eax, -0x168(%rbp)
jmp 0x6644
movl -0x168(%rbp), %eax
movl %eax, -0x138(%rbp)
movl $0xffffffff, -0x13c(%rbp) # imm = 0xFFFFFFFF
movl -0x138(%rbp), %eax
cmpl -0x13c(%rbp), %eax
je 0x6694
movl -0x134(%rbp), %esi
movl -0x138(%rbp), %edx
movl -0x13c(%rbp), %ecx
leaq 0xd1d(%rip), %rdi       # 0x739e
xorl %eax, %eax
callq 0x1030
jmp 0x668a
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1140
jmp 0x6696
movl -0x134(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x134(%rbp)
jmp 0x661d
movq 0x3927(%rip), %rdi      # 0x9fd8
leaq 0xd1f(%rip), %rsi       # 0x73d7
callq 0x10e0
jmp 0x66bf
leaq -0xc8(%rbp), %rdi
callq 0x1420
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0xf8(%rbp), %rdi
callq 0x11b0