#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, int);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
int sched_getcpu();
int sched_setaffinity(int /*<<< orphan*/, int, int /*<<< orphan*/ *);
void *runner(void *p) {
  int r;
  cpu_set_t cpu_set;
  CPU_ZERO(&cpu_set);
  CPU_SET(3, &cpu_set);
  CPU_SET(2, &cpu_set);
  r = sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set);
  while (1)
    printf("Esta é a execucao da Thread %d na CPU=%d; afinidade=%d\n",
           (int)(size_t)p, sched_getcpu(), r);
  pthread_exit(NULL);
}


x86 assembly (clang, -O0):
<runner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <CPU_ZERO@plt>
mov    $0x3,%edi
lea    -0x10(%rbp),%rsi
call   1070 <CPU_SET@plt>
mov    $0x2,%edi
lea    -0x10(%rbp),%rsi
call   1070 <CPU_SET@plt>
xor    %edi,%edi
mov    $0x4,%esi
lea    -0x10(%rbp),%rdx
call   1040 <sched_setaffinity@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <sched_getcpu@plt>
mov    -0x14(%rbp),%esi
mov    %eax,%edx
mov    -0xc(%rbp),%ecx
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
jmp    1194 <runner+0x44>

x86 assembly (clang, -O2):
<runner>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <CPU_ZERO@plt>
mov    $0x3,%edi
mov    %rbp,%rsi
call   1070 <CPU_SET@plt>
mov    $0x2,%edi
mov    %rbp,%rsi
call   1070 <CPU_SET@plt>
xor    %edi,%edi
mov    $0x4,%esi
mov    %rbp,%rdx
call   1040 <sched_setaffinity@plt>
mov    %eax,%ebp
lea    0xe66(%rip),%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <sched_getcpu@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
mov    %ebp,%ecx
call   1030 <printf@plt>
jmp    11a0 <runner+0x50>

LLVM IR (-O0):
@.str = [57 x i8] c"Esta \C3\A9 a execucao da Thread %d na CPU=%d; afinidade=%d\0A\00"
define i8* @runner(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @CPU_ZERO(i32* %4)
%6 = call i32 @CPU_SET(i32 3, i32* %4)
%7 = call i32 @CPU_SET(i32 2, i32* %4)
%8 = call i32 @sched_setaffinity(i32 0, i32 4, i32* %4)
store i32 %8, i32* %3
br label %9
9: ; preds = %1, %9
%10 = load i8*, i8** %2
%11 = ptrtoint i8* %10 to i64
%12 = trunc i64 %11 to i32
%13 = call i32 (...) @sched_getcpu()
%14 = load i32, i32* %3
%15 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13, i32 %14)
br label %9
}

LLVM IR (-O2):
@.str = [57 x i8] c"Esta \C3\A9 a execucao da Thread %d na CPU=%d; afinidade=%d\0A\00"
define noalias i8* @runner(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @CPU_ZERO(i32* %2)
%5 = call i32 @CPU_SET(i32 3, i32* %2)
%6 = call i32 @CPU_SET(i32 2, i32* %2)
%7 = call i32 @sched_setaffinity(i32 0, i32 4, i32* %2)
%8 = ptrtoint i8* %0 to i64
%9 = trunc i64 %8 to i32
br label %10
10: ; preds = %10, %1
%11 = call i32 (...) @sched_getcpu()
%12 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11, i32 %7)
br label %10
}