#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 */
int /*<<< orphan*/ PRIO_PROCESS;
int SCHED_FIFO;
int SCHED_OTHER;
int SCHED_RR;
int getpriority(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int sched_get_priority_max(int);
int sched_get_priority_min(int);
int /*<<< orphan*/ sched_getparam(int, struct sched_param *);
int sched_getscheduler(int);
int main() {
  int i = 0;
  int politica, nice;
  struct sched_param p;
  politica = sched_getscheduler(i);
  sched_getparam(i, &p);
  nice = getpriority(PRIO_PROCESS, i);
  if (politica == SCHED_FIFO)
    printf("Política: SCHED_FIFO\n");
  else if (politica == SCHED_RR)
    printf("Política: SCHED_RR\n");
  else if (politica == SCHED_OTHER)
    printf("Política: SCHED_OTHER\n");
  printf("Prioridad del proceso: %d\n", p.sched_priority);
  printf("Nice del proceso: %d\n", nice);
  printf("Valor máximo de prioridad: %d\n", sched_get_priority_max(politica));
  printf("Valor mínimo de prioridad: %d\n", sched_get_priority_min(politica));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1060 <sched_getparam@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
call   1040 <getpriority@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e3d(%rip),%rcx
cmp    (%rcx),%eax
jne    11c6 <main+0x66>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1215 <main+0xb5>
mov    -0xc(%rbp),%eax
mov    0x2df0(%rip),%rcx
cmp    (%rcx),%eax
jne    11eb <main+0x8b>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1210 <main+0xb0>
mov    -0xc(%rbp),%eax
mov    0x2ddb(%rip),%rcx
cmp    (%rcx),%eax
jne    120b <main+0xab>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1210 <main+0xb0>
jmp    1215 <main+0xb5>
mov    -0x18(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
call   1080 <sched_get_priority_max@plt>
mov    %eax,%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
call   1070 <sched_get_priority_min@plt>
mov    %eax,%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,%ebx
mov    %rsp,%rsi
xor    %edi,%edi
call   1070 <sched_getparam@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <getpriority@plt>
mov    %eax,%ebp
mov    0x2e49(%rip),%rax
cmp    (%rax),%ebx
jne    11ac <main+0x3c>
lea    0xef2(%rip),%rdi
jmp    11d2 <main+0x62>
mov    0x2e0d(%rip),%rax
cmp    (%rax),%ebx
jne    11c0 <main+0x50>
lea    0xeca(%rip),%rdi
jmp    11d2 <main+0x62>
mov    0x2e09(%rip),%rax
cmp    (%rax),%ebx
jne    11d7 <main+0x67>
lea    0xe9f(%rip),%rdi
call   1050 <puts@plt>
mov    (%rsp),%esi
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe2c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1090 <sched_get_priority_max@plt>
lea    0xe2b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1080 <sched_get_priority_min@plt>
lea    0xe34(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@PRIO_PROCESS = global i32 0
@SCHED_FIFO = global i32 0
@.str = [23 x i8] c"Pol\C3\ADtica: SCHED_FIFO\0A\00"
@SCHED_RR = global i32 0
@.str.1 = [21 x i8] c"Pol\C3\ADtica: SCHED_RR\0A\00"
@SCHED_OTHER = global i32 0
@.str.2 = [24 x i8] c"Pol\C3\ADtica: SCHED_OTHER\0A\00"
@.str.3 = [27 x i8] c"Prioridad del proceso: %d\0A\00"
@.str.4 = [22 x i8] c"Nice del proceso: %d\0A\00"
@.str.5 = [32 x i8] c"Valor m\C3\A1ximo de prioridad: %d\0A\00"
@.str.6 = [32 x i8] c"Valor m\C3\ADnimo de prioridad: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sched_param
store i32 0, i32* %1
store i32 0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @sched_getscheduler(i32 %6)
store i32 %7, i32* %3
%8 = load i32, i32* %2
%9 = call i32 @sched_getparam(i32 %8, %struct.sched_param* %5)
%10 = load i32, i32* @PRIO_PROCESS
%11 = load i32, i32* %2
%12 = call i32 @getpriority(i32 %10, i32 %11)
store i32 %12, i32* %4
%13 = load i32, i32* %3
%14 = load i32, i32* @SCHED_FIFO
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %32
18: ; preds = %0
%19 = load i32, i32* %3
%20 = load i32, i32* @SCHED_RR
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %31
24: ; preds = %18
%25 = load i32, i32* %3
%26 = load i32, i32* @SCHED_OTHER
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
br label %31
31: ; preds = %30, %22
br label %32
32: ; preds = %31, %16
%33 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %5, i32 0, i32 0
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %3
%39 = call i32 @sched_get_priority_max(i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %3
%42 = call i32 @sched_get_priority_min(i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %42)
ret i32 0
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@PRIO_PROCESS = global i32 0
@SCHED_FIFO = global i32 0
@SCHED_RR = global i32 0
@SCHED_OTHER = global i32 0
@.str.3 = [27 x i8] c"Prioridad del proceso: %d\0A\00"
@.str.4 = [22 x i8] c"Nice del proceso: %d\0A\00"
@.str.5 = [32 x i8] c"Valor m\C3\A1ximo de prioridad: %d\0A\00"
@.str.6 = [32 x i8] c"Valor m\C3\ADnimo de prioridad: %d\0A\00"
@str = [23 x i8] c"Pol\C3\ADtica: SCHED_OTHER\00"
@str.7 = [20 x i8] c"Pol\C3\ADtica: SCHED_RR\00"
@str.8 = [22 x i8] c"Pol\C3\ADtica: SCHED_FIFO\00"
define i32 @main() {
%1 = alloca %struct.sched_param
%2 = bitcast %struct.sched_param* %1 to i8*
%3 = tail call i32 @sched_getscheduler(i32 0)
%4 = call i32 @sched_getparam(i32 0, %struct.sched_param* %1)
%5 = load i32, i32* @PRIO_PROCESS
%6 = call i32 @getpriority(i32 %5, i32 0)
%7 = load i32, i32* @SCHED_FIFO
%8 = icmp eq i32 %3, %7
br i1 %8, label %15, label %9
9: ; preds = %0
%10 = load i32, i32* @SCHED_RR
%11 = icmp eq i32 %3, %10
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* @SCHED_OTHER
%14 = icmp eq i32 %3, %13
br i1 %14, label %15, label %18
15: ; preds = %12, %9, %0
%16 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0), %0 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0), %9 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0), %12 ]
%17 = call i32 @puts(i8* dereferenceable(1) %16)
br label %18
18: ; preds = %15, %12
%19 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i64 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %6)
%23 = call i32 @sched_get_priority_max(i32 %3)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = call i32 @sched_get_priority_min(i32 %3)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %25)
ret i32 0
}