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

/* Variables and functions */
int getpid();
int /*<<< orphan*/ printf(char *, int, int, ...);
int sched_get_priority_max(int);
int sched_get_priority_min(int);
int sched_getscheduler(int /*<<< orphan*/);
void main(int args, char *argv[]) {
  pid_t pid = getpid();
  int policy = sched_getscheduler(0);
  printf("Process : %d\t,policy:%d\n", pid, policy);
  int max_p = sched_get_priority_max(policy);
  int min_p = sched_get_priority_min(policy);
  printf("The maximum priority for policy %d is %i, and the minumum is %i\n",
         policy, max_p, min_p);
  while (1) {
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x14(%rbp)
xor    %edi,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%edi
call   1070 <sched_get_priority_max@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <sched_get_priority_min@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11b4 <main+0x64>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%ebx
xor    %edi,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,%ebp
lea    0xe94(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
call   1070 <sched_get_priority_max@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1060 <sched_get_priority_min@plt>
lea    0xe8b(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
nopl   0x0(%rax,%rax,1)
jmp    11a0 <main+0x50>

LLVM IR (-O0):
@.str = [25 x i8] c"Process : %d\09,policy:%d\0A\00"
@.str.1 = [65 x i8] c"The maximum priority for policy %d is %i, and the minumum is %i\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = call i32 (...) @getpid()
store i32 %9, i32* %5
%10 = call i32 @sched_getscheduler(i32 0)
store i32 %10, i32* %6
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* %6
%15 = call i32 @sched_get_priority_max(i32 %14)
store i32 %15, i32* %7
%16 = load i32, i32* %6
%17 = call i32 @sched_get_priority_min(i32 %16)
store i32 %17, i32* %8
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
br label %22
22: ; preds = %2, %22
br label %22
}

LLVM IR (-O2):
@.str = [25 x i8] c"Process : %d\09,policy:%d\0A\00"
@.str.1 = [65 x i8] c"The maximum priority for policy %d is %i, and the minumum is %i\0A\00"
define void @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 @sched_getscheduler(i32 0)
%5 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%6 = tail call i32 @sched_get_priority_max(i32 %4)
%7 = tail call i32 @sched_get_priority_min(i32 %4)
%8 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %6, i32 %7)
br label %9
9: ; preds = %9, %2
br label %9
}