// File: /workspace/github_cpp_makefile_star2_O1/travisdowns[P]avx-turbo/avx-turbo.cpp
// Function: filter_cpus(std::vector<int, std::allocator<int>>)
std::vector<int> filter_cpus(std::vector<int> cpus) {
    int shift = get_smt_shift();
    if (shift == -1) {
        printf("Can't use cpuid leaf 0xb to filter out hyperthreads, CPU too old or AMD\n");
        return cpus;
    }
    cpu_set_t original_set;
    if (sched_getaffinity(0, sizeof(original_set), &original_set)) {
        err(EXIT_FAILURE, "failed while getting cpu affinity");
    }
    std::vector<int> filtered_cpus;
    std::set<uint32_t> coreid_set;
    for (int cpu : cpus) {
        cpu_set_t cpuset;
        CPU_ZERO(&cpuset);
        CPU_SET(cpu, &cpuset);
        if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset)) {
            err(EXIT_FAILURE, "failed to sched_setaffinity in filter_cpus");
        }
        cpuid_result leafb = cpuid(0xb);
        uint32_t apicid = leafb.edx, coreid = apicid >> shift;
        if (verbose) printf("cpu %d has x2apic ID %u, coreid %u\n", cpu, apicid, coreid);
        if (coreid_set.insert(coreid).second) {
            filtered_cpus.push_back(cpu);
        }
    }
    // restore original affinity
    sched_setaffinity(0, sizeof(cpu_set_t), &original_set);
    return filtered_cpus;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, %r14
movq %rdi, %rbx
callq 0x1625d
cmpl $-0x1, %eax
je 0x9913
movl %eax, %ebp
leaq 0xc8(%rsp), %rdx
movl $0x80, %esi
xorl %edi, %edi
callq 0x64e0
testl %eax, %eax
jne 0x996c
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
xorl %eax, %eax
movq %rax, 0x10(%rbx)
leaq 0x18(%rsp), %rcx
movl $0x0, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq (%r14), %r15
movq 0x8(%r14), %r14
cmpq %r14, %r15
je 0x98f3
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %r13
movl (%r15), %ecx
movl %ecx, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
cmpq $0x3ff, %rcx            # imm = 0x3FF
ja 0x9861
movl $0x1, %eax
shlq %cl, %rax
shrl $0x6, %ecx
orq %rax, 0x40(%rsp,%rcx,8)
movl $0x80, %esi
xorl %edi, %edi
leaq 0x40(%rsp), %rdx
callq 0x62b0
testl %eax, %eax
jne 0x9959
movl $0xb, %edi
callq 0x15eaa
shrq $0x20, %rdx
movl %edx, %eax
movl %ebp, %ecx
shrl %cl, %eax
movl %eax, 0xc(%rsp)
cmpb $0x1, 0x1f97f(%rip)     # 0x29218
jne 0x98af
movl 0x8(%rsp), %esi
leaq 0x14f44(%rip), %rdi     # 0x1e7ea
movl %eax, %ecx
xorl %eax, %eax
callq 0x6050
movq %r12, %rdi
movq %r13, %rsi
callq 0x1426c
testb $0x1, %dl
je 0x98e6
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x98d9
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x98e6
movq %rbx, %rdi
leaq 0x8(%rsp), %rdx
callq 0x14154
addq $0x4, %r15
cmpq %r14, %r15
jne 0x980a
leaq 0xc8(%rsp), %rdx
movl $0x80, %esi
xorl %edi, %edi
callq 0x62b0
leaq 0x10(%rsp), %rdi
callq 0xf3bc
jmp 0x9944
leaq 0x1609b(%rip), %rdi     # 0x1f9b5
callq 0x6500
movq (%r14), %rax
movq %rax, (%rbx)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rbx)
movq 0x10(%r14), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movq %rbx, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14e5f(%rip), %rsi     # 0x1e7bf
movl $0x1, %edi
xorl %eax, %eax
callq 0x62f0
leaq 0x14e2a(%rip), %rsi     # 0x1e79d
movl $0x1, %edi
xorl %eax, %eax
callq 0x62f0
jmp 0x9985
jmp 0x9985
jmp 0x9985
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0xf3bc
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x999f
callq 0x6320
movq %r14, %rdi
callq 0x65f0