#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*/ cpu_set_t;

/* Variables and functions */
int /*<<< orphan*/ CPU_CLR(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ CPU_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ assert(int);
int sched_getcpu();
void no_omp_cpu(int num_cpu, cpu_set_t *no_omp) {
  int cpu_index, i;
  for (i = 0; i < num_cpu; ++i) {
    CPU_SET(i, no_omp);
  }
#pragma omp parallel default(shared)
  {
#pragma omp critical
    {
      cpu_index = sched_getcpu();
      assert(cpu_index < num_cpu);
      CPU_CLR(cpu_index, no_omp);
    }
  }
}


x86 assembly (clang, -O0):
<no_omp_cpu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117c <no_omp_cpu+0x3c>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <CPU_SET@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1156 <no_omp_cpu+0x16>
mov    $0x0,%al
call   1040 <sched_getcpu@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <CPU_CLR@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<no_omp_cpu>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
test   %edi,%edi
jle    1161 <no_omp_cpu+0x21>
xor    %ebx,%ebx
nop
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <CPU_SET@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1150 <no_omp_cpu+0x10>
xor    %eax,%eax
call   1040 <sched_getcpu@plt>
mov    %eax,%ebx
xor    %edi,%edi
cmp    %ebp,%eax
setl   %dil
call   1030 <assert@plt>
mov    %ebx,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <CPU_CLR@plt>

LLVM IR (-O0):
define void @no_omp_cpu(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 0, i32* %6
br label %7
7: ; preds = %15, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load i32, i32* %6
%13 = load i32*, i32** %4
%14 = call i32 @CPU_SET(i32 %12, i32* %13)
br label %15
15: ; preds = %11
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %7
18: ; preds = %7
%19 = call i32 (...) @sched_getcpu()
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = load i32, i32* %3
%22 = icmp slt i32 %20, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %5
%26 = load i32*, i32** %4
%27 = call i32 @CPU_CLR(i32 %25, i32* %26)
ret void
}

LLVM IR (-O2):
define void @no_omp_cpu(i32 %0, i32* %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %9
4: ; preds = %2, %4
%5 = phi i32 [ %7, %4 ], [ 0, %2 ]
%6 = tail call i32 @CPU_SET(i32 %5, i32* %1)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, %0
br i1 %8, label %9, label %4
9: ; preds = %4, %2
%10 = tail call i32 (...) @sched_getcpu()
%11 = icmp slt i32 %10, %0
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32 @CPU_CLR(i32 %10, i32* %1)
ret void
}