#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*/ errx(int, char *, char *);
int /*<<< orphan*/ exit(int);
scalar_t__ get_int_arg(char *, unsigned int *);
int get_sched_param(int argc, char *argv[], int pos, unsigned int *valp) {
  if (pos + 1 >= argc)
    errx(1, "missing value for %s", argv[pos]);
  if (get_int_arg(argv[pos + 1], valp))
    exit(1);
  return 0;
}


x86 assembly (clang, -O0):
<get_sched_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cmp    -0x4(%rbp),%eax
jl     1172 <get_sched_param+0x42>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    $0x1,%edi
lea    0xe93(%rip),%rsi
call   1030 <errx@plt>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <get_int_arg@plt>
cmp    $0x0,%rax
je     11a0 <get_sched_param+0x70>
mov    $0x1,%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sched_param>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rsi,%rbx
lea    0x1(%rdx),%ebp
cmp    %edi,%ebp
jl     1159 <get_sched_param+0x29>
movslq %edx,%rax
mov    (%rbx,%rax,8),%rdx
lea    0xeb1(%rip),%rsi
mov    $0x1,%edi
call   1030 <errx@plt>
movslq %ebp,%rax
mov    (%rbx,%rax,8),%rdi
mov    %r14,%rsi
call   1040 <get_int_arg@plt>
test   %rax,%rax
jne    1174 <get_sched_param+0x44>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"missing value for %s\00"
define i32 @get_sched_param(i32 %0, i8** %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%9 = load i32, i32* %7
%10 = add nsw i32 %9, 1
%11 = load i32, i32* %5
%12 = icmp sge i32 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %4
%14 = load i8**, i8*** %6
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @errx(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %13, %4
%21 = load i8**, i8*** %6
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %21, i64 %24
%26 = load i8*, i8** %25
%27 = load i32*, i32** %8
%28 = call i64 @get_int_arg(i8* %26, i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %20
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"missing value for %s\00"
define i32 @get_sched_param(i32 %0, i8** nocapture %1, i32 %2, i32* %3) {
%5 = add nsw i32 %2, 1
%6 = icmp slt i32 %5, %0
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %7, %4
%13 = sext i32 %5 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i64 @get_int_arg(i8* %15, i32* %3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %12
ret i32 0
}