// File: /workspace/github_cpp_makefile_star2_O2/travisdowns[P]avx-turbo/avx-turbo.cpp
// Function: main
int main(int argc, char** argv) {

    try {
        parser.ParseCLI(argc, argv);
        if (arg_iters.Get() % 100 != 0) {
            printf("ITERS must be a multiple of 100\n");
            exit(EXIT_FAILURE);
        }
    } catch (args::Help& help) {
        printf("%s\n", parser.Help().c_str());
        exit(EXIT_SUCCESS);
    } catch (const args::ParseError& e) {
        printf("ERROR while parsing arguments: %s\n", e.what());
        printf("\nUsage:\n%s\n", parser.Help().c_str());
        exit(EXIT_FAILURE);
    }

    if (arg_list) {
        list_tests();
        exit(EXIT_SUCCESS);
    }

    verbose = arg_verbose;
    bool is_root = (geteuid() == 0);
    bool use_aperf = aperf_ghz::is_supported();
    printf("CPUID highest leaf    : [%2xh]\n", cpuid_highest_leaf());
    printf("Running as root       : [%s]\n", is_root     ? "YES" : "NO ");
    printf("MSR reads supported   : [%s]\n", use_aperf   ? "YES" : "NO ");
    printf("CPU pinning enabled   : [%s]\n", !arg_no_pin ? "YES" : "NO ");

    ISA isas_supported = get_isas();
    zeroupper_allowed = isas_supported & AVX2;
    printf("CPU supports zeroupper: [%s]\n", zeroupper_allowed         ? "YES" : "NO ");
    printf("CPU supports AVX2     : [%s]\n", isas_supported & AVX2     ? "YES" : "NO ");
    printf("CPU supports AVX-512F : [%s]\n", isas_supported & AVX512F  ? "YES" : "NO ");
    printf("CPU supports AVX-512VL: [%s]\n", isas_supported & AVX512VL ? "YES" : "NO ");
    printf("CPU supports AVX-512BW: [%s]\n", isas_supported & AVX512BW ? "YES" : "NO ");
    printf("CPU supports AVX-512CD: [%s]\n", isas_supported & AVX512CD ? "YES" : "NO ");
    printf("tsc_freq = %.1f MHz (%s)\n", RdtscClock::tsc_freq() / 1000000.0, get_tsc_cal_info(arg_force_tsc_cal));
    std::vector<int> cpus = get_cpus();
    printf("CPU brand string: %s\n", get_brand_string().c_str());
    printf("%lu available CPUs: [%s]\n", cpus.size(), join(cpus, ", ").c_str());
    if (!arg_hyperthreads) {
        cpus = filter_cpus(cpus);
        printf("%lu physical cores: [%s]\n", cpus.size(), join(cpus, ", ").c_str());
    }

    if (arg_dirty && !(isas_supported & AVX512VL)) {
        printf("ERROR: --dirty-upper only supported on AVX-512 hardware\n");
        exit(EXIT_FAILURE);
    }

    auto iters = arg_iters.Get();
    zeroupper();
    auto specs = filter_tests(isas_supported, cpus);

    size_t last_thread_count = -1u;
    std::vector<result_holder> results_list;
    for (auto& spec : specs) {
        // if we changed the number of threads, spit out the accumulated output
        if (last_thread_count != -1u && last_thread_count != spec.count()) {
            // time to print results
            report_results(results_list, use_aperf);
            results_list.clear();
        }
        last_thread_count = spec.count();

        assert(!spec.thread_funcs.empty());
        if (verbose) printf("Running test spec: %s\n", spec.to_string().c_str());

        // run
        std::deque<test_thread> threads;
        hot_barrier start{spec.count()}, stop{spec.count()};
        for (auto& test : spec.thread_funcs) {
            threads.emplace_back(threads.size(), start, stop, &test, iters, use_aperf);
        }

        results_list.emplace_back(&spec);
        for (auto& t : threads) {
            t.thread.join();
            results_list.back().results.push_back(t.res);
        }
    }

    report_results(results_list, use_aperf);

    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %rdx
movl %edi, %esi
leaq 0x1ea37(%rip), %rdi     # 0x273a0
callq 0xa5b6
movq 0x1f56b(%rip), %rax     # 0x27ee0
pushq $0x64
popq %rcx
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0x8f96
movq 0x1ef8b(%rip), %rax     # 0x27918
leaq 0x1ef84(%rip), %rdi     # 0x27918
callq *0x10(%rax)
testb %al, %al
jne 0x8f9f
movq 0x1ede2(%rip), %rax     # 0x27788
leaq 0x1eddb(%rip), %rdi     # 0x27788
callq *0x10(%rax)
movb %al, 0x1f882(%rip)      # 0x28238
callq 0x61d0
movl %eax, %ebx
callq 0xa6ac
movl %eax, %ebp
movb %al, 0x17(%rsp)
callq 0x13237
leaq 0x12e98(%rip), %rdi     # 0x1b86c
movl %eax, %esi
xorl %eax, %eax
callq 0x6050
testl %ebx, %ebx
leaq 0x12ec4(%rip), %r12     # 0x1b8aa
leaq 0x12ec1(%rip), %r14     # 0x1b8ae
movq %r14, %rsi
cmoveq %r12, %rsi
leaq 0x12e91(%rip), %rdi     # 0x1b88c
xorl %eax, %eax
callq 0x6050
testb %bpl, %bpl
movq %r14, %rsi
cmovneq %r12, %rsi
leaq 0x12e9f(%rip), %rdi     # 0x1b8b2
xorl %eax, %eax
callq 0x6050
movq 0x1ec9f(%rip), %rax     # 0x276c0
leaq 0x1ec98(%rip), %rdi     # 0x276c0
callq *0x10(%rax)
testb %al, %al
movq %r14, %rsi
cmoveq %r12, %rsi
leaq 0x12e95(%rip), %rdi     # 0x1b8d0
xorl %eax, %eax
callq 0x6050
callq 0x76fe
movl %eax, %ebx
andl $0x2, %eax
movl %eax, %ecx
shrl %ecx
testl %eax, %eax
movb %cl, 0x1e940(%rip)      # 0x27398
movq %r14, %r15
cmovneq %r12, %r15
leaq 0x12e88(%rip), %rdi     # 0x1b8ee
movq %r15, %rsi
xorl %eax, %eax
callq 0x6050
leaq 0x12e95(%rip), %rdi     # 0x1b90c
movq %r15, %rsi
xorl %eax, %eax
callq 0x6050
testb $0x4, %bl
movq %r14, %rsi
cmovneq %r12, %rsi
leaq 0x12e98(%rip), %rdi     # 0x1b92a
xorl %eax, %eax
callq 0x6050
testb $0x8, %bl
movq %r14, %rsi
cmovneq %r12, %rsi
leaq 0x12e9e(%rip), %rdi     # 0x1b948
xorl %eax, %eax
callq 0x6050
cmpl $0x20, %ebx
movq %r12, %rsi
cmovbq %r14, %rsi
leaq 0x12ea4(%rip), %rdi     # 0x1b966
xorl %eax, %eax
callq 0x6050
testb $0x10, %bl
cmovneq %r12, %r14
leaq 0x12ead(%rip), %rdi     # 0x1b984
movq %r14, %rsi
xorl %eax, %eax
callq 0x6050
callq 0xa6d6
movq %rax, %xmm0
punpckldq 0x1255d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x12565(%rip), %xmm0    # 0x1b060
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0x12501(%rip), %xmm1    # 0x1b010
movapd %xmm1, 0x40(%rsp)
movq 0x1eadc(%rip), %rax     # 0x275f8
leaq 0x1ead5(%rip), %rdi     # 0x275f8
callq *0x10(%rax)
movzbl %al, %edi
callq 0x137e9
leaq 0x12e6d(%rip), %rdi     # 0x1b9a2
movaps 0x40(%rsp), %xmm0
movq %rax, %rsi
movb $0x1, %al
callq 0x6050
leaq 0x18(%rsp), %rdi
callq 0x8661
leaq 0xa8(%rsp), %rdi
callq 0x13349
leaq 0xa8(%rsp), %r14
movq (%r14), %rsi
leaq 0x12e4f(%rip), %rdi     # 0x1b9bc
xorl %eax, %eax
callq 0x6050
movq %r14, %rdi
callq 0x6140
movq 0x20(%rsp), %r14
subq 0x18(%rsp), %r14
leaq 0x12e5f(%rip), %rsi     # 0x1b9ec
leaq 0x168(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x6100
leaq 0xa8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x168(%rsp), %rdx
callq 0x911f
sarq $0x2, %r14
leaq 0xa8(%rsp), %r15
movq (%r15), %rdx
leaq 0x12e03(%rip), %rdi     # 0x1b9d2
movq %r14, %rsi
xorl %eax, %eax
callq 0x6050
movq %r15, %rdi
callq 0x6140
leaq 0x168(%rsp), %rdi
callq 0x6140
movq 0x1edeb(%rip), %rax     # 0x279e0
leaq 0x1ede4(%rip), %rdi     # 0x279e0
callq *0x10(%rax)
testb %al, %al
jne 0x8cca
leaq 0x130(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x9bc4
leaq 0xa8(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x874e
leaq 0x18(%rsp), %r15
leaq 0xa8(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x11a56
movq %r14, %rdi
callq 0x115da
leaq 0x130(%rsp), %rdi
callq 0x115da
movq 0x8(%r15), %r14
subq (%r15), %r14
leaq 0x12d83(%rip), %rsi     # 0x1b9ec
leaq 0x148(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x6100
leaq 0xa8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x911f
sarq $0x2, %r14
leaq 0xa8(%rsp), %r15
movq (%r15), %rdx
leaq 0x12d44(%rip), %rdi     # 0x1b9ef
movq %r14, %rsi
xorl %eax, %eax
callq 0x6050
movq %r15, %rdi
callq 0x6140
leaq 0x148(%rsp), %rdi
callq 0x6140
movq 0x1edd7(%rip), %rax     # 0x27aa8
leaq 0x1edd0(%rip), %rdi     # 0x27aa8
callq *0x10(%rax)
testb $0x8, %bl
jne 0x8ce8
testb %al, %al
jne 0x8fa9
movq 0x1f1f1(%rip), %rax     # 0x27ee0
movq %rax, 0xa0(%rsp)
callq 0x766c
leaq 0x118(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x9bc4
leaq 0x58(%rsp), %rdi
leaq 0x118(%rsp), %rdx
movl %ebx, %esi
callq 0x7f78
leaq 0x118(%rsp), %rdi
callq 0x115da
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rbp
movaps %xmm0, (%rbp)
andq $0x0, 0x10(%rbp)
movq 0x58(%rsp), %r12
movq 0x60(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0xa8(%rsp), %r15
leaq 0x38(%rsp), %r13
leaq 0xa0(%rsp), %r14
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq 0x88(%rsp), %r12
je 0x8f36
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rcx
je 0x8dac
movq 0x48(%r12), %rax
subq 0x40(%r12), %rax
sarq $0x5, %rax
cmpq %rax, %rcx
je 0x8dac
movzbl 0x17(%rsp), %esi
movq %rbp, %rdi
callq 0x800e
movq %rbp, %rdi
callq 0xa740
movq 0x48(%r12), %rbx
movq 0x40(%r12), %rax
subq %rax, %rbx
je 0x8f77
cmpb $0x1, 0x1f472(%rip)     # 0x28238
jne 0x8df1
movq %r15, %rdi
movq %r12, %rsi
callq 0xa748
movq 0xa8(%rsp), %rsi
leaq 0x12c59(%rip), %rdi     # 0x1ba3b
xorl %eax, %eax
callq 0x6050
movq %r15, %rdi
callq 0x6140
movq %r15, %rdi
callq 0x106ce
sarq $0x5, %rbx
movq %rbx, 0x90(%rsp)
movq 0x40(%r12), %rbx
movq %r12, 0x40(%rsp)
movq 0x48(%r12), %r12
movq %r12, %rax
subq %rbx, %rax
sarq $0x5, %rax
movq %rax, 0x108(%rsp)
andq $0x0, 0x110(%rsp)
movq %rax, 0xf8(%rsp)
andq $0x0, 0x100(%rsp)
cmpq %r12, %rbx
je 0x8e8f
movq %r15, %rdi
callq 0xa802
movq %rax, 0x38(%rsp)
movq %rbx, 0x98(%rsp)
leaq 0x17(%rsp), %rax
movq %rax, (%rsp)
movq %r15, %rdi
movq %r13, %rsi
leaq 0x108(%rsp), %rdx
leaq 0xf8(%rsp), %rcx
leaq 0x98(%rsp), %r8
movq %r14, %r9
callq 0xa7b0
addq $0x20, %rbx
jmp 0x8e40
movq 0x40(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0xa812
movq 0xb8(%rsp), %rbp
movq 0xc8(%rsp), %rbx
movq 0xd0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xd8(%rsp), %r12
cmpq %r12, %rbp
je 0x8f13
addq $0x78, %rbp
movq %rbp, %rdi
callq 0x65d0
movq 0x78(%rsp), %rdi
addq $-0x18, %rdi
addq $-0x60, %rbp
movq %rbp, %rsi
callq 0xa83c
addq $0x68, %rbp
cmpq %rbx, %rbp
jne 0x8ec9
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rbp
addq $0x8, %rax
movq %rax, 0x30(%rsp)
leaq 0x200(%rbp), %rbx
jmp 0x8ec9
movq %r15, %rdi
callq 0xa866
movq 0x40(%rsp), %r12
addq $0x58, %r12
leaq 0x70(%rsp), %rbp
movq 0x90(%rsp), %rcx
jmp 0x8d6c
movzbl 0x17(%rsp), %esi
leaq 0x70(%rsp), %rdi
callq 0x800e
leaq 0x70(%rsp), %rdi
callq 0xa8b2
leaq 0x58(%rsp), %rdi
callq 0x99fa
leaq 0x18(%rsp), %rdi
callq 0x115da
xorl %eax, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12a8b(%rip), %rdi     # 0x1ba09
leaq 0x1271d(%rip), %rsi     # 0x1b6a2
leaq 0x12a98(%rip), %rcx     # 0x1ba24
movl $0x355, %edx            # imm = 0x355
callq 0x6220
leaq 0x13ac7(%rip), %rdi     # 0x1ca64
jmp 0x8fb0
callq 0x858f
jmp 0x9054
leaq 0x13a7c(%rip), %rdi     # 0x1ca2c
callq 0x6520
pushq $0x1
popq %rdi
callq 0x63f0
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
jmp 0x9004
jmp 0x9010
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
jmp 0x8feb
jmp 0x9010
jmp 0x90e2
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x115da
jmp 0x910d
jmp 0x9010
jmp 0x9010
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0x6140
jmp 0x910d
jmp 0x9010
movq %rax, %rbx
jmp 0x910d
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x905b
movq %rbx, %rdi
callq 0x6110
leaq 0x1e371(%rip), %rsi     # 0x273a0
leaq 0xa8(%rsp), %rdi
callq 0xa63a
leaq 0xa8(%rsp), %rbx
movq (%rbx), %rdi
callq 0x6520
movq %rbx, %rdi
callq 0x6140
xorl %edi, %edi
callq 0x63f0
cmpl $0x1, %edx
jne 0x9117
movq %rbx, %rdi
callq 0x6110
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
leaq 0x127c1(%rip), %rdi     # 0x1b83d
movq %rax, %rsi
xorl %eax, %eax
callq 0x6050
leaq 0x1e313(%rip), %rsi     # 0x273a0
leaq 0xa8(%rsp), %rdi
callq 0xa63a
leaq 0xa8(%rsp), %rbx
movq (%rbx), %rsi
leaq 0x127b4(%rip), %rdi     # 0x1b860
xorl %eax, %eax
callq 0x6050
movq %rbx, %rdi
callq 0x6140
jmp 0x8fb5
movq %rax, %rbx
callq 0x65a0
jmp 0x9117
movq %rax, %rbx
callq 0x65a0
jmp 0x9117
movq %rax, %rdi
callq 0xa6a0
jmp 0x90e2
jmp 0x90e2
jmp 0x90e9
movq %rax, %rbx
jmp 0x90f9
jmp 0x90e9
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0xa866
leaq 0x70(%rsp), %rdi
callq 0xa8b2
leaq 0x58(%rsp), %rdi
callq 0x99fa
leaq 0x18(%rsp), %rdi
callq 0x115da
movq %rbx, %rdi
callq 0x65f0