#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*/ member_0;
};

/* Variables and functions */
int EINVAL;
int atoi(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int sched_setscheduler(int, int, struct sched_param *);
int main(int argc, char *argv[]) {
  int pid;
  struct sched_param param = {0};
  if (argc != 2) {
    printf("usage: %s pid\n", argv[0]);
    return EINVAL;
  }
  pid = atoi(argv[1]);
  if (sched_setscheduler(pid, 6006, &param) == -1) {
    perror("error sched_setscheduler");
    return -1;
  }
  return 0;
}


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)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
cmpl   $0x2,-0x8(%rbp)
je     11a4 <main+0x54>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ed <main+0x9d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1776,%esi
lea    -0x18(%rbp),%rdx
call   1040 <sched_setscheduler@plt>
cmp    $0xffffffff,%eax
jne    11e6 <main+0x96>
lea    0xe3a(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ed <main+0x9d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,(%rsp)
cmp    $0x2,%edi
jne    1170 <main+0x30>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %rsp,%rdx
mov    %eax,%edi
mov    $0x1776,%esi
call   1040 <sched_setscheduler@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
je     118a <main+0x4a>
pop    %rcx
ret
mov    (%rsi),%rsi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret
lea    0xe7e(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@.str = [15 x i8] c"usage: %s pid\0A\00"
@EINVAL = global i32 0
@.str.1 = [25 x i8] c"error sched_setscheduler\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sched_param
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast %struct.sched_param* %7 to i8*
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EINVAL
store i32 %16, i32* %3
br label %28
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = call i32 @sched_setscheduler(i32 %22, i32 6006, %struct.sched_param* %7)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %28
27: ; preds = %17
store i32 0, i32* %3
br label %28
28: ; preds = %27, %25, %11
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@.str = [15 x i8] c"usage: %s pid\0A\00"
@EINVAL = global i32 0
@.str.1 = [25 x i8] c"error sched_setscheduler\00"
define i32 @main(i32 %0, i8** nocapture %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 i32 0, i32* %5
%6 = icmp eq i32 %0, 2
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EINVAL
br label %19
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = call i32 @sched_setscheduler(i32 %14, i32 6006, %struct.sched_param* %3)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %11, %17, %7
%20 = phi i32 [ %10, %7 ], [ -1, %17 ], [ 0, %11 ]
ret i32 %20
}