#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 */
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int sched_get_priority_max(int);
int sched_get_priority_min(int);
int sched_getscheduler(int /*<<< orphan*/);
int main(int args, char *argv[]) {
  pid_t target;
  if (args == 1)
    target = getpid();
  else if (args == 2)
    target = atoi(argv[1]);
  else {
    perror("More than 2 args");
    exit(-1);
  }
  int politica = sched_getscheduler(target);
  printf("La politica es : %d\n", politica);
  int prioMax = sched_get_priority_max(politica);
  printf("La prioridad maxima para dicha politica es: %d\n", prioMax);
  int prioMin = sched_get_priority_min(politica);
  printf("La prioridad minima para dicha politica es: %d\n", prioMin);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11af <main+0x2f>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x14(%rbp)
jmp    11e9 <main+0x69>
cmpl   $0x2,-0x8(%rbp)
jne    11ce <main+0x4e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    11e4 <main+0x64>
lea    0xe2b(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
jmp    11e9 <main+0x69>
mov    -0x14(%rbp),%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe13(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%edi
call   10a0 <sched_get_priority_max@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe0e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%edi
call   1060 <sched_get_priority_min@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe24(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
je     1194 <main+0x14>
cmp    $0x1,%edi
jne    11e2 <main+0x62>
xor    %eax,%eax
call   1040 <getpid@plt>
jmp    119d <main+0x1d>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,%ebx
lea    0xe64(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %ebx,%edi
call   10a0 <sched_get_priority_max@plt>
lea    0xe64(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %ebx,%edi
call   1060 <sched_get_priority_min@plt>
lea    0xe7f(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe17(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"More than 2 args\00"
@.str.1 = [21 x i8] c"La politica es : %d\0A\00"
@.str.2 = [48 x i8] c"La prioridad maxima para dicha politica es: %d\0A\00"
@.str.3 = [48 x i8] c"La prioridad minima para dicha politica es: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @getpid()
store i32 %13, i32* %6
br label %26
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
br label %25
22: ; preds = %14
%23 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %17
br label %26
26: ; preds = %25, %12
%27 = load i32, i32* %6
%28 = call i32 @sched_getscheduler(i32 %27)
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %7
%32 = call i32 @sched_get_priority_max(i32 %31)
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %7
%36 = call i32 @sched_get_priority_min(i32 %35)
store i32 %36, i32* %9
%37 = load i32, i32* %9
%38 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [17 x i8] c"More than 2 args\00"
@.str.1 = [21 x i8] c"La politica es : %d\0A\00"
@.str.2 = [48 x i8] c"La prioridad maxima para dicha politica es: %d\0A\00"
@.str.3 = [48 x i8] c"La prioridad minima para dicha politica es: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %9 [
i32 1, label %3
i32 2, label %5
]
3: ; preds = %2
%4 = tail call i32 (...) @getpid()
br label %12
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
br label %12
9: ; preds = %2
%10 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %5, %3
%13 = phi i32 [ %4, %3 ], [ %8, %5 ]
%14 = tail call i32 @sched_getscheduler(i32 %13)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call i32 @sched_get_priority_max(i32 %14)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = tail call i32 @sched_get_priority_min(i32 %14)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %18)
ret i32 0
}