#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_ALLOC(int);
int /*<<< orphan*/ CPU_FREE(int /*<<< orphan*/ *);
scalar_t__ CPU_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ _SC_NPROCESSORS_ONLN;
int /*<<< orphan*/ no_omp_cpu(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int sysconf(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int i, num_cpu = sysconf(_SC_NPROCESSORS_ONLN);
  cpu_set_t *no_omp = CPU_ALLOC(num_cpu);
  no_omp_cpu(num_cpu, no_omp);
  printf("Free cpu list: ");
  for (i = 0; i < num_cpu; ++i) {
    if (CPU_ISSET(i, no_omp)) {
      printf("%i ", i);
    }
  }
  printf("\n\n");
  CPU_FREE(no_omp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1080 <sysconf@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <CPU_ALLOC@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1060 <no_omp_cpu@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11fa <main+0x9a>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <CPU_ISSET@plt>
cmp    $0x0,%rax
je     11e7 <main+0x87>
mov    -0x14(%rbp),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ec <main+0x8c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b4 <main+0x54>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <CPU_FREE@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1090 <sysconf@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <CPU_ALLOC@plt>
mov    %rax,%r15
mov    %ebp,%edi
mov    %rax,%rsi
call   1070 <no_omp_cpu@plt>
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jle    11e4 <main+0x74>
lea    0xe5c(%rip),%r14
xor    %ebx,%ebx
jmp    11c7 <main+0x57>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%ebp
je     11e4 <main+0x74>
mov    %ebx,%edi
mov    %r15,%rsi
call   1060 <CPU_ISSET@plt>
test   %rax,%rax
je     11c0 <main+0x50>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c0 <main+0x50>
lea    0xe29(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1080 <CPU_FREE@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@_SC_NPROCESSORS_ONLN = global i32 0
@.str = [16 x i8] c"Free cpu list: \00"
@.str.1 = [4 x i8] c"%i \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @_SC_NPROCESSORS_ONLN
%10 = call i32 @sysconf(i32 %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = call i32* @CPU_ALLOC(i32 %11)
store i32* %12, i32** %8
%13 = load i32, i32* %7
%14 = load i32*, i32** %8
%15 = call i32 @no_omp_cpu(i32 %13, i32* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %17
17: ; preds = %30, %2
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load i32, i32* %6
%23 = load i32*, i32** %8
%24 = call i64 @CPU_ISSET(i32 %22, i32* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i32, i32* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %21
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %17
33: ; preds = %17
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32*, i32** %8
%36 = call i32 @CPU_FREE(i32* %35)
ret i32 0
}

LLVM IR (-O2):
@_SC_NPROCESSORS_ONLN = global i32 0
@.str = [16 x i8] c"Free cpu list: \00"
@.str.1 = [4 x i8] c"%i \00"
@str = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @_SC_NPROCESSORS_ONLN
%4 = tail call i32 @sysconf(i32 %3)
%5 = tail call i32* @CPU_ALLOC(i32 %4)
%6 = tail call i32 @no_omp_cpu(i32 %4, i32* %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = icmp sgt i32 %4, 0
br i1 %8, label %9, label %18
9: ; preds = %2, %15
%10 = phi i32 [ %16, %15 ], [ 0, %2 ]
%11 = tail call i64 @CPU_ISSET(i32 %10, i32* %5)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %15
15: ; preds = %9, %13
%16 = add nuw nsw i32 %10, 1
%17 = icmp eq i32 %16, %4
br i1 %17, label %18, label %9
18: ; preds = %15, %2
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%20 = tail call i32 @CPU_FREE(i32* %5)
ret i32 0
}