#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ iopl(int);
scalar_t__ mlockall(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void begin_realtime() {
  if (iopl(3) < 0) {
    perror("iopl(3)");
    fprintf(stderr, "this program must be run suid root (see chmod(1))\n");
    exit(1);
  }
  if (mlockall(1) < 0) {
    perror("mlockall(1)");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<begin_realtime>:
push   %rbp
mov    %rsp,%rbp
mov    $0x3,%edi
call   1030 <iopl@plt>
cmp    $0x0,%rax
jge    1193 <begin_realtime+0x43>
lea    0xe91(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    $0x1,%edi
call   1050 <mlockall@plt>
cmp    $0x0,%rax
jge    11bd <begin_realtime+0x6d>
lea    0xe8d(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<begin_realtime>:
push   %rax
mov    $0x3,%edi
call   1030 <iopl@plt>
test   %rax,%rax
js     1171 <begin_realtime+0x21>
mov    $0x1,%edi
call   1050 <mlockall@plt>
test   %rax,%rax
js     119c <begin_realtime+0x4c>
pop    %rax
ret
lea    0xe88(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe98(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"iopl(3)\00"
@stderr = global i32 0
@.str.1 = [51 x i8] c"this program must be run suid root (see chmod(1))\0A\00"
@.str.2 = [12 x i8] c"mlockall(1)\00"
define void @begin_realtime() {
%1 = call i64 @iopl(i32 3)
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = call i64 @mlockall(i32 1)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"iopl(3)\00"
@stderr = global i32 0
@.str.1 = [51 x i8] c"this program must be run suid root (see chmod(1))\0A\00"
@.str.2 = [12 x i8] c"mlockall(1)\00"
define void @begin_realtime() {
%1 = tail call i64 @iopl(i32 3)
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = tail call i64 @mlockall(i32 1)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8
ret void
}