#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ mask;
typedef int /*<<< orphan*/ cpu_set_t;

/* Variables and functions */
int /*<<< orphan*/ CPU_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ CPU_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ _SC_NPROCESSORS_ONLN;
int /*<<< orphan*/ sched_setaffinity(int /*<<< orphan*/, int,
                                     int /*<<< orphan*/ *);
int sysconf(int /*<<< orphan*/);
void core_set_no_affinity() {
  cpu_set_t mask;
  int cpu_count;
  int i;
  CPU_ZERO(&mask);
  cpu_count = sysconf(_SC_NPROCESSORS_ONLN);
  for (i = 0; i < cpu_count; ++i) {
    CPU_SET(i, &mask);
  }
  sched_setaffinity(0, sizeof(mask), &mask);
}


x86 assembly (clang, -O0):
<core_set_no_affinity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1040 <CPU_ZERO@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118f <core_set_no_affinity+0x4f>
mov    -0xc(%rbp),%edi
lea    -0x4(%rbp),%rsi
call   1060 <CPU_SET@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1169 <core_set_no_affinity+0x29>
xor    %edi,%edi
mov    $0x4,%esi
lea    -0x4(%rbp),%rdx
call   1030 <sched_setaffinity@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<core_set_no_affinity>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1040 <CPU_ZERO@plt>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
test   %eax,%eax
jle    1181 <core_set_no_affinity+0x41>
mov    %eax,%ebx
xor    %ebp,%ebp
lea    0xc(%rsp),%r14
nopl   (%rax)
mov    %ebp,%edi
mov    %r14,%rsi
call   1060 <CPU_SET@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1170 <core_set_no_affinity+0x30>
lea    0xc(%rsp),%rdx
xor    %edi,%edi
mov    $0x4,%esi
call   1030 <sched_setaffinity@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@_SC_NPROCESSORS_ONLN = global i32 0
define void @core_set_no_affinity() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @CPU_ZERO(i32* %1)
%5 = load i32, i32* @_SC_NPROCESSORS_ONLN
%6 = call i32 @sysconf(i32 %5)
store i32 %6, i32* %2
store i32 0, i32* %3
br label %7
7: ; preds = %14, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i32, i32* %3
%13 = call i32 @CPU_SET(i32 %12, i32* %1)
br label %14
14: ; preds = %11
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %7
17: ; preds = %7
%18 = call i32 @sched_setaffinity(i32 0, i32 4, i32* %1)
ret void
}

LLVM IR (-O2):
@_SC_NPROCESSORS_ONLN = global i32 0
define void @core_set_no_affinity() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @CPU_ZERO(i32* %1)
%4 = load i32, i32* @_SC_NPROCESSORS_ONLN
%5 = call i32 @sysconf(i32 %4)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0, %7
%8 = phi i32 [ %10, %7 ], [ 0, %0 ]
%9 = call i32 @CPU_SET(i32 %8, i32* %1)
%10 = add nuw nsw i32 %8, 1
%11 = icmp eq i32 %10, %5
br i1 %11, label %12, label %7
12: ; preds = %7, %0
%13 = call i32 @sched_setaffinity(i32 0, i32 4, i32* %1)
ret void
}