#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 {
  scalar_t__ sched_priority;
};

/* Variables and functions */
int /*<<< orphan*/ SCHED_FIFO;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ sched_get_priority_max(int /*<<< orphan*/);
scalar_t__ sched_setscheduler(int /*<<< orphan*/, int /*<<< orphan*/,
                              struct sched_param *);
void realtimize(void) {
  struct sched_param prm;
  prm.sched_priority = sched_get_priority_max(SCHED_FIFO);
  if (prm.sched_priority < 0) {
    perror("sched_get_priority_max SCHED_FIFO");
    exit(1);
  }
  if (sched_setscheduler(0, SCHED_FIFO, &prm) < 0) {
    perror("sched_setscheduler SCHED_FIFO");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<realtimize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
call   1060 <sched_get_priority_max@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    117b <realtimize+0x3b>
lea    0xe94(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x8(%rbp),%rdx
call   1030 <sched_setscheduler@plt>
cmp    $0x0,%rax
jge    11af <realtimize+0x6f>
lea    0xe82(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<realtimize>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e9c(%rip),%rbx
mov    (%rbx),%edi
call   1060 <sched_get_priority_max@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
js     1176 <realtimize+0x36>
mov    (%rbx),%esi
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1030 <sched_setscheduler@plt>
test   %rax,%rax
js     117f <realtimize+0x3f>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe83(%rip),%rdi
jmp    1186 <realtimize+0x46>
lea    0xe9c(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.sched_param = type { i64 }
@SCHED_FIFO = global i32 0
@.str = [34 x i8] c"sched_get_priority_max SCHED_FIFO\00"
@.str.1 = [30 x i8] c"sched_setscheduler SCHED_FIFO\00"
define void @realtimize() {
%1 = alloca %struct.sched_param
%2 = load i32, i32* @SCHED_FIFO
%3 = call i64 @sched_get_priority_max(i32 %2)
%4 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i32 0, i32 0
store i64 %3, i64* %4
%5 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i32 0, i32 0
%6 = load i64, i64* %5
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = load i32, i32* @SCHED_FIFO
%13 = call i64 @sched_setscheduler(i32 0, i32 %12, %struct.sched_param* %1)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %11
ret void
}

LLVM IR (-O2):
%struct.sched_param = type { i64 }
@SCHED_FIFO = global i32 0
@.str = [34 x i8] c"sched_get_priority_max SCHED_FIFO\00"
@.str.1 = [30 x i8] c"sched_setscheduler SCHED_FIFO\00"
define void @realtimize() {
%1 = alloca %struct.sched_param
%2 = bitcast %struct.sched_param* %1 to i8*
%3 = load i32, i32* @SCHED_FIFO
%4 = tail call i64 @sched_get_priority_max(i32 %3)
%5 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i64 0, i32 0
store i64 %4, i64* %5
%6 = icmp slt i64 %4, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = tail call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = load i32, i32* @SCHED_FIFO
%12 = call i64 @sched_setscheduler(i32 0, i32 %11, %struct.sched_param* %1)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
ret void
}