#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;

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, double);
scalar_t__ sched_setaffinity(int /*<<< orphan*/, int, unsigned long *);
double waste_time(int);
int main(int argc, char **argv) {
  unsigned long mask = 1;
  if (sched_setaffinity(0, sizeof(mask), &mask) < 0) {
    perror("sched_setaffinity");
  }
  printf("result: %f\n", waste_time(2000));
  mask = 2;
  if (sched_setaffinity(0, sizeof(mask), &mask) < 0) {
    perror("sched_setaffinity");
  }
  printf("result: %f\n", waste_time(2000));
}


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)
movq   $0x1,-0x18(%rbp)
xor    %edi,%edi
mov    $0x8,%esi
lea    -0x18(%rbp),%rdx
call   1040 <sched_setaffinity@plt>
cmp    $0x0,%rax
jge    1184 <main+0x44>
lea    0xe81(%rip),%rdi
call   1060 <perror@plt>
mov    $0x7d0,%edi
call   1050 <waste_time@plt>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
movq   $0x2,-0x18(%rbp)
xor    %edi,%edi
mov    $0x8,%esi
lea    -0x18(%rbp),%rdx
call   1040 <sched_setaffinity@plt>
cmp    $0x0,%rax
jge    11c8 <main+0x88>
lea    0xe3d(%rip),%rdi
call   1060 <perror@plt>
mov    $0x7d0,%edi
call   1050 <waste_time@plt>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movq   $0x1,(%rsp)
mov    %rsp,%rdx
xor    %edi,%edi
mov    $0x8,%esi
call   1040 <sched_setaffinity@plt>
test   %rax,%rax
js     11a9 <main+0x69>
mov    $0x7d0,%edi
call   1050 <waste_time@plt>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
movq   $0x2,(%rsp)
mov    %rsp,%rdx
xor    %edi,%edi
mov    $0x8,%esi
call   1040 <sched_setaffinity@plt>
test   %rax,%rax
js     11b7 <main+0x77>
mov    $0x7d0,%edi
call   1050 <waste_time@plt>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe50(%rip),%rdi
call   1060 <perror@plt>
jmp    115d <main+0x1d>
lea    0xe42(%rip),%rdi
call   1060 <perror@plt>
jmp    118f <main+0x4f>

LLVM IR (-O0):
@.str = [18 x i8] c"sched_setaffinity\00"
@.str.1 = [12 x i8] c"result: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1, i64* %6
%7 = call i64 @sched_setaffinity(i32 0, i32 8, i64* %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = call double @waste_time(i32 2000)
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %12)
store i64 2, i64* %6
%14 = call i64 @sched_setaffinity(i32 0, i32 8, i64* %6)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = call double @waste_time(i32 2000)
%20 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %19)
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [18 x i8] c"sched_setaffinity\00"
@.str.1 = [12 x i8] c"result: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 1, i64* %3
%5 = call i64 @sched_setaffinity(i32 0, i32 8, i64* %3)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = call double @waste_time(i32 2000)
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %10)
store i64 2, i64* %3
%12 = call i64 @sched_setaffinity(i32 0, i32 8, i64* %3)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %9
%17 = call double @waste_time(i32 2000)
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %17)
ret i32 0
}