#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*/ atoi(char *);
int /*<<< orphan*/ perror(char *);
unsigned long pow(int, int /*<<< orphan*/);
scalar_t__ sched_setaffinity(int /*<<< orphan*/, unsigned int, unsigned long *);
int main(int argc, char *argv[]) {
  unsigned long mask;
  unsigned int len = sizeof(mask);
  if (argv[1] != NULL) {
    mask = pow(2, atoi(argv[1]));
    if (sched_setaffinity(0, len, &mask) < 0) {
      perror("sched_setaffinity");
    }
  }
  while (1)
    ;
  return 0;
}


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)
movl   $0x8,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11b2 <main+0x72>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%esi
mov    $0x2,%edi
call   1040 <pow@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%esi
xor    %edi,%edi
lea    -0x18(%rbp),%rdx
call   1030 <sched_setaffinity@plt>
cmp    $0x0,%rax
jge    11ad <main+0x6d>
lea    0xe58(%rip),%rdi
call   1050 <perror@plt>
jmp    11b2 <main+0x72>
jmp    11b7 <main+0x77>
jmp    11b7 <main+0x77>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     1180 <main+0x40>
call   1060 <atoi@plt>
mov    $0x2,%edi
mov    %eax,%esi
call   1040 <pow@plt>
mov    %rax,(%rsp)
mov    %rsp,%rdx
xor    %edi,%edi
mov    $0x8,%esi
call   1030 <sched_setaffinity@plt>
test   %rax,%rax
js     1182 <main+0x42>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
jmp    1180 <main+0x40>
lea    0xe77(%rip),%rdi
call   1050 <perror@plt>
jmp    1180 <main+0x40>

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

LLVM IR (-O2):
@.str = [18 x i8] c"sched_setaffinity\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %15, label %8
8: ; preds = %2
%9 = tail call i32 @atoi(i8* %6)
%10 = tail call i64 @pow(i32 2, i32 %9)
store i64 %10, i64* %3
%11 = call i64 @sched_setaffinity(i32 0, i32 8, i64* %3)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %8, %13, %2
br label %16
16: ; preds = %15, %16
br label %16
}