// File: wx-csy[P]librmq/main.cpp
// Function: void functional_test_instance<librmq::rmq_zkw<int>>(int)
void functional_test_instance(int size) {
    static int epoch = 0;
    printf("Running epoch #%d (size=%d) ... ", epoch++, size);
    int *data = new int[size];
    for (int i = 0; i < size; i++) data[i] = gen();
    rmq_st<int> st(size, data);
    TSolver rmqr(size, data);
    for (int i = 0; i < size; i++) {
        int l = gen() % size, r = gen() % size + 1;
        if (l == r) continue;
        if (l > r) std::swap(l, r);
        int res_st = st.query(l, r), res_rmq = rmqr.query(l, r);
        if (data[res_st] != data[res_rmq]) {
            puts("FAIL!");
            std::printf(
                "on query #%d (%d, %d): expected %d(%d), returned %d(%d)\n", 
                i, l, r, data[res_st], res_st, data[res_rmq], res_rmq);
            std::exit(EXIT_FAILURE);
        }
    }
    puts("OK!");
    delete[] data;
}

// Assembly:
subq $0x288, %rsp            # imm = 0x288
movl %edi, 0x284(%rsp)
movl 0xf5e4c(%rip), %esi     # 0xf8440
movl %esi, %eax
addl $0x1, %eax
movl %eax, 0xf5e41(%rip)     # 0xf8440
movl 0x284(%rsp), %edx
leaq 0xf2043(%rip), %rdi     # 0xf4650
movb $0x0, %al
callq 0x1040
movslq 0x284(%rsp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x1030
movq %rax, 0x278(%rsp)
movl $0x0, 0x274(%rsp)
movl 0x274(%rsp), %eax
cmpl 0x284(%rsp), %eax
jge 0x2694
leaq 0xf4a51(%rip), %rdi     # 0xf70b8
callq 0x28e0
movl %eax, %edx
movq 0x278(%rsp), %rax
movslq 0x274(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x274(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x274(%rsp)
jmp 0x2650
movslq 0x284(%rsp), %rsi
movq 0x278(%rsp), %rdx
leaq 0x80(%rsp), %rdi
callq 0x29b0
movslq 0x284(%rsp), %rsi
movq 0x278(%rsp), %rdx
leaq 0x60(%rsp), %rdi
callq 0x2a30
jmp 0x26cd
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x284(%rsp), %eax
jge 0x2873
leaq 0xf49cb(%rip), %rdi     # 0xf70b8
callq 0x28e0
movq %rax, 0x38(%rsp)
jmp 0x26f9
movq 0x38(%rsp), %rax
movslq 0x284(%rsp), %rcx
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, 0x4c(%rsp)
leaq 0xf49a0(%rip), %rdi     # 0xf70b8
callq 0x28e0
movq %rax, 0x30(%rsp)
jmp 0x2724
movq 0x30(%rsp), %rax
movslq 0x284(%rsp), %rcx
xorl %edx, %edx
divq %rcx
addq $0x1, %rdx
movl %edx, %eax
movl %eax, 0x48(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x48(%rsp), %eax
jne 0x277f
jmp 0x2863
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
jmp 0x28bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x2e40
jmp 0x28bd
movl 0x4c(%rsp), %eax
cmpl 0x48(%rsp), %eax
jle 0x2798
leaq 0x4c(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x2c20
movslq 0x4c(%rsp), %rsi
movslq 0x48(%rsp), %rdx
leaq 0x80(%rsp), %rdi
callq 0x2c50
movq %rax, 0x28(%rsp)
jmp 0x27b6
movq 0x28(%rsp), %rax
movl %eax, 0x44(%rsp)
movslq 0x4c(%rsp), %rsi
movslq 0x48(%rsp), %rdx
leaq 0x60(%rsp), %rdi
callq 0x2d10
movq %rax, 0x20(%rsp)
jmp 0x27da
movq 0x20(%rsp), %rax
movl %eax, 0x40(%rsp)
movq 0x278(%rsp), %rax
movslq 0x44(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x278(%rsp), %rcx
movslq 0x40(%rsp), %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x2861
leaq 0xf1e65(%rip), %rdi     # 0xf4671
callq 0x1100
jmp 0x2813
movl 0x50(%rsp), %esi
movl 0x4c(%rsp), %edx
movl 0x48(%rsp), %ecx
movq 0x278(%rsp), %rax
movslq 0x44(%rsp), %rdi
movl %edi, %r9d
movl (%rax,%rdi,4), %r8d
movslq 0x40(%rsp), %rdi
movl %edi, %r10d
movl (%rax,%rdi,4), %edi
movq %rsp, %rax
movl %r10d, 0x8(%rax)
movl %edi, (%rax)
leaq 0xf1e29(%rip), %rdi     # 0xf4677
xorl %eax, %eax
callq 0x1040
jmp 0x2857
movl $0x1, %edi
callq 0x10e0
jmp 0x2863
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x26d5
leaq 0xf1e36(%rip), %rdi     # 0xf46b0
callq 0x1100
jmp 0x2881
movq 0x278(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x289e
movq 0x18(%rsp), %rdi
callq 0x10f0
leaq 0x60(%rsp), %rdi
callq 0x2e40
leaq 0x80(%rsp), %rdi
callq 0x2e70
addq $0x288, %rsp            # imm = 0x288
retq
leaq 0x80(%rsp), %rdi
callq 0x2e70
movq 0x58(%rsp), %rdi
callq 0x1120
nopw %cs:(%rax,%rax)
nop