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

/* Variables and functions */
int errno;
int execve(char *, char **, char **);
int /*<<< orphan*/ printUsage(char *);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ sched_setscheduler(int /*<<< orphan*/, int,
                                      struct sched_param *);
char *strerror(int);
int main(int argc, char *argv[]) {
  extern char **environ;
  struct sched_param param;
  param.sched_priority = 0;
  if (argc >= 10) {
    printUsage(argv[0]);
    return -1;
  }
  sched_setscheduler(0, 5, &param);
  if (-1 == execve("/bin/sh", argv, environ)) {
    printf("exec error. errno is %d. errstr is %s\n", errno, strerror(errno));
  }
}


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)
movq   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x8(%rbp)
jl     1190 <main+0x40>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <printUsage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f5 <main+0xa5>
xor    %edi,%edi
mov    $0x5,%esi
lea    -0x18(%rbp),%rdx
call   1040 <sched_setscheduler@plt>
mov    -0x10(%rbp),%rsi
mov    0x2e3d(%rip),%rax
mov    (%rax),%rdx
lea    0xe4b(%rip),%rdi
call   1050 <execve@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11f5 <main+0xa5>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x1c(%rbp),%esi
mov    %rax,%rdx
lea    0xe18(%rip),%rdi
call   1030 <printf@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
movq   $0x0,(%rsp)
cmp    $0xa,%edi
jl     1172 <main+0x22>
mov    (%rbx),%rdi
call   1060 <printUsage@plt>
mov    $0xffffffff,%ebp
jmp    11c2 <main+0x72>
xor    %ebp,%ebp
mov    %rsp,%rdx
xor    %edi,%edi
mov    $0x5,%esi
call   1040 <sched_setscheduler@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%rdx
lea    0xe6c(%rip),%rdi
mov    %rbx,%rsi
call   1050 <execve@plt>
cmp    $0xffffffff,%eax
jne    11c2 <main+0x72>
mov    0x2e30(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1070 <strerror@plt>
lea    0xe50(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1030 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sched_param = type { i64 }
@.str = [8 x i8] c"/bin/sh\00"
@environ = external global i8**
@.str.1 = [39 x i8] c"exec error. errno is %d. errstr is %s\0A\00"
@errno = global i32 0
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 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %6, i32 0, i32 0
store i64 0, i64* %7
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 10
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @printUsage(i8* %13)
store i32 -1, i32* %3
br label %26
15: ; preds = %2
%16 = call i32 @sched_setscheduler(i32 0, i32 5, %struct.sched_param* %6)
%17 = load i8**, i8*** %5
%18 = load i8**, i8*** @environ
%19 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %17, i8** %18)
%20 = icmp eq i32 -1, %19
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = load i32, i32* @errno
%23 = load i32, i32* @errno
%24 = call i8* @strerror(i32 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %22, i8* %24)
br label %26
26: ; preds = %10, %21, %15
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.sched_param = type { i64 }
@.str = [8 x i8] c"/bin/sh\00"
@environ = external global i8**
@.str.1 = [39 x i8] c"exec error. errno is %d. errstr is %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sched_param
%4 = bitcast %struct.sched_param* %3 to i8*
%5 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %3, i64 0, i32 0
store i64 0, i64* %5
%6 = icmp sgt i32 %0, 9
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 @printUsage(i8* %8)
br label %19
10: ; preds = %2
%11 = call i32 @sched_setscheduler(i32 0, i32 5, %struct.sched_param* %3)
%12 = load i8**, i8*** @environ
%13 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %1, i8** %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %17)
br label %19
19: ; preds = %10, %15, %7
%20 = phi i32 [ -1, %7 ], [ 0, %15 ], [ 0, %10 ]
ret i32 %20
}