#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*/ atoi(char *);
int /*<<< orphan*/ execlp(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sched_get_priority_max(int /*<<< orphan*/);
int /*<<< orphan*/ sched_getparam(int /*<<< orphan*/, struct sched_param *);
int /*<<< orphan*/ sched_setscheduler(int /*<<< orphan*/, int /*<<< orphan*/,
                                      struct sched_param *);
int main(int argc, char **argv) {
  struct sched_param p;
  sched_getparam(0, &p);
  if (argc < 1 || argv[1] == NULL)
    p.sched_priority = sched_get_priority_max(SCHED_FIFO);
  else
    p.sched_priority = atoi(argv[1]);
  sched_setscheduler(0, SCHED_FIFO, &p);
  execlp("/bin/sh", "/bin/sh", NULL);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
call   1030 <sched_getparam@plt>
cmpl   $0x1,-0x8(%rbp)
jl     118a <main+0x3a>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    11a0 <main+0x50>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1060 <sched_get_priority_max@plt>
mov    %eax,-0x18(%rbp)
jmp    11b0 <main+0x60>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x18(%rbp),%rdx
call   1040 <sched_setscheduler@plt>
lea    0xe35(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    %rsi,%rdi
call   1070 <execlp@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsp,%rsi
xor    %edi,%edi
call   1030 <sched_getparam@plt>
test   %ebp,%ebp
jle    1176 <main+0x26>
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     1176 <main+0x26>
call   1050 <atoi@plt>
jmp    1184 <main+0x34>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1060 <sched_get_priority_max@plt>
mov    %eax,(%rsp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
xor    %edi,%edi
call   1040 <sched_setscheduler@plt>
lea    0xe5f(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1070 <execlp@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@.str = [8 x i8] c"/bin/sh\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sched_param
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @sched_getparam(i32 0, %struct.sched_param* %6)
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 1
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %10, %2
%16 = load i32, i32* @SCHED_FIFO
%17 = call i32 @sched_get_priority_max(i32 %16)
%18 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %6, i32 0, i32 0
store i32 %17, i32* %18
br label %25
19: ; preds = %10
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
%24 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %6, i32 0, i32 0
store i32 %23, i32* %24
br label %25
25: ; preds = %19, %15
%26 = load i32, i32* @SCHED_FIFO
%27 = call i32 @sched_setscheduler(i32 0, i32 %26, %struct.sched_param* %6)
%28 = call i32 @execlp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* null)
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@SCHED_FIFO = global i32 0
@.str = [8 x i8] c"/bin/sh\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sched_param
%4 = bitcast %struct.sched_param* %3 to i8*
%5 = call i32 @sched_getparam(i32 0, %struct.sched_param* %3)
%6 = icmp slt i32 %0, 1
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %7, %2
%12 = load i32, i32* @SCHED_FIFO
%13 = call i32 @sched_get_priority_max(i32 %12)
%14 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %3, i64 0, i32 0
store i32 %13, i32* %14
br label %18
15: ; preds = %7
%16 = call i32 @atoi(i8* %9)
%17 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %3, i64 0, i32 0
store i32 %16, i32* %17
br label %18
18: ; preds = %15, %11
%19 = load i32, i32* @SCHED_FIFO
%20 = call i32 @sched_setscheduler(i32 0, i32 %19, %struct.sched_param* %3)
%21 = call i32 @execlp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* null)
ret i32 0
}