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

    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 $0xa0, %rsp
movb %dl, %al
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movl -0x4(%rbp), %esi
movb -0x9(%rbp), %al
leaq -0x30(%rbp), %rdi
andb $0x1, %al
movzbl %al, %edx
callq 0x2bc0
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x5442
movl -0x34(%rbp), %edx
leaq -0x30(%rbp), %rdi
movl %edx, %esi
callq 0x2fd0
jmp 0x541b
jmp 0x541d
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5403
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2c50
jmp 0x55f6
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x554a
movl -0x48(%rbp), %eax
movl $0x2710, %ecx           # imm = 0x2710
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x5477
movl -0x48(%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, -0x4c(%rbp)
callq 0x1050
cltd
idivl -0x4(%rbp)
movl %edx, -0x50(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0x54ae
movl -0x50(%rbp), %edx
leaq -0x30(%rbp), %rdi
movl %edx, %esi
callq 0x2fd0
jmp 0x54a9
jmp 0x553a
movl -0x50(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x3040
movl %eax, -0x58(%rbp)
jmp 0x54bf
movl -0x58(%rbp), %eax
cmpl -0x50(%rbp), %eax
je 0x5538
movq 0x3b02(%rip), %rdi      # 0x8fd0
leaq 0xc46(%rip), %rsi       # 0x611b
callq 0x10e0
movq %rax, -0x60(%rbp)
jmp 0x54e0
movq -0x60(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x1190
movq %rax, -0x68(%rbp)
jmp 0x54f2
movq -0x68(%rbp), %rdi
leaq 0xc34(%rip), %rsi       # 0x6131
callq 0x10e0
movq %rax, -0x70(%rbp)
jmp 0x5508
movq -0x70(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x1190
movq %rax, -0x78(%rbp)
jmp 0x551a
movq -0x78(%rbp), %rdi
movq 0x3a9b(%rip), %rsi      # 0x8fc0
callq 0x1120
jmp 0x552c
movl $0x1, -0x54(%rbp)
jmp 0x55e4
jmp 0x553a
jmp 0x553c
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x5449
movq 0x3a7f(%rip), %rdi      # 0x8fd0
leaq 0xbe4(%rip), %rsi       # 0x613c
callq 0x10e0
movq %rax, -0x80(%rbp)
jmp 0x5563
movq -0x80(%rbp), %rdi
movl -0x4(%rbp), %esi
callq 0x1190
movq %rax, -0x88(%rbp)
jmp 0x5578
movq -0x88(%rbp), %rdi
leaq 0xbbc(%rip), %rsi       # 0x6142
callq 0x10e0
movq %rax, -0x90(%rbp)
jmp 0x5594
movq -0x90(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x1190
movq %rax, -0x98(%rbp)
jmp 0x55ac
movq -0x98(%rbp), %rdi
leaq 0xb8b(%rip), %rsi       # 0x6145
callq 0x10e0
movq %rax, -0xa0(%rbp)
jmp 0x55c8
movq -0xa0(%rbp), %rdi
movq 0x39ea(%rip), %rsi      # 0x8fc0
callq 0x1120
jmp 0x55dd
movl $0x0, -0x54(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2c50
addq $0xa0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x11a0
nop