#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, int /*<<< orphan*/ *);
int /*<<< orphan*/ CPU_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sched_setaffinity(int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
void *main_thread_1(void *arg) {
  int i;
  cpu_set_t mask;
  CPU_ZERO(&mask);
  CPU_SET(*((int *)arg), &mask);
  sched_setaffinity(1, sizeof(cpu_set_t), &mask);
  i = 0;
  while (true) {
    printf("1 %d\n", i);
    sleep(1);
    i++;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<main_thread_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <CPU_ZERO@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1060 <CPU_SET@plt>
mov    $0x1,%edi
mov    $0x4,%esi
lea    -0x10(%rbp),%rdx
call   1040 <sched_setaffinity@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    %eax,-0xc(%rbp)
jmp    118e <main_thread_1+0x3e>

x86 assembly (clang, -O2):
<main_thread_1>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1050 <CPU_ZERO@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
call   1060 <CPU_SET@plt>
mov    $0x1,%edi
mov    $0x4,%esi
mov    %r14,%rdx
call   1040 <sched_setaffinity@plt>
xor    %ebx,%ebx
lea    0xe77(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
add    $0x1,%ebx
jmp    1190 <main_thread_1+0x40>

LLVM IR (-O0):
@.str = [6 x i8] c"1 %d\0A\00"
define i8* @main_thread_1(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @CPU_ZERO(i32* %4)
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
%9 = call i32 @CPU_SET(i32 %8, i32* %4)
%10 = call i32 @sched_setaffinity(i32 1, i32 4, i32* %4)
store i32 0, i32* %3
br label %11
11: ; preds = %1, %11
%12 = load i32, i32* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call i32 @sleep(i32 1)
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %11
}

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