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

/* Variables and functions */
int /*<<< orphan*/ CPU_ISSET(int /*<<< orphan*/, int /*<<< orphan*/ *);
int errno;
int /*<<< orphan*/ printf(char *, char *, int, char *, int, int);
int pthread_attr_getaffinity_np(int /*<<< orphan*/ *, int,
                                int /*<<< orphan*/ *);
int /*<<< orphan*/ puts(char *);
int verify_affinity_result(pthread_attr_t *attr) {
  cpu_set_t cpuset;
  ({
    int ret = pthread_attr_getaffinity_np(attr, sizeof(cpuset), &cpuset);
    if (ret != 0) {
      printf("%s:%d: %s returned %d (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/Phant0mas/glibc-hurd/refs/heads/"
             "baseline/nptl/tst-default-attr.c",
             168, "pthread_attr_getaffinity_np", ret, errno);
      return ret;
    }
  });
  if (!CPU_ISSET(0, &cpuset)) {
    puts("failed to set cpu affinity");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<verify_affinity_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
lea    -0x14(%rbp),%rdx
call   1060 <pthread_attr_getaffinity_np@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11a3 <verify_affinity_result+0x63>
mov    -0x18(%rbp),%r8d
mov    0x2e6a(%rip),%rax
mov    (%rax),%r9d
lea    0xe80(%rip),%rdi
lea    0xe9d(%rip),%rsi
mov    $0xa8,%edx
lea    0xf2c(%rip),%rcx
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d6 <verify_affinity_result+0x96>
xor    %edi,%edi
lea    -0x14(%rbp),%rsi
call   1050 <CPU_ISSET@plt>
cmp    $0x0,%eax
jne    11cf <verify_affinity_result+0x8f>
lea    0xf1d(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <verify_affinity_result+0x96>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_affinity_result>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdx
mov    $0x4,%esi
call   1060 <pthread_attr_getaffinity_np@plt>
test   %eax,%eax
je     1188 <verify_affinity_result+0x48>
mov    %eax,%ebx
mov    0x2e7f(%rip),%rax
mov    (%rax),%r9d
lea    0xe95(%rip),%rdi
lea    0xeb2(%rip),%rsi
lea    0xf46(%rip),%rcx
mov    $0xa8,%edx
mov    %ebx,%r8d
call   1040 <printf@plt>
jmp    11ab <verify_affinity_result+0x6b>
xor    %ebx,%ebx
lea    0xc(%rsp),%rsi
xor    %edi,%edi
call   1050 <CPU_ISSET@plt>
test   %eax,%eax
jne    11ab <verify_affinity_result+0x6b>
lea    0xf3a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"%s:%d: %s returned %d (errno = %d)\0A\00"
@.str.1 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Phant0mas/glibc-hurd/refs/heads/baseline/nptl/tst-default-attr.c\00"
@.str.2 = [28 x i8] c"pthread_attr_getaffinity_np\00"
@errno = global i32 0
@.str.3 = [27 x i8] c"failed to set cpu affinity\00"
define i32 @verify_affinity_result(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @pthread_attr_getaffinity_np(i32* %6, i32 4, i32* %4)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32, i32* %5
%12 = load i32, i32* @errno
%13 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 168, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* %5
store i32 %14, i32* %2
br label %21
15: ; preds = %1
%16 = call i32 @CPU_ISSET(i32 0, i32* %4)
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %21
20: ; preds = %15
store i32 0, i32* %2
br label %21
21: ; preds = %20, %18, %10
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [36 x i8] c"%s:%d: %s returned %d (errno = %d)\0A\00"
@.str.1 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Phant0mas/glibc-hurd/refs/heads/baseline/nptl/tst-default-attr.c\00"
@.str.2 = [28 x i8] c"pthread_attr_getaffinity_np\00"
@errno = global i32 0
@.str.3 = [27 x i8] c"failed to set cpu affinity\00"
define i32 @verify_affinity_result(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @pthread_attr_getaffinity_np(i32* %0, i32 4, i32* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 168, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %7)
br label %14
9: ; preds = %1
%10 = call i32 @CPU_ISSET(i32 0, i32* %2)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %6, %9, %12
%15 = phi i32 [ 1, %12 ], [ %4, %6 ], [ 0, %9 ]
ret i32 %15
}