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

/* Variables and functions */
int MCL_CURRENT;
int MCL_FUTURE;
int /*<<< orphan*/ SCHED_FIFO;
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int mlockall(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ sched_setscheduler(int /*<<< orphan*/, int /*<<< orphan*/,
                              struct sched_param *);
void setSchedPrio_noerrcheck(void) {
  struct sched_param param;
  param.sched_priority = 99;
  if (sched_setscheduler(0, SCHED_FIFO, &param) != 0) {
    perror("sched_setscheduler");
  }
  if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
    perror("mlockall failed");
  }
  unsigned char dummy[(8 * 1024)];
  memset(dummy, 0, (8 * 1024));
}


x86 assembly (clang, -O0):
<setSchedPrio_noerrcheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2010,%rsp
movl   $0x63,-0x8(%rbp)
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x8(%rbp),%rdx
call   1030 <sched_setscheduler@plt>
cmp    $0x0,%rax
je     117c <setSchedPrio_noerrcheck+0x3c>
lea    0xe89(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    0x2e64(%rip),%rax
or     (%rax),%edi
call   1050 <mlockall@plt>
cmp    $0xffffffff,%eax
jne    11a8 <setSchedPrio_noerrcheck+0x68>
lea    0xe70(%rip),%rdi
call   1060 <perror@plt>
lea    -0x2010(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1040 <memset@plt>
add    $0x2010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setSchedPrio_noerrcheck>:
sub    $0x2018,%rsp
movl   $0x63,0x8(%rsp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1030 <sched_setscheduler@plt>
test   %rax,%rax
jne    119e <setSchedPrio_noerrcheck+0x5e>
mov    0x2e60(%rip),%rax
mov    0x2e79(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
call   1050 <mlockall@plt>
cmp    $0xffffffff,%eax
je     11ac <setSchedPrio_noerrcheck+0x6c>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1040 <memset@plt>
add    $0x2018,%rsp
ret
lea    0xe5b(%rip),%rdi
call   1060 <perror@plt>
jmp    1169 <setSchedPrio_noerrcheck+0x29>
lea    0xe60(%rip),%rdi
call   1060 <perror@plt>
jmp    1185 <setSchedPrio_noerrcheck+0x45>

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@.str = [19 x i8] c"sched_setscheduler\00"
@MCL_CURRENT = global i32 0
@MCL_FUTURE = global i32 0
@.str.1 = [16 x i8] c"mlockall failed\00"
define void @setSchedPrio_noerrcheck() {
%1 = alloca %struct.sched_param
%2 = alloca [8192 x i8]
%3 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i32 0, i32 0
store i32 99, i32* %3
%4 = load i32, i32* @SCHED_FIFO
%5 = call i64 @sched_setscheduler(i32 0, i32 %4, %struct.sched_param* %1)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = load i32, i32* @MCL_CURRENT
%11 = load i32, i32* @MCL_FUTURE
%12 = or i32 %10, %11
%13 = call i32 @mlockall(i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %9
%18 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%19 = call i32 @memset(i8* %18, i32 0, i32 8192)
ret void
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@.str = [19 x i8] c"sched_setscheduler\00"
@MCL_CURRENT = global i32 0
@MCL_FUTURE = global i32 0
@.str.1 = [16 x i8] c"mlockall failed\00"
define void @setSchedPrio_noerrcheck() {
%1 = alloca %struct.sched_param
%2 = alloca [8192 x i8]
%3 = bitcast %struct.sched_param* %1 to i8*
%4 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %1, i64 0, i32 0
store i32 99, i32* %4
%5 = load i32, i32* @SCHED_FIFO
%6 = call i64 @sched_setscheduler(i32 0, i32 %5, %struct.sched_param* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = load i32, i32* @MCL_CURRENT
%12 = load i32, i32* @MCL_FUTURE
%13 = or i32 %12, %11
%14 = call i32 @mlockall(i32 %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %10
%19 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%20 = call i32 @memset(i8* %19, i32 0, i32 8192)
ret void
}