// File: /workspace/github_cpp_makefile_star2_O2/travisdowns[P]avx-turbo/avx-turbo.cpp
// Function: inner_result run_test<RdtscClock, 101ul, 3ul>(void (*)(unsigned long), unsigned long, outer_timer&, hot_barrier*)
inner_result run_test(cal_f* func, size_t iters, outer_timer& outer, hot_barrier *barrier) {
    assert(iters % 100 == 0);

    std::array<typename CLOCK::delta_t, TRIES> results;

    inner_result result;

    if (arg_dirty) {
        dirty_it();
    }

    if (arg_dirty16) {
        dirty_it16();
    }

    result.ostart_ts = RdtscClock::now();
    for (size_t w = 0; w < WARMUP + 1; w++) {
        result.istart_ts = RdtscClock::now();
        outer.start();
        for (size_t r = 0; r < TRIES; r++) {
            auto t0 = CLOCK::now();
            func(iters);
            auto t1 = CLOCK::now();
            func(iters * 2);
            auto t2 = CLOCK::now();
            results[r] = (t2 - t1) - (t1 - t0);
        }
        outer.stop();
        result.iend_ts = RdtscClock::now();
    }

    for (barrier->increment(); !barrier->is_broken();) {
        func(iters);
    }
    result.oend_ts = RdtscClock::now();

    std::array<uint64_t, TRIES> nanos = {};
    std::transform(results.begin(), results.end(), nanos.begin(), CLOCK::to_nanos);
    DescriptiveStats stats = get_stats(nanos.begin(), nanos.end());

    result.mops = ((double)iters / stats.getMedian());
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6a8, %rsp            # imm = 0x6A8
movq %rcx, 0x10(%rsp)
movq %rdx, %rax
pushq $0x64
popq %rcx
movq %rdx, (%rsp)
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0x121e8
movq %r8, %r14
movq %rsi, %r12
movq %rdi, %rbx
movq 0x15aa1(%rip), %rax     # 0x27aa8
leaq 0x15a9a(%rip), %rdi     # 0x27aa8
callq *0x10(%rax)
testb %al, %al
je 0x1201a
callq 0x1ad55
movq %r14, 0x18(%rsp)
movq 0x15b4a(%rip), %rax     # 0x27b70
leaq 0x15b43(%rip), %rdi     # 0x27b70
callq *0x10(%rax)
testb %al, %al
je 0x12039
callq 0x1ad5f
lfence
rdtsc
shlq $0x20, %rdx
orq %rax, %rdx
lfence
movq %rdx, 0x8(%rbx)
movq (%rsp), %rax
leaq (%rax,%rax), %rbp
movq 0x18(%rbx), %rax
movq %rax, 0x8(%rsp)
movq %rbx, 0x20(%rsp)
movq 0x20(%rbx), %rdx
xorl %eax, %eax
cmpq $0x4, %rax
je 0x1211b
movq %rax, 0x28(%rsp)
lfence
rdtsc
shlq $0x20, %rdx
orq %rax, %rdx
movq %rdx, 0x8(%rsp)
lfence
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *(%rax)
xorl %r14d, %r14d
cmpq $0x65, %r14
je 0x120f4
lfence
rdtsc
movq %rdx, %r15
shlq $0x20, %r15
orq %rax, %r15
lfence
movq (%rsp), %rdi
callq *%r12
lfence
rdtsc
movq %rax, %r13
movq %rdx, %rbx
lfence
movq %rbp, %rdi
callq *%r12
lfence
rdtsc
shlq $0x20, %rdx
orq %rax, %rdx
lfence
addq %r13, %r13
shlq $0x21, %rbx
orq %r13, %rbx
subq %rbx, %r15
addq %rdx, %r15
movq %r15, 0x58(%rsp,%r14,8)
incq %r14
jmp 0x12098
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
lfence
rdtsc
shlq $0x20, %rdx
orq %rax, %rdx
lfence
movq 0x28(%rsp), %rax
incq %rax
jmp 0x12068
movq 0x20(%rsp), %r14
movq 0x8(%rsp), %rax
movq %rax, 0x18(%r14)
movq %rdx, 0x20(%r14)
movq 0x18(%rsp), %rbx
lock
incq 0x8(%rbx)
movq 0x8(%rbx), %rax
cmpq (%rbx), %rax
je 0x12149
movq (%rsp), %rdi
callq *%r12
jmp 0x12137
lfence
rdtsc
shlq $0x20, %rdx
orq %rax, %rdx
lfence
movq %rdx, 0x10(%r14)
leaq 0x380(%rsp), %rbx
movl $0x328, %r15d           # imm = 0x328
movl $0x328, %edx            # imm = 0x328
movq %rbx, %rdi
xorl %esi, %esi
callq 0x61b0
leaq 0x58(%rsp), %rdi
leaq (%rdi,%r15), %rsi
leaq 0x2bd(%rip), %rcx       # 0x12446
movq %rbx, %rdx
callq 0x12510
addq %rbx, %r15
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1254c
movsd (%rsp), %xmm0
unpcklps 0x8e9d(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x8ea5(%rip), %xmm0     # 0x1b060
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0x18(%r12), %xmm1
movsd %xmm1, (%r14)
movq %r14, %rax
addq $0x6a8, %rsp            # imm = 0x6A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa69b(%rip), %rdi      # 0x1c88a
leaq 0x94ac(%rip), %rsi      # 0x1b6a2
leaq 0xa69e(%rip), %rcx      # 0x1c89b
movl $0x17b, %edx            # imm = 0x17B
callq 0x6220
nop