#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 {
  scalar_t__ sched_priority;
};

/* Variables and functions */
int SCHED_OTHER;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
scalar_t__ pthread_getschedparam(int /*<<< orphan*/, int *,
                                 struct sched_param *);
int /*<<< orphan*/ pthread_self();
scalar_t__ pthread_setschedparam(int /*<<< orphan*/, int, struct sched_param *);
int main(void) {
  struct sched_param param;
  int policy;
  if (pthread_getschedparam(pthread_self(), &policy, &param) != 0 ||
      policy != SCHED_OTHER || param.sched_priority != 0)
    abort();
  if (pthread_setschedparam(pthread_self(), SCHED_OTHER, &param) != 0 ||
      param.sched_priority != 0)
    abort();
  printf("pass\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <pthread_self@plt>
mov    %eax,%edi
lea    -0x14(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <pthread_getschedparam@plt>
cmp    $0x0,%rax
jne    11ac <main+0x4c>
mov    -0x14(%rbp),%eax
mov    0x2e47(%rip),%rcx
cmp    (%rcx),%eax
jne    11ac <main+0x4c>
cmpq   $0x0,-0x10(%rbp)
je     11b3 <main+0x53>
mov    $0x0,%al
call   1030 <abort@plt>
mov    $0x0,%al
call   1070 <pthread_self@plt>
mov    %eax,%edi
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <pthread_setschedparam@plt>
cmp    $0x0,%rax
jne    11e3 <main+0x83>
cmpq   $0x0,-0x10(%rbp)
je     11ea <main+0x8a>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xe0f(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <pthread_self@plt>
lea    0xc(%rsp),%rsi
mov    %rsp,%rdx
mov    %eax,%edi
call   1060 <pthread_getschedparam@plt>
test   %rax,%rax
jne    11af <main+0x4f>
mov    0xc(%rsp),%eax
mov    0x2e55(%rip),%rbx
cmp    (%rbx),%eax
jne    11af <main+0x4f>
cmpq   $0x0,(%rsp)
jne    11af <main+0x4f>
xor    %eax,%eax
call   1070 <pthread_self@plt>
mov    (%rbx),%esi
mov    %rsp,%rdx
mov    %eax,%edi
call   1050 <pthread_setschedparam@plt>
or     (%rsp),%rax
je     11b6 <main+0x56>
xor    %eax,%eax
call   1030 <abort@plt>
lea    0xe43(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.sched_param = type { i64 }
@SCHED_OTHER = global i32 0
@.str = [6 x i8] c"pass\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sched_param
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @pthread_self()
%5 = call i64 @pthread_getschedparam(i32 %4, i32* %3, %struct.sched_param* %2)
%6 = icmp ne i64 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %0
%8 = load i32, i32* %3
%9 = load i32, i32* @SCHED_OTHER
%10 = icmp ne i32 %8, %9
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %2, i32 0, i32 0
%13 = load i64, i64* %12
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11, %7, %0
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %11
%18 = call i32 (...) @pthread_self()
%19 = load i32, i32* @SCHED_OTHER
%20 = call i64 @pthread_setschedparam(i32 %18, i32 %19, %struct.sched_param* %2)
%21 = icmp ne i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %17
%23 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %2, i32 0, i32 0
%24 = load i64, i64* %23
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22, %17
%27 = call i32 (...) @abort()
unreachable
28: ; preds = %22
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sched_param = type { i64 }
@SCHED_OTHER = global i32 0
@str = [5 x i8] c"pass\00"
define i32 @main() {
%1 = alloca %struct.sched_param
%2 = alloca i32
%3 = bitcast %struct.sched_param* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @pthread_self()
%6 = call i64 @pthread_getschedparam(i32 %5, i32* %2, %struct.sched_param* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %0
%9 = load i32, i32* %2
%10 = load i32, i32* @SCHED_OTHER
%11 = icmp ne i32 %9, %10
%12 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i64 0, i32 0
%13 = load i64, i64* %12
%14 = icmp ne i64 %13, 0
%15 = select i1 %11, i1 true, i1 %14
br i1 %15, label %16, label %18
16: ; preds = %8, %0
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %8
%19 = call i32 (...) @pthread_self()
%20 = load i32, i32* @SCHED_OTHER
%21 = call i64 @pthread_setschedparam(i32 %19, i32 %20, %struct.sched_param* %1)
%22 = icmp ne i64 %21, 0
%23 = load i64, i64* %12
%24 = icmp ne i64 %23, 0
%25 = select i1 %22, i1 true, i1 %24
br i1 %25, label %26, label %28
26: ; preds = %18
%27 = call i32 (...) @abort()
unreachable
28: ; preds = %18
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%30 = call i32 @exit(i32 0)
unreachable
}