#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 /*<<< orphan*/ sched_priority;
};

/* Variables and functions */
int /*<<< orphan*/ SCHED_FIFO;
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ sched_get_priority_max(int /*<<< orphan*/);
int /*<<< orphan*/ sched_getparam(int /*<<< orphan*/, struct sched_param *);
int sched_setscheduler(int /*<<< orphan*/, int /*<<< orphan*/,
                       struct sched_param *);
int osfunctions_setMaxPriority() {
  struct sched_param param;
  sched_getparam(getpid(), &param);
  param.sched_priority = sched_get_priority_max(SCHED_FIFO);
  return (sched_setscheduler(getpid(), SCHED_FIFO, &param) != -1);
}


x86 assembly (clang, -O0):
<osfunctions_setMaxPriority>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
lea    -0x8(%rbp),%rsi
call   1040 <sched_getparam@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
call   1060 <sched_get_priority_max@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1050 <sched_setscheduler@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<osfunctions_setMaxPriority>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %rsp,%r14
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <sched_getparam@plt>
mov    0x2e89(%rip),%rbx
mov    (%rbx),%edi
call   1060 <sched_get_priority_max@plt>
mov    %eax,(%rsp)
xor    %eax,%eax
call   1030 <getpid@plt>
mov    (%rbx),%esi
mov    %eax,%edi
mov    %r14,%rdx
call   1050 <sched_setscheduler@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
setne  %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
define i32 @osfunctions_setMaxPriority() {
%1 = alloca %struct.sched_param
%2 = call i32 (...) @getpid()
%3 = call i32 @sched_getparam(i32 %2, %struct.sched_param* %1)
%4 = load i32, i32* @SCHED_FIFO
%5 = call i32 @sched_get_priority_max(i32 %4)
%6 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i32 0, i32 0
store i32 %5, i32* %6
%7 = call i32 (...) @getpid()
%8 = load i32, i32* @SCHED_FIFO
%9 = call i32 @sched_setscheduler(i32 %7, i32 %8, %struct.sched_param* %1)
%10 = icmp ne i32 %9, -1
%11 = zext i1 %10 to i32
ret i32 %11
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
define i32 @osfunctions_setMaxPriority() {
%1 = alloca %struct.sched_param
%2 = bitcast %struct.sched_param* %1 to i8*
%3 = tail call i32 (...) @getpid()
%4 = call i32 @sched_getparam(i32 %3, %struct.sched_param* %1)
%5 = load i32, i32* @SCHED_FIFO
%6 = call i32 @sched_get_priority_max(i32 %5)
%7 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i64 0, i32 0
store i32 %6, i32* %7
%8 = call i32 (...) @getpid()
%9 = load i32, i32* @SCHED_FIFO
%10 = call i32 @sched_setscheduler(i32 %8, i32 %9, %struct.sched_param* %1)
%11 = icmp ne i32 %10, -1
%12 = zext i1 %11 to i32
ret i32 %12
}