#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 /*<<< orphan*/ SCHED_FIFO;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int sched_setscheduler(int /*<<< orphan*/, int /*<<< orphan*/,
                       struct sched_param *);
int make_rt(void) {
  int res;
  struct sched_param param;
  param.sched_priority = 1;
  res = sched_setscheduler(0, SCHED_FIFO, &param);
  if (res != 0) {
    perror("sched_setscheduler");
    printf("You probably need to run as root.\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<make_rt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x10(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x10(%rbp),%rdx
call   1040 <sched_setscheduler@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1184 <make_rt+0x54>
lea    0xe99(%rip),%rdi
call   1050 <perror@plt>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    118b <make_rt+0x5b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_rt>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0x8(%rsp)
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1040 <sched_setscheduler@plt>
test   %eax,%eax
jne    1160 <make_rt+0x30>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe99(%rip),%rdi
call   1050 <perror@plt>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    1158 <make_rt+0x28>

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@.str = [19 x i8] c"sched_setscheduler\00"
@.str.1 = [35 x i8] c"You probably need to run as root.\0A\00"
define i32 @make_rt() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.sched_param
%4 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %3, i32 0, i32 0
store i32 1, i32* %4
%5 = load i32, i32* @SCHED_FIFO
%6 = call i32 @sched_setscheduler(i32 0, i32 %5, %struct.sched_param* %3)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %13
12: ; preds = %0
store i32 0, i32* %1
br label %13
13: ; preds = %12, %9
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@.str = [19 x i8] c"sched_setscheduler\00"
@str = [34 x i8] c"You probably need to run as root.\00"
define i32 @make_rt() {
%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 1, i32* %3
%4 = load i32, i32* @SCHED_FIFO
%5 = call i32 @sched_setscheduler(i32 0, i32 %4, %struct.sched_param* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %0, %7
%11 = phi i32 [ -1, %7 ], [ 0, %0 ]
ret i32 %11
}