#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 CPU_ISSET(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ CPU_SET(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ CPU_ZERO(int /*<<< orphan*/ *);
int sched_getaffinity(int /*<<< orphan*/, int, int /*<<< orphan*/ *);
int sched_setaffinity(int /*<<< orphan*/, int, int /*<<< orphan*/ *);
int main(void) {
  cpu_set_t mask;
  int rc;
  CPU_ZERO(&mask);
  CPU_SET(0, &mask);
  rc = sched_setaffinity(0, sizeof(mask), &mask);
  (void)rc;
  rc = sched_getaffinity(0, sizeof(mask), &mask);
  if (rc == 0) {
    rc = CPU_ISSET(0, &mask);
    (void)rc;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <CPU_ZERO@plt>
xor    %edi,%edi
lea    -0x8(%rbp),%rsi
call   1070 <CPU_SET@plt>
xor    %edi,%edi
mov    $0x4,%esi
lea    -0x8(%rbp),%rdx
call   1030 <sched_setaffinity@plt>
mov    %eax,-0xc(%rbp)
xor    %edi,%edi
mov    $0x4,%esi
lea    -0x8(%rbp),%rdx
call   1060 <sched_getaffinity@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11b1 <main+0x61>
xor    %edi,%edi
lea    -0x8(%rbp),%rsi
call   1040 <CPU_ISSET@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <CPU_ZERO@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1070 <CPU_SET@plt>
xor    %edi,%edi
mov    $0x4,%esi
mov    %rbx,%rdx
call   1030 <sched_setaffinity@plt>
xor    %edi,%edi
mov    $0x4,%esi
mov    %rbx,%rdx
call   1060 <sched_getaffinity@plt>
test   %eax,%eax
jne    119a <main+0x4a>
lea    0xc(%rsp),%rsi
xor    %edi,%edi
call   1040 <CPU_ISSET@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @CPU_ZERO(i32* %2)
%5 = call i32 @CPU_SET(i32 0, i32* %2)
%6 = call i32 @sched_setaffinity(i32 0, i32 4, i32* %2)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = call i32 @sched_getaffinity(i32 0, i32 4, i32* %2)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 @CPU_ISSET(i32 0, i32* %2)
store i32 %12, i32* %3
%13 = load i32, i32* %3
br label %14
14: ; preds = %11, %0
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @CPU_ZERO(i32* %1)
%4 = call i32 @CPU_SET(i32 0, i32* %1)
%5 = call i32 @sched_setaffinity(i32 0, i32 4, i32* %1)
%6 = call i32 @sched_getaffinity(i32 0, i32 4, i32* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @CPU_ISSET(i32 0, i32* %1)
br label %10
10: ; preds = %8, %0
ret i32 0
}