// File: wx-csy[P]librmq/main.cpp
// Function: void performance_test<librmq::rmq_zkw>(unsigned long, unsigned long, unsigned long)
void performance_test(size_t size, size_t nq, size_t rep = 10) {
    std::vector<double> tprep, tq;
    printf("Testing size = %zu nq = %zu with %zu repititions\n", size, nq, rep);
    for (size_t i = 0; i < rep; i++) {
        printf("Round %zu ... ", i); 
        double ttprep, ttq;
        std::tie(ttprep, ttq) = performance_test_instance<TSolver<int>>(size, nq, gen());
        printf("tprep = %.6fs, tquery = %.6fs\n", ttprep, ttq);
        tprep.push_back(ttprep); tq.push_back(ttq);
    }
    double atprep, atq;
    atprep = std::accumulate(tprep.begin(), tprep.end(), 0.0) / rep;
    atq = std::accumulate(tq.begin(), tq.end(), 0.0) / rep;
    printf("tprep = %.6fs, tquery = %.6fs, MQPS = %.6f, ctp/ctq = %.6f\n", 
        atprep, atq, nq / 1000000.0 / atq, atprep / atq / size * nq);
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
movq %rdx, 0x100(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x4a90
leaq 0xd0(%rsp), %rdi
callq 0x4a90
movq 0x110(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq 0x100(%rsp), %rcx
leaq 0xf305c(%rip), %rdi     # 0xf46b4
xorl %eax, %eax
callq 0x1040
jmp 0x1661
movq $0x0, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
cmpq 0x100(%rsp), %rax
jae 0x17dc
movq 0xb8(%rsp), %rsi
leaq 0xf3054(%rip), %rdi     # 0xf46e6
xorl %eax, %eax
callq 0x1040
jmp 0x169b
movq 0x110(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0xf59fc(%rip), %rdi     # 0xf70b8
callq 0x28e0
movq %rax, 0x50(%rsp)
jmp 0x16c8
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdi
movq 0x50(%rsp), %rax
movl %eax, %edx
callq 0x4aa0
movsd %xmm1, 0x30(%rsp)
movsd %xmm0, 0x38(%rsp)
jmp 0x16ec
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd %xmm1, 0x98(%rsp)
movsd %xmm0, 0xa0(%rsp)
leaq 0x88(%rsp), %rdi
movq %rdi, 0x28(%rsp)
leaq 0xb0(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x4fa0
movq 0x28(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x4fe0
movsd 0xb0(%rsp), %xmm0
movsd 0xa8(%rsp), %xmm1
leaq 0xf2f9e(%rip), %rdi     # 0xf46f5
movb $0x2, %al
callq 0x1040
jmp 0x1760
leaq 0xe8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x5050
jmp 0x1777
leaq 0xd0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x5050
jmp 0x178e
jmp 0x1790
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
jmp 0x166d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x5190
leaq 0xe8(%rsp), %rdi
callq 0x5190
jmp 0x1970
leaq 0xe8(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x5130
movq 0x18(%rsp), %rdi
movq %rax, 0x70(%rsp)
callq 0x5160
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rdi
movq 0x68(%rsp), %rsi
xorps %xmm0, %xmm0
callq 0x50c0
movsd %xmm0, 0x20(%rsp)
jmp 0x181c
movsd 0x20(%rsp), %xmm0
movaps 0xf2df7(%rip), %xmm2    # 0xf4620
movq 0x100(%rsp), %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xf2df2(%rip), %xmm2    # 0xf4630
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rsp)
leaq 0xd0(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x5130
movq 0x8(%rsp), %rdi
movq %rax, 0x60(%rsp)
callq 0x5160
movq %rax, 0x58(%rsp)
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
xorps %xmm0, %xmm0
callq 0x50c0
movsd %xmm0, 0x10(%rsp)
jmp 0x189a
movsd 0x10(%rsp), %xmm0
movq 0x100(%rsp), %xmm1
movaps 0xf2d70(%rip), %xmm7    # 0xf4620
punpckldq %xmm7, %xmm1    # xmm1 = xmm1[0],xmm7[0],xmm1[1],xmm7[1]
movapd 0xf2d74(%rip), %xmm6    # 0xf4630
subpd %xmm6, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x80(%rsp), %xmm0
movsd 0x78(%rsp), %xmm1
movq 0x108(%rsp), %xmm4
punpckldq %xmm7, %xmm4    # xmm4 = xmm4[0],xmm7[0],xmm4[1],xmm7[1]
subpd %xmm6, %xmm4
movaps %xmm4, %xmm2
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
addsd %xmm2, %xmm4
movsd 0xf2d38(%rip), %xmm3    # 0xf4640
movaps %xmm4, %xmm2
divsd %xmm3, %xmm2
divsd %xmm1, %xmm2
movaps %xmm0, %xmm3
divsd %xmm1, %xmm3
movq 0x110(%rsp), %xmm5
punpckldq %xmm7, %xmm5    # xmm5 = xmm5[0],xmm7[0],xmm5[1],xmm7[1]
subpd %xmm6, %xmm5
movaps %xmm5, %xmm6
unpckhpd %xmm5, %xmm5            # xmm5 = xmm5[1,1]
addsd %xmm6, %xmm5
divsd %xmm5, %xmm3
mulsd %xmm4, %xmm3
leaq 0xf2dcf(%rip), %rdi     # 0xf4714
movb $0x4, %al
callq 0x1040
jmp 0x194e
leaq 0xd0(%rsp), %rdi
callq 0x5190
leaq 0xe8(%rsp), %rdi
callq 0x5190
addq $0x118, %rsp            # imm = 0x118
retq
movq 0xc8(%rsp), %rdi
callq 0x1120
nopl (%rax)