#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*/ Usage();
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, int);
int /*<<< orphan*/ stderr;
void getvalue(int *arg, int *index, int argc, char **argv, int min, int max) {
  if (*index >= argc - 1)
    Usage();
  *arg = atoi(argv[1 + *index]);
  if (*arg < min || *arg > max) {
    fprintf(stderr, "Value for %s should be in the range %d..%d\n",
            argv[*index] + 2, min, max);
    exit(1);
  }
  ++*index;
}


x86 assembly (clang, -O0):
<getvalue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     117a <getvalue+0x3a>
mov    $0x0,%al
call   1030 <Usage@plt>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
cmp    -0x24(%rbp),%eax
jl     11b9 <getvalue+0x79>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
cmp    -0x28(%rbp),%eax
jle    11f2 <getvalue+0xb2>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
add    $0x2,%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
lea    0xe1d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getvalue>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %rcx,%r12
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    (%rsi),%eax
add    $0xffffffff,%edx
cmp    %edx,%eax
jl     116a <getvalue+0x2a>
xor    %eax,%eax
call   1030 <Usage@plt>
mov    0x0(%rbp),%eax
cltq
mov    0x8(%r12,%rax,8),%rdi
call   1050 <atoi@plt>
mov    %eax,(%rbx)
cmp    %r15d,%eax
jl     118f <getvalue+0x4f>
cmp    %r14d,%eax
jg     118f <getvalue+0x4f>
addl   $0x1,0x0(%rbp)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
movslq 0x0(%rbp),%rax
mov    (%r12,%rax,8),%rdx
add    $0x2,%rdx
lea    0xe55(%rip),%rsi
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"Value for %s should be in the range %d..%d\0A\00"
define void @getvalue(i32* %0, i32* %1, i32 %2, i8** %3, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store i8** %3, i8*** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = load i32*, i32** %8
%14 = load i32, i32* %13
%15 = load i32, i32* %9
%16 = sub nsw i32 %15, 1
%17 = icmp sge i32 %14, %16
br i1 %17, label %18, label %20
18: ; preds = %6
%19 = call i32 (...) @Usage()
br label %20
20: ; preds = %18, %6
%21 = load i8**, i8*** %10
%22 = load i32*, i32** %8
%23 = load i32, i32* %22
%24 = add nsw i32 1, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %21, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
%29 = load i32*, i32** %7
store i32 %28, i32* %29
%30 = load i32*, i32** %7
%31 = load i32, i32* %30
%32 = load i32, i32* %11
%33 = icmp slt i32 %31, %32
br i1 %33, label %39, label %34
34: ; preds = %20
%35 = load i32*, i32** %7
%36 = load i32, i32* %35
%37 = load i32, i32* %12
%38 = icmp sgt i32 %36, %37
br i1 %38, label %39, label %52
39: ; preds = %34, %20
%40 = load i32, i32* @stderr
%41 = load i8**, i8*** %10
%42 = load i32*, i32** %8
%43 = load i32, i32* %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %41, i64 %44
%46 = load i8*, i8** %45
%47 = getelementptr inbounds i8, i8* %46, i64 2
%48 = load i32, i32* %11
%49 = load i32, i32* %12
%50 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %47, i32 %48, i32 %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %34
%53 = load i32*, i32** %8
%54 = load i32, i32* %53
%55 = add nsw i32 %54, 1
store i32 %55, i32* %53
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"Value for %s should be in the range %d..%d\0A\00"
define void @getvalue(i32* nocapture writeonly %0, i32* nocapture %1, i32 %2, i8** nocapture %3, i32 %4, i32 %5) {
%7 = load i32, i32* %1
%8 = add nsw i32 %2, -1
%9 = icmp slt i32 %7, %8
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = tail call i32 (...) @Usage()
%12 = load i32, i32* %1
br label %13
13: ; preds = %10, %6
%14 = phi i32 [ %12, %10 ], [ %7, %6 ]
%15 = add nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %3, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
store i32 %19, i32* %0
%20 = icmp slt i32 %19, %4
%21 = icmp sgt i32 %19, %5
%22 = or i1 %20, %21
br i1 %22, label %23, label %32
23: ; preds = %13
%24 = load i32, i32* @stderr
%25 = load i32, i32* %1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %3, i64 %26
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 2
%30 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %29, i32 %4, i32 %5)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %13
%33 = load i32, i32* %1
%34 = add nsw i32 %33, 1
store i32 %34, i32* %1
ret void
}