#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 uint8_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ cpu_set_t;

/* Variables and functions */
scalar_t__ CPU_ISSET(int, int /*<<< orphan*/ *);
int getpid();
int /*<<< orphan*/ printf(char *, ...);
void print_cpu_mask(cpu_set_t cpu_mask) {
  uint8_t flag;
  uint32_t i;
  printf("%d Cpu affinity is ", getpid());
  flag = 0;
  for (i = 0; i < sizeof(cpu_set_t); i++) {
    if (CPU_ISSET(i, &cpu_mask)) {
      if (flag == 0) {
        flag = 1;
        printf("%d", i);
      } else {
        printf(",%d", i);
      }
    }
  }
  printf(".\n");
}


x86 assembly (clang, -O0):
<print_cpu_mask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
cmp    $0x4,%rax
jae    11d4 <print_cpu_mask+0xa4>
mov    -0xc(%rbp),%edi
lea    -0x4(%rbp),%rsi
call   1050 <CPU_ISSET@plt>
cmp    $0x0,%rax
je     11c1 <print_cpu_mask+0x91>
cmpl   $0x0,-0x8(%rbp)
jne    11ab <print_cpu_mask+0x7b>
movl   $0x1,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bc <print_cpu_mask+0x8c>
mov    -0xc(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c1 <print_cpu_mask+0x91>
jmp    11c6 <print_cpu_mask+0x96>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1160 <print_cpu_mask+0x30>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cpu_mask>:
push   %rax
mov    %edi,0x4(%rsp)
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xead(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
xor    %edi,%edi
call   1060 <CPU_ISSET@plt>
test   %rax,%rax
je     119a <print_cpu_mask+0x5a>
lea    0xea1(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
mov    $0x1,%edi
call   1060 <CPU_ISSET@plt>
test   %rax,%rax
je     11c1 <print_cpu_mask+0x81>
lea    0xe7c(%rip),%rdi
jmp    11b5 <print_cpu_mask+0x75>
lea    0x4(%rsp),%rsi
mov    $0x1,%edi
call   1060 <CPU_ISSET@plt>
test   %rax,%rax
je     121d <print_cpu_mask+0xdd>
lea    0xe60(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
mov    $0x2,%edi
call   1060 <CPU_ISSET@plt>
test   %rax,%rax
je     11e8 <print_cpu_mask+0xa8>
lea    0xe38(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
mov    $0x3,%edi
call   1060 <CPU_ISSET@plt>
test   %rax,%rax
je     120f <print_cpu_mask+0xcf>
lea    0xe11(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe02(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret
lea    0x4(%rsp),%rsi
mov    $0x2,%edi
call   1060 <CPU_ISSET@plt>
test   %rax,%rax
je     123a <print_cpu_mask+0xfa>
lea    0xddd(%rip),%rdi
jmp    11dc <print_cpu_mask+0x9c>
lea    0x4(%rsp),%rsi
mov    $0x3,%edi
call   1060 <CPU_ISSET@plt>
test   %rax,%rax
je     120f <print_cpu_mask+0xcf>
lea    0xdc0(%rip),%rdi
jmp    1203 <print_cpu_mask+0xc3>

LLVM IR (-O0):
@.str = [20 x i8] c"%d Cpu affinity is \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c",%d\00"
@.str.3 = [3 x i8] c".\0A\00"
define void @print_cpu_mask(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 (...) @getpid()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 0, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %26, %1
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 4
br i1 %10, label %11, label %29
11: ; preds = %7
%12 = load i32, i32* %4
%13 = call i64 @CPU_ISSET(i32 %12, i32* %2)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
store i32 1, i32* %3
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %24
21: ; preds = %15
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %21, %18
br label %25
25: ; preds = %24, %11
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %7
29: ; preds = %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"%d Cpu affinity is \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c",%d\00"
@str = [2 x i8] c".\00"
define void @print_cpu_mask(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i64 @CPU_ISSET(i32 0, i32* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i64 @CPU_ISSET(i32 1, i32* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %20, label %14
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0)
%12 = call i64 @CPU_ISSET(i32 1, i32* %2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %7, %10
%15 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %7 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15, i32 1)
br label %17
17: ; preds = %14, %10
%18 = call i64 @CPU_ISSET(i32 2, i32* %2)
%19 = icmp eq i64 %18, 0
br i1 %19, label %26, label %23
20: ; preds = %7
%21 = call i64 @CPU_ISSET(i32 2, i32* %2)
%22 = icmp eq i64 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %20, %17
%24 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %17 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %20 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %24, i32 2)
br label %26
26: ; preds = %23, %17
%27 = call i64 @CPU_ISSET(i32 3, i32* %2)
%28 = icmp eq i64 %27, 0
br i1 %28, label %35, label %32
29: ; preds = %20
%30 = call i64 @CPU_ISSET(i32 3, i32* %2)
%31 = icmp eq i64 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %29, %26
%33 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %26 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %29 ]
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %33, i32 3)
br label %35
35: ; preds = %32, %29, %26
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}