#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 */

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sched_get_priority_max;
int /*<<< orphan*/ sched_get_priority_min;
scalar_t__ sched_yield();
scalar_t__ test_min_max(int /*<<< orphan*/, char *);
scalar_t__ test_rr_interval();
scalar_t__ test_schedparam();
scalar_t__ test_scheduler();
int sched_test(void) {
  if (test_min_max(sched_get_priority_max, "sched_get_priority_max") < 0) {
    printf("sched_get_priority_max() test failed\n");
    return -1;
  }
  if (test_min_max(sched_get_priority_min, "sched_get_priority_min") < 0) {
    printf("sched_get_priority_max() test failed\n");
    return -1;
  }
  if (test_schedparam() < 0) {
    printf("sched_get_priority_max() test failed\n");
    return -1;
  }
  if (test_scheduler() < 0) {
    printf("sched_get_priority_max() test failed\n");
    return -1;
  }
  if (sched_yield() < 0) {
    perror("failed to yield");
    return -1;
  }
  if (test_rr_interval() < 0) {
    printf("sched_get_priority_max() test failed\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<sched_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1070 <test_min_max@plt>
cmp    $0x0,%rax
jge    11af <sched_test+0x3f>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <sched_test+0x121>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
call   1070 <test_min_max@plt>
cmp    $0x0,%rax
jge    11e6 <sched_test+0x76>
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <sched_test+0x121>
mov    $0x0,%al
call   1050 <test_schedparam@plt>
cmp    $0x0,%rax
jge    120f <sched_test+0x9f>
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <sched_test+0x121>
mov    $0x0,%al
call   1030 <test_scheduler@plt>
cmp    $0x0,%rax
jge    1238 <sched_test+0xc8>
lea    0xdf0(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <sched_test+0x121>
mov    $0x0,%al
call   1060 <sched_yield@plt>
cmp    $0x0,%rax
jge    1261 <sched_test+0xf1>
lea    0xe04(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <sched_test+0x121>
mov    $0x0,%al
call   1090 <test_rr_interval@plt>
cmp    $0x0,%rax
jge    128a <sched_test+0x11a>
lea    0xd9e(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <sched_test+0x121>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sched_test>:
push   %rbx
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1070 <test_min_max@plt>
test   %rax,%rax
js     11d7 <sched_test+0x67>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
call   1070 <test_min_max@plt>
test   %rax,%rax
js     11d7 <sched_test+0x67>
xor    %eax,%eax
call   1050 <test_schedparam@plt>
test   %rax,%rax
js     11d7 <sched_test+0x67>
xor    %eax,%eax
call   1030 <test_scheduler@plt>
test   %rax,%rax
js     11d7 <sched_test+0x67>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <sched_yield@plt>
test   %rax,%rax
js     11ec <sched_test+0x7c>
xor    %eax,%eax
call   1090 <test_rr_interval@plt>
test   %rax,%rax
jns    11e8 <sched_test+0x78>
lea    0xe60(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe3b(%rip),%rdi
call   1080 <perror@plt>
jmp    11e3 <sched_test+0x73>

LLVM IR (-O0):
@sched_get_priority_max = global i32 0
@.str = [23 x i8] c"sched_get_priority_max\00"
@.str.1 = [38 x i8] c"sched_get_priority_max() test failed\0A\00"
@sched_get_priority_min = global i32 0
@.str.2 = [23 x i8] c"sched_get_priority_min\00"
@.str.3 = [16 x i8] c"failed to yield\00"
define i32 @sched_test() {
%1 = alloca i32
%2 = load i32, i32* @sched_get_priority_max
%3 = call i64 @test_min_max(i32 %2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %34
7: ; preds = %0
%8 = load i32, i32* @sched_get_priority_min
%9 = call i64 @test_min_max(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %34
13: ; preds = %7
%14 = call i64 (...) @test_schedparam()
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %34
18: ; preds = %13
%19 = call i64 (...) @test_scheduler()
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %34
23: ; preds = %18
%24 = call i64 (...) @sched_yield()
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %34
28: ; preds = %23
%29 = call i64 (...) @test_rr_interval()
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %34
33: ; preds = %28
store i32 0, i32* %1
br label %34
34: ; preds = %33, %31, %26, %21, %16, %11, %5
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@sched_get_priority_max = global i32 0
@.str = [23 x i8] c"sched_get_priority_max\00"
@sched_get_priority_min = global i32 0
@.str.2 = [23 x i8] c"sched_get_priority_min\00"
@.str.3 = [16 x i8] c"failed to yield\00"
@str.7 = [37 x i8] c"sched_get_priority_max() test failed\00"
define i32 @sched_test() {
%1 = load i32, i32* @sched_get_priority_max
%2 = tail call i64 @test_min_max(i32 %1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %32
6: ; preds = %0
%7 = load i32, i32* @sched_get_priority_min
%8 = tail call i64 @test_min_max(i32 %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %32
12: ; preds = %6
%13 = tail call i64 (...) @test_schedparam()
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %32
17: ; preds = %12
%18 = tail call i64 (...) @test_scheduler()
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %32
22: ; preds = %17
%23 = tail call i64 (...) @sched_yield()
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %32
27: ; preds = %22
%28 = tail call i64 (...) @test_rr_interval()
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %32
32: ; preds = %27, %30, %25, %20, %15, %10, %4
%33 = phi i32 [ -1, %4 ], [ -1, %10 ], [ -1, %15 ], [ -1, %20 ], [ -1, %25 ], [ -1, %30 ], [ 0, %27 ]
ret i32 %33
}