#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*/ SCHED_FIFO;
int /*<<< orphan*/ SCHED_OTHER;
int /*<<< orphan*/ SCHED_RR;
int /*<<< orphan*/ printf(char *, ...);
int sched_get_priority_max(int /*<<< orphan*/);
int sched_get_priority_min(int /*<<< orphan*/);
void show_min_max(void) {
  int max, min;
  max = sched_get_priority_max(SCHED_FIFO);
  min = sched_get_priority_min(SCHED_FIFO);
  if (max >= 0 && min >= 0)
    printf("SCHED_FIFO min/max priority\t: %d/%d\n", min, max);
  else
    printf("SCHED_FIFO not supported?\n");
  max = sched_get_priority_max(SCHED_RR);
  min = sched_get_priority_min(SCHED_RR);
  if (max >= 0 && min >= 0)
    printf("SCHED_RR min/max priority\t: %d/%d\n", min, max);
  else
    printf("SCHED_RR not supported?\n");
  max = sched_get_priority_max(SCHED_OTHER);
  min = sched_get_priority_min(SCHED_OTHER);
  if (max >= 0 && min >= 0)
    printf("SCHED_OTHER min/max priority\t: %d/%d\n", min, max);
  else
    printf("SCHED_OTHER not supported?\n");
}


x86 assembly (clang, -O0):
<show_min_max>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
call   1050 <sched_get_priority_max@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
call   1040 <sched_get_priority_min@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1187 <show_min_max+0x57>
cmpl   $0x0,-0x8(%rbp)
jl     1187 <show_min_max+0x57>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1195 <show_min_max+0x65>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1050 <sched_get_priority_max@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1040 <sched_get_priority_min@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     11e4 <show_min_max+0xb4>
cmpl   $0x0,-0x8(%rbp)
jl     11e4 <show_min_max+0xb4>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <show_min_max+0xc2>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1050 <sched_get_priority_max@plt>
mov    %eax,-0x4(%rbp)
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1040 <sched_get_priority_min@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1241 <show_min_max+0x111>
cmpl   $0x0,-0x8(%rbp)
jl     1241 <show_min_max+0x111>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124f <show_min_max+0x11f>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_min_max>:
push   %r14
push   %rbx
push   %rax
mov    0x2e9d(%rip),%r14
mov    (%r14),%edi
call   1060 <sched_get_priority_max@plt>
mov    %eax,%ebx
mov    (%r14),%edi
call   1050 <sched_get_priority_min@plt>
test   %ebx,%ebx
js     1179 <show_min_max+0x39>
test   %eax,%eax
js     1179 <show_min_max+0x39>
lea    0xe94(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1185 <show_min_max+0x45>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e3c(%rip),%r14
mov    (%r14),%edi
call   1060 <sched_get_priority_max@plt>
mov    %eax,%ebx
mov    (%r14),%edi
call   1050 <sched_get_priority_min@plt>
test   %ebx,%ebx
js     11ba <show_min_max+0x7a>
test   %eax,%eax
js     11ba <show_min_max+0x7a>
lea    0xe78(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c6 <show_min_max+0x86>
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e0b(%rip),%r14
mov    (%r14),%edi
call   1060 <sched_get_priority_max@plt>
mov    %eax,%ebx
mov    (%r14),%edi
call   1050 <sched_get_priority_min@plt>
test   %ebx,%ebx
js     1200 <show_min_max+0xc0>
test   %eax,%eax
js     1200 <show_min_max+0xc0>
lea    0xe5a(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>
lea    0xe99(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
@SCHED_FIFO = global i32 0
@.str = [37 x i8] c"SCHED_FIFO min/max priority\09: %d/%d\0A\00"
@.str.1 = [27 x i8] c"SCHED_FIFO not supported?\0A\00"
@SCHED_RR = global i32 0
@.str.2 = [35 x i8] c"SCHED_RR min/max priority\09: %d/%d\0A\00"
@.str.3 = [25 x i8] c"SCHED_RR not supported?\0A\00"
@SCHED_OTHER = global i32 0
@.str.4 = [38 x i8] c"SCHED_OTHER min/max priority\09: %d/%d\0A\00"
@.str.5 = [28 x i8] c"SCHED_OTHER not supported?\0A\00"
define void @show_min_max() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @SCHED_FIFO
%4 = call i32 @sched_get_priority_max(i32 %3)
store i32 %4, i32* %1
%5 = load i32, i32* @SCHED_FIFO
%6 = call i32 @sched_get_priority_min(i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* %1
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* %2
%14 = load i32, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
br label %18
16: ; preds = %9, %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
%19 = load i32, i32* @SCHED_RR
%20 = call i32 @sched_get_priority_max(i32 %19)
store i32 %20, i32* %1
%21 = load i32, i32* @SCHED_RR
%22 = call i32 @sched_get_priority_min(i32 %21)
store i32 %22, i32* %2
%23 = load i32, i32* %1
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %18
%26 = load i32, i32* %2
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* %2
%30 = load i32, i32* %1
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %30)
br label %34
32: ; preds = %25, %18
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
%35 = load i32, i32* @SCHED_OTHER
%36 = call i32 @sched_get_priority_max(i32 %35)
store i32 %36, i32* %1
%37 = load i32, i32* @SCHED_OTHER
%38 = call i32 @sched_get_priority_min(i32 %37)
store i32 %38, i32* %2
%39 = load i32, i32* %1
%40 = icmp sge i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %34
%42 = load i32, i32* %2
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i32, i32* %2
%46 = load i32, i32* %1
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %45, i32 %46)
br label %50
48: ; preds = %41, %34
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %50
50: ; preds = %48, %44
ret void
}

LLVM IR (-O2):
@SCHED_FIFO = global i32 0
@.str = [37 x i8] c"SCHED_FIFO min/max priority\09: %d/%d\0A\00"
@SCHED_RR = global i32 0
@.str.2 = [35 x i8] c"SCHED_RR min/max priority\09: %d/%d\0A\00"
@SCHED_OTHER = global i32 0
@.str.4 = [38 x i8] c"SCHED_OTHER min/max priority\09: %d/%d\0A\00"
@str = [26 x i8] c"SCHED_FIFO not supported?\00"
@str.6 = [24 x i8] c"SCHED_RR not supported?\00"
@str.7 = [27 x i8] c"SCHED_OTHER not supported?\00"
define void @show_min_max() {
%1 = load i32, i32* @SCHED_FIFO
%2 = tail call i32 @sched_get_priority_max(i32 %1)
%3 = load i32, i32* @SCHED_FIFO
%4 = tail call i32 @sched_get_priority_min(i32 %3)
%5 = icmp sgt i32 %2, -1
%6 = icmp sgt i32 %4, -1
%7 = select i1 %5, i1 %6, i1 false
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %2)
br label %12
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = load i32, i32* @SCHED_RR
%14 = tail call i32 @sched_get_priority_max(i32 %13)
%15 = load i32, i32* @SCHED_RR
%16 = tail call i32 @sched_get_priority_min(i32 %15)
%17 = icmp sgt i32 %14, -1
%18 = icmp sgt i32 %16, -1
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %14)
br label %24
22: ; preds = %12
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
%25 = load i32, i32* @SCHED_OTHER
%26 = tail call i32 @sched_get_priority_max(i32 %25)
%27 = load i32, i32* @SCHED_OTHER
%28 = tail call i32 @sched_get_priority_min(i32 %27)
%29 = icmp sgt i32 %26, -1
%30 = icmp sgt i32 %28, -1
%31 = select i1 %29, i1 %30, i1 false
br i1 %31, label %32, label %34
32: ; preds = %24
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %28, i32 %26)
br label %36
34: ; preds = %24
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
ret void
}