#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_SET(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int sched_setaffinity(int /*<<< orphan*/, int, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i, ret;
  cpu_set_t set;
  CPU_SET(0, &set);
  ret = sched_setaffinity(0, sizeof(cpu_set_t), &set);
  if (ret == -1)
    perror("sched_setaffinity()");
  i = 0;
  while (1) {
    i++;
    printf("%d\n", i);
  }
}


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)
xor    %edi,%edi
lea    -0x1c(%rbp),%rsi
call   1060 <CPU_SET@plt>
xor    %edi,%edi
mov    $0x4,%esi
lea    -0x1c(%rbp),%rdx
call   1040 <sched_setaffinity@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    118a <main+0x4a>
lea    0xe7b(%rip),%rdi
call   1050 <perror@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    1191 <main+0x51>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <CPU_SET@plt>
xor    %edi,%edi
mov    $0x4,%esi
mov    %rbx,%rdx
call   1040 <sched_setaffinity@plt>
cmp    $0xffffffff,%eax
je     118f <main+0x4f>
mov    $0x1,%ebx
lea    0xea1(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
jmp    1180 <main+0x40>
lea    0xe6a(%rip),%rdi
call   1050 <perror@plt>
jmp    1167 <main+0x27>

LLVM IR (-O0):
@.str = [20 x i8] c"sched_setaffinity()\00"
@.str.1 = [4 x i8] c"%d\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 = call i32 @CPU_SET(i32 0, i32* %8)
%10 = call i32 @sched_setaffinity(i32 0, i32 4, i32* %8)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
store i32 0, i32* %6
br label %16
16: ; preds = %15, %16
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %16
}

LLVM IR (-O2):
@.str = [20 x i8] c"sched_setaffinity()\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @CPU_SET(i32 0, i32* %3)
%6 = call i32 @sched_setaffinity(i32 0, i32 4, i32* %3)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
br label %11
11: ; preds = %10, %11
%12 = phi i32 [ %13, %11 ], [ 0, %10 ]
%13 = add nuw nsw i32 %12, 1
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %11
}