#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_OTHER;
int /*<<< orphan*/ exit(int);
scalar_t__ munlockall();
int /*<<< orphan*/ perror(char *);
scalar_t__ sched_setscheduler(int /*<<< orphan*/, int /*<<< orphan*/,
                              struct sched_param *);
void unrealtime(void) {
  struct sched_param prm = {.sched_priority = 0};
  if (sched_setscheduler(0, SCHED_OTHER, &prm) < 0) {
    perror("sched_setscheduler SCHED_OTHER");
    exit(1);
  }
  if (munlockall() < 0) {
    perror("munlockall");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<unrealtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x8(%rbp),%rdx
call   1030 <sched_setscheduler@plt>
cmp    $0x0,%rax
jge    119c <unrealtime+0x4c>
lea    0xe73(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1060 <munlockall@plt>
cmp    $0x0,%rax
jge    11c3 <unrealtime+0x73>
lea    0xe6b(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unrealtime>:
push   %rax
movl   $0x0,(%rsp)
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
xor    %edi,%edi
call   1030 <sched_setscheduler@plt>
test   %rax,%rax
js     116e <unrealtime+0x2e>
xor    %eax,%eax
call   1050 <munlockall@plt>
test   %rax,%rax
js     1177 <unrealtime+0x37>
pop    %rax
ret
lea    0xe8b(%rip),%rdi
jmp    117e <unrealtime+0x3e>
lea    0xea1(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

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

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