// File: 6851-2021[P]Cache-Oblivious-Data-Structures/static_search_trees/perf_co_sst.cpp
// Function: test(int, int)
void test(int n, int Q) {
    co_static_search_tree tree(n);

    for (int i = 0; i < n; ++i) {
        tree.update(i, i);
    }

    for (int query = 0; query < Q; ++query)
    {   
        if (query % rand_reset_const == 0) {
            srand(query / rand_reset_const);
        }
        int type = rand() % 2;
        int index = rand() % n;
        if(type == 0) {
            tree.update(index, index);
        } else {
            if(tree.get(index) != index) {
                cout << "Fail: expected value " << index << " at index " << index << endl;
                return;
            }
        }
    }
    cout << "test(" << n << ", " << Q << "): OK" << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl -0x4(%rbp), %esi
leaq -0xc8(%rbp), %rdi
callq 0x1350
movl $0x0, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x5451
movl -0xcc(%rbp), %edx
leaq -0xc8(%rbp), %rdi
movl %edx, %esi
callq 0x16b0
jmp 0x541b
jmp 0x541d
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x53fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x1410
jmp 0x5666
movl $0x0, -0xe0(%rbp)
movl -0xe0(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x55ae
movl -0xe0(%rbp), %eax
movl $0x2710, %ecx           # imm = 0x2710
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x5492
movl -0xe0(%rbp), %eax
movl $0x2710, %ecx           # imm = 0x2710
cltd
idivl %ecx
movl %eax, %edi
callq 0x10d0
callq 0x1050
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, -0xe4(%rbp)
callq 0x1050
cltd
idivl -0x4(%rbp)
movl %edx, -0xe8(%rbp)
cmpl $0x0, -0xe4(%rbp)
jne 0x54d8
movl -0xe8(%rbp), %edx
leaq -0xc8(%rbp), %rdi
movl %edx, %esi
callq 0x16b0
jmp 0x54d3
jmp 0x5598
movl -0xe8(%rbp), %esi
leaq -0xc8(%rbp), %rdi
callq 0x18d0
movl %eax, -0xf0(%rbp)
jmp 0x54f2
movl -0xf0(%rbp), %eax
cmpl -0xe8(%rbp), %eax
je 0x5596
movq 0x3ac5(%rip), %rdi      # 0x8fd0
leaq 0xc09(%rip), %rsi       # 0x611b
callq 0x10e0
movq %rax, -0xf8(%rbp)
jmp 0x5520
movq -0xf8(%rbp), %rdi
movl -0xe8(%rbp), %esi
callq 0x1190
movq %rax, -0x100(%rbp)
jmp 0x553b
movq -0x100(%rbp), %rdi
leaq 0xbe8(%rip), %rsi       # 0x6131
callq 0x10e0
movq %rax, -0x108(%rbp)
jmp 0x5557
movq -0x108(%rbp), %rdi
movl -0xe8(%rbp), %esi
callq 0x1190
movq %rax, -0x110(%rbp)
jmp 0x5572
movq -0x110(%rbp), %rdi
movq 0x3a40(%rip), %rsi      # 0x8fc0
callq 0x1120
jmp 0x5587
movl $0x1, -0xec(%rbp)
jmp 0x5651
jmp 0x5598
jmp 0x559a
movl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0x545b
movq 0x3a1b(%rip), %rdi      # 0x8fd0
leaq 0xb80(%rip), %rsi       # 0x613c
callq 0x10e0
movq %rax, -0x118(%rbp)
jmp 0x55ca
movq -0x118(%rbp), %rdi
movl -0x4(%rbp), %esi
callq 0x1190
movq %rax, -0x120(%rbp)
jmp 0x55e2
movq -0x120(%rbp), %rdi
leaq 0xb52(%rip), %rsi       # 0x6142
callq 0x10e0
movq %rax, -0x128(%rbp)
jmp 0x55fe
movq -0x128(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x1190
movq %rax, -0x130(%rbp)
jmp 0x5616
movq -0x130(%rbp), %rdi
leaq 0xb21(%rip), %rsi       # 0x6145
callq 0x10e0
movq %rax, -0x138(%rbp)
jmp 0x5632
movq -0x138(%rbp), %rdi
movq 0x3980(%rip), %rsi      # 0x8fc0
callq 0x1120
jmp 0x5647
movl $0x0, -0xec(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x1410
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0xd8(%rbp), %rdi
callq 0x11a0
nopw %cs:(%rax,%rax)