#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 */
#define SCHED_FIFO 130
#define SCHED_OTHER 129
#define SCHED_RR 128
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ printf(char *);
int sched_getscheduler(int /*<<< orphan*/);
void print_scheduler(void) {
  int schedType;
  schedType = sched_getscheduler(getpid());
  switch (schedType) {
  case SCHED_FIFO:
    printf("Pthread Policy is SCHED_FIFO\n");
    break;
  case SCHED_OTHER:
    printf("Pthread Policy is SCHED_OTHER\n");
    break;
  case SCHED_RR:
    printf("Pthread Policy is SCHED_OTHER\n");
    break;
  default:
    printf("Pthread Policy is UNKNOWN\n");
  }
}


x86 assembly (clang, -O0):
<print_scheduler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%edi
call   1030 <sched_getscheduler@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x80,%eax
je     11a7 <print_scheduler+0x77>
jmp    115f <print_scheduler+0x2f>
mov    -0x8(%rbp),%eax
sub    $0x81,%eax
je     1196 <print_scheduler+0x66>
jmp    1172 <print_scheduler+0x42>
mov    -0x8(%rbp),%eax
sub    $0x82,%eax
jne    11b8 <print_scheduler+0x88>
jmp    1185 <print_scheduler+0x55>
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
jmp    11c4 <print_scheduler+0x94>
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
jmp    11c4 <print_scheduler+0x94>
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
jmp    11c4 <print_scheduler+0x94>
lea    0xe7e(%rip),%rdi
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_scheduler>:
push   %rax
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %eax,%edi
call   1030 <sched_getscheduler@plt>
add    $0xffffff80,%eax
cmp    $0x2,%eax
ja     115d <print_scheduler+0x2d>
cltq
lea    0xf08(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rax
jmp    1040 <puts@plt>
lea    0xed7(%rip),%rdi
pop    %rax
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Pthread Policy is SCHED_FIFO\0A\00"
@.str.1 = [31 x i8] c"Pthread Policy is SCHED_OTHER\0A\00"
@.str.2 = [27 x i8] c"Pthread Policy is UNKNOWN\0A\00"
define void @print_scheduler() {
%1 = alloca i32
%2 = call i32 (...) @getpid()
%3 = call i32 @sched_getscheduler(i32 %2)
store i32 %3, i32* %1
%4 = load i32, i32* %1
switch i32 %4, label %11 [
i32 130, label %5
i32 129, label %7
i32 128, label %9
]
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %13
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %13
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %13
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %9, %7, %5
ret void
}

LLVM IR (-O2):
@str.3 = [30 x i8] c"Pthread Policy is SCHED_OTHER\00"
@str.4 = [29 x i8] c"Pthread Policy is SCHED_FIFO\00"
@str.5 = [26 x i8] c"Pthread Policy is UNKNOWN\00"
@reltable.print_scheduler = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.print_scheduler to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.print_scheduler to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @str.4 to i64), i64 ptrtoint ([3 x i32]* @reltable.print_scheduler to i64)) to i32)]
define void @print_scheduler() {
%1 = tail call i32 (...) @getpid()
%2 = tail call i32 @sched_getscheduler(i32 %1)
%3 = add i32 %2, -128
%4 = icmp ult i32 %3, 3
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = sext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.print_scheduler to i8*), i64 %7)
br label %9
9: ; preds = %0, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.5, i64 0, i64 0), %0 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret void
}