#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;
};

/* Variables and functions */
scalar_t__ EINVAL;
int /*<<< orphan*/ abort();
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ printf(char *);
scalar_t__ sched_setparam(int /*<<< orphan*/, struct sched_param *);
int main(void) {
  struct sched_param sb;
  sb.sched_priority = 0;
  if (sched_setparam(getpid(), &sb) != 0 || sb.sched_priority != 0)
    abort();
  sb.sched_priority = 5;
  if (sched_setparam(getpid(), &sb) == 0 || errno != EINVAL ||
      sb.sched_priority != 5)
    abort();
  printf("pass\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%edi
lea    -0x8(%rbp),%rsi
call   1060 <sched_setparam@plt>
cmp    $0x0,%rax
jne    118c <main+0x3c>
cmpl   $0x0,-0x8(%rbp)
je     1193 <main+0x43>
mov    $0x0,%al
call   1030 <abort@plt>
movl   $0x5,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%edi
lea    -0x8(%rbp),%rsi
call   1060 <sched_setparam@plt>
cmp    $0x0,%rax
je     11da <main+0x8a>
mov    0x2e23(%rip),%rax
mov    (%rax),%rax
mov    0x2e11(%rip),%rcx
cmp    (%rcx),%rax
jne    11da <main+0x8a>
cmpl   $0x5,-0x8(%rbp)
je     11e1 <main+0x91>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xe18(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,(%rsp)
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %rsp,%rsi
mov    %eax,%edi
call   1060 <sched_setparam@plt>
test   %rax,%rax
jne    11c0 <main+0x70>
cmpl   $0x0,(%rsp)
jne    11c0 <main+0x70>
movl   $0x5,(%rsp)
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %rsp,%rsi
mov    %eax,%edi
call   1060 <sched_setparam@plt>
test   %rax,%rax
je     11c0 <main+0x70>
mov    0x2e48(%rip),%rax
mov    (%rax),%rax
mov    0x2e36(%rip),%rcx
cmp    (%rcx),%rax
jne    11c0 <main+0x70>
cmpl   $0x5,(%rsp)
jne    11c0 <main+0x70>
lea    0xe4c(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>
xor    %eax,%eax
call   1030 <abort@plt>

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