#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 */
struct sched_param {
  int sched_priority;
};
typedef int /*<<< orphan*/ pthread_attr_t;

/* Variables and functions */
int PTHREAD_EXPLICIT_SCHED;
int SCHED_RR;
int errno;
int /*<<< orphan*/ printf(char *, ...);
int pthread_attr_getinheritsched(int /*<<< orphan*/ *, int *);
int pthread_attr_getschedparam(int /*<<< orphan*/ *, struct sched_param *);
int pthread_attr_getschedpolicy(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ puts(char *);
int verify_sched_result(pthread_attr_t *attr) {
  int inherited, policy;
  struct sched_param param;
  ({
    int ret = pthread_attr_getinheritsched(attr, &inherited);
    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",
             212, "pthread_attr_getinheritsched", ret, errno);
      return ret;
    }
  });
  if (inherited != PTHREAD_EXPLICIT_SCHED) {
    puts("failed to set EXPLICIT_SCHED (%d != %d)");
    return 1;
  }
  ({
    int ret = pthread_attr_getschedpolicy(attr, &policy);
    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",
             219, "pthread_attr_getschedpolicy", ret, errno);
      return ret;
    }
  });
  if (policy != SCHED_RR) {
    printf("failed to set SCHED_RR (%d != %d)\n", policy, SCHED_RR);
    return 1;
  }
  ({
    int ret = pthread_attr_getschedparam(attr, &param);
    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",
             226, "pthread_attr_getschedparam", ret, errno);
      return ret;
    }
  });
  if (param.sched_priority != 42) {
    printf("failed to set sched_priority (%d != %d)\n", param.sched_priority,
           42);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<verify_sched_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <pthread_attr_getinheritsched@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11b0 <verify_sched_result+0x60>
mov    -0x24(%rbp),%r8d
mov    0x2e57(%rip),%rax
mov    (%rax),%r9d
lea    0xe75(%rip),%rdi
lea    0xe92(%rip),%rsi
mov    $0xd4,%edx
lea    0xf21(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12ed <verify_sched_result+0x19d>
mov    -0x14(%rbp),%eax
mov    0x2e2e(%rip),%rcx
cmp    (%rcx),%eax
je     11da <verify_sched_result+0x8a>
lea    0xf13(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ed <verify_sched_result+0x19d>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <pthread_attr_getschedpolicy@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     122e <verify_sched_result+0xde>
mov    -0x28(%rbp),%r8d
mov    0x2dd9(%rip),%rax
mov    (%rax),%r9d
lea    0xdf7(%rip),%rdi
lea    0xe14(%rip),%rsi
mov    $0xdb,%edx
lea    0xee8(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12ed <verify_sched_result+0x19d>
mov    -0x18(%rbp),%eax
mov    0x2d90(%rip),%rcx
cmp    (%rcx),%eax
je     1266 <verify_sched_result+0x116>
mov    -0x18(%rbp),%esi
mov    0x2d7e(%rip),%rax
mov    (%rax),%edx
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ed <verify_sched_result+0x19d>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <pthread_attr_getschedparam@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     12ba <verify_sched_result+0x16a>
mov    -0x2c(%rbp),%r8d
mov    0x2d4d(%rip),%rax
mov    (%rax),%r9d
lea    0xd6b(%rip),%rdi
lea    0xd88(%rip),%rsi
mov    $0xe2,%edx
lea    0xe9b(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12ed <verify_sched_result+0x19d>
cmpl   $0x2a,-0x20(%rbp)
je     12e6 <verify_sched_result+0x196>
mov    -0x20(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x2a,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ed <verify_sched_result+0x19d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_sched_result>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0x14(%rsp),%rsi
call   1060 <pthread_attr_getinheritsched@plt>
test   %eax,%eax
je     119a <verify_sched_result+0x4a>
mov    %eax,%ebx
mov    0x2e67(%rip),%rax
mov    (%rax),%r9d
lea    0xe85(%rip),%rdi
lea    0xea2(%rip),%rsi
lea    0xf36(%rip),%rcx
mov    $0xd4,%edx
mov    %ebx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f3 <verify_sched_result+0xa3>
mov    0x14(%rsp),%eax
mov    0x2e43(%rip),%rcx
cmp    (%rcx),%eax
jne    11e2 <verify_sched_result+0x92>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1070 <pthread_attr_getschedpolicy@plt>
test   %eax,%eax
je     11fd <verify_sched_result+0xad>
mov    %eax,%ebx
mov    0x2e15(%rip),%rax
mov    (%rax),%r9d
lea    0xe33(%rip),%rdi
lea    0xe50(%rip),%rsi
lea    0xf29(%rip),%rcx
mov    $0xdb,%edx
jmp    118e <verify_sched_result+0x3e>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    0x10(%rsp),%esi
mov    0x2dc0(%rip),%rax
mov    (%rax),%edx
cmp    %edx,%esi
jne    124a <verify_sched_result+0xfa>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1050 <pthread_attr_getschedparam@plt>
test   %eax,%eax
je     125a <verify_sched_result+0x10a>
mov    %eax,%ebx
mov    0x2db0(%rip),%rax
mov    (%rax),%r9d
lea    0xdce(%rip),%rdi
lea    0xdeb(%rip),%rsi
lea    0xf03(%rip),%rcx
mov    $0xe2,%edx
jmp    118e <verify_sched_result+0x3e>
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ee <verify_sched_result+0x9e>
mov    0x8(%rsp),%esi
xor    %ebx,%ebx
cmp    $0x2a,%esi
je     11f3 <verify_sched_result+0xa3>
lea    0xef2(%rip),%rdi
mov    $0x2a,%edx
jmp    1251 <verify_sched_result+0x101>

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@.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 = [29 x i8] c"pthread_attr_getinheritsched\00"
@errno = global i32 0
@PTHREAD_EXPLICIT_SCHED = global i32 0
@.str.3 = [40 x i8] c"failed to set EXPLICIT_SCHED (%d != %d)\00"
@.str.4 = [28 x i8] c"pthread_attr_getschedpolicy\00"
@SCHED_RR = global i32 0
@.str.5 = [35 x i8] c"failed to set SCHED_RR (%d != %d)\0A\00"
@.str.6 = [27 x i8] c"pthread_attr_getschedparam\00"
@.str.7 = [41 x i8] c"failed to set sched_priority (%d != %d)\0A\00"
define i32 @verify_sched_result(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sched_param
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %3
%10 = load i32*, i32** %3
%11 = call i32 @pthread_attr_getinheritsched(i32* %10, i32* %4)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %1
%15 = load i32, i32* %7
%16 = load i32, i32* @errno
%17 = call i32 (i8*, ...) @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 212, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %16)
%18 = load i32, i32* %7
store i32 %18, i32* %2
br label %62
19: ; preds = %1
%20 = load i32, i32* %4
%21 = load i32, i32* @PTHREAD_EXPLICIT_SCHED
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @puts(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %62
25: ; preds = %19
%26 = load i32*, i32** %3
%27 = call i32 @pthread_attr_getschedpolicy(i32* %26, i32* %5)
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i32, i32* %8
%32 = load i32, i32* @errno
%33 = call i32 (i8*, ...) @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 219, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 %32)
%34 = load i32, i32* %8
store i32 %34, i32* %2
br label %62
35: ; preds = %25
%36 = load i32, i32* %5
%37 = load i32, i32* @SCHED_RR
%38 = icmp ne i32 %36, %37
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* %5
%41 = load i32, i32* @SCHED_RR
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %40, i32 %41)
store i32 1, i32* %2
br label %62
43: ; preds = %35
%44 = load i32*, i32** %3
%45 = call i32 @pthread_attr_getschedparam(i32* %44, %struct.sched_param* %6)
store i32 %45, i32* %9
%46 = load i32, i32* %9
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = load i32, i32* %9
%50 = load i32, i32* @errno
%51 = call i32 (i8*, ...) @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 226, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %49, i32 %50)
%52 = load i32, i32* %9
store i32 %52, i32* %2
br label %62
53: ; preds = %43
%54 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %6, i32 0, i32 0
%55 = load i32, i32* %54
%56 = icmp ne i32 %55, 42
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %6, i32 0, i32 0
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i32 %59, i32 42)
store i32 1, i32* %2
br label %62
61: ; preds = %53
store i32 0, i32* %2
br label %62
62: ; preds = %61, %57, %48, %39, %30, %23, %14
%63 = load i32, i32* %2
ret i32 %63
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@.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 = [29 x i8] c"pthread_attr_getinheritsched\00"
@errno = global i32 0
@PTHREAD_EXPLICIT_SCHED = global i32 0
@.str.3 = [40 x i8] c"failed to set EXPLICIT_SCHED (%d != %d)\00"
@.str.4 = [28 x i8] c"pthread_attr_getschedpolicy\00"
@SCHED_RR = global i32 0
@.str.5 = [35 x i8] c"failed to set SCHED_RR (%d != %d)\0A\00"
@.str.6 = [27 x i8] c"pthread_attr_getschedparam\00"
@.str.7 = [41 x i8] c"failed to set sched_priority (%d != %d)\0A\00"
define i32 @verify_sched_result(i32* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sched_param
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast %struct.sched_param* %4 to i8*
%8 = call i32 @pthread_attr_getinheritsched(i32* %0, i32* %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = load i32, i32* @errno
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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 212, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %11)
br label %43
13: ; preds = %1
%14 = load i32, i32* %2
%15 = load i32, i32* @PTHREAD_EXPLICIT_SCHED
%16 = icmp eq i32 %14, %15
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
br label %43
19: ; preds = %13
%20 = call i32 @pthread_attr_getschedpolicy(i32* %0, i32* %3)
%21 = icmp eq i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i32, i32* @errno
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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 219, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %20, i32 %23)
br label %43
25: ; preds = %19
%26 = load i32, i32* %3
%27 = load i32, i32* @SCHED_RR
%28 = icmp eq i32 %26, %27
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %26, i32 %27)
br label %43
31: ; preds = %25
%32 = call i32 @pthread_attr_getschedparam(i32* %0, %struct.sched_param* %4)
%33 = icmp eq i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* @errno
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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 226, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %32, i32 %35)
br label %43
37: ; preds = %31
%38 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %4, i64 0, i32 0
%39 = load i32, i32* %38
%40 = icmp eq i32 %39, 42
br i1 %40, label %43, label %41
41: ; preds = %37
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i32 %39, i32 42)
br label %43
43: ; preds = %34, %22, %10, %37, %41, %29, %17
%44 = phi i32 [ 1, %17 ], [ 1, %29 ], [ 1, %41 ], [ %32, %34 ], [ %20, %22 ], [ %8, %10 ], [ 0, %37 ]
ret i32 %44
}