#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*/ fprint_err(char *, ...);
int int_value(char *, char *, char *, int, int, int *);
int /*<<< orphan*/ print_err(char *);
extern int int_value_in_range(char *prefix, char *cmd, char *arg, int minimum,
                              int maximum, int base, int *value) {
  int err, temp;
  err = int_value(prefix, cmd, arg, (minimum >= 0), base, &temp);
  if (err)
    return err;
  if (temp > maximum || temp < minimum) {
    print_err("### ");
    if (prefix != NULL)
      fprint_err("%s: ", prefix);
    fprint_err("Value %d (in %s %s) is not in range %d..%d (0x%x..0x%x)\n",
               temp, cmd, arg, minimum, maximum, minimum, maximum);
    return 1;
  }
  *value = temp;
  return 0;
}


x86 assembly (clang, -O0):
<int_value_in_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
cmpl   $0x0,-0x24(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x2c(%rbp),%r8d
lea    -0x34(%rbp),%r9
call   1050 <int_value@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1190 <int_value_in_range+0x60>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121d <int_value_in_range+0xed>
mov    -0x34(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     11a8 <int_value_in_range+0x78>
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    120d <int_value_in_range+0xdd>
lea    0xe51(%rip),%rdi
call   1040 <print_err@plt>
cmpq   $0x0,-0x10(%rbp)
je     11d1 <int_value_in_range+0xa1>
mov    -0x10(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <fprint_err@plt>
mov    -0x34(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
mov    -0x24(%rbp),%r10d
mov    -0x28(%rbp),%eax
lea    0xe18(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <fprint_err@plt>
movl   $0x1,-0x4(%rbp)
jmp    121d <int_value_in_range+0xed>
mov    -0x34(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_value_in_range>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r9d,%eax
mov    %r8d,%r14d
mov    %ecx,%r13d
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
not    %ecx
shr    $0x1f,%ecx
lea    0xc(%rsp),%r9
mov    %eax,%r8d
call   1050 <int_value@plt>
test   %eax,%eax
jne    11cb <int_value_in_range+0x9b>
mov    0xc(%rsp),%eax
cmp    %r14d,%eax
jg     117e <int_value_in_range+0x4e>
cmp    %r13d,%eax
jl     117e <int_value_in_range+0x4e>
mov    0x40(%rsp),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
jmp    11cb <int_value_in_range+0x9b>
lea    0xe7b(%rip),%rdi
call   1040 <print_err@plt>
test   %rbx,%rbx
je     11a0 <int_value_in_range+0x70>
lea    0xe6f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprint_err@plt>
mov    0xc(%rsp),%esi
lea    0xe5f(%rip),%rdi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r13d,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
push   %r14
push   %r13
call   1030 <fprint_err@plt>
add    $0x10,%rsp
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"### \00"
@.str.1 = [5 x i8] c"%s: \00"
@.str.2 = [57 x i8] c"Value %d (in %s %s) is not in range %d..%d (0x%x..0x%x)\0A\00"
define i32 @int_value_in_range(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5, i32* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %9
store i8* %1, i8** %10
store i8* %2, i8** %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32* %6, i32** %15
%18 = load i8*, i8** %9
%19 = load i8*, i8** %10
%20 = load i8*, i8** %11
%21 = load i32, i32* %12
%22 = icmp sge i32 %21, 0
%23 = zext i1 %22 to i32
%24 = load i32, i32* %14
%25 = call i32 @int_value(i8* %18, i8* %19, i8* %20, i32 %23, i32 %24, i32* %17)
store i32 %25, i32* %16
%26 = load i32, i32* %16
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %7
%29 = load i32, i32* %16
store i32 %29, i32* %8
br label %57
30: ; preds = %7
%31 = load i32, i32* %17
%32 = load i32, i32* %13
%33 = icmp sgt i32 %31, %32
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i32, i32* %17
%36 = load i32, i32* %12
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %54
38: ; preds = %34, %30
%39 = call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%40 = load i8*, i8** %9
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i8*, i8** %9
%44 = call i32 (i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %42, %38
%46 = load i32, i32* %17
%47 = load i8*, i8** %10
%48 = load i8*, i8** %11
%49 = load i32, i32* %12
%50 = load i32, i32* %13
%51 = load i32, i32* %12
%52 = load i32, i32* %13
%53 = call i32 (i8*, ...) @fprint_err(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %46, i8* %47, i8* %48, i32 %49, i32 %50, i32 %51, i32 %52)
store i32 1, i32* %8
br label %57
54: ; preds = %34
%55 = load i32, i32* %17
%56 = load i32*, i32** %15
store i32 %55, i32* %56
store i32 0, i32* %8
br label %57
57: ; preds = %54, %45, %28
%58 = load i32, i32* %8
ret i32 %58
}

LLVM IR (-O2):
@.str = [5 x i8] c"### \00"
@.str.1 = [5 x i8] c"%s: \00"
@.str.2 = [57 x i8] c"Value %d (in %s %s) is not in range %d..%d (0x%x..0x%x)\0A\00"
define i32 @int_value_in_range(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5, i32* nocapture writeonly %6) {
%8 = alloca i32
%9 = bitcast i32* %8 to i8*
%10 = xor i32 %3, -1
%11 = lshr i32 %10, 31
%12 = call i32 @int_value(i8* %0, i8* %1, i8* %2, i32 %11, i32 %5, i32* %8)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %7
%15 = load i32, i32* %8
%16 = icmp sgt i32 %15, %4
%17 = icmp slt i32 %15, %3
%18 = or i1 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %14
%20 = call i32 @print_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i8* %0, null
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 (i8*, ...) @fprint_err(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %24
24: ; preds = %22, %19
%25 = load i32, i32* %8
%26 = call i32 (i8*, ...) @fprint_err(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %25, i8* %1, i8* %2, i32 %3, i32 %4, i32 %3, i32 %4)
br label %28
27: ; preds = %14
store i32 %15, i32* %6
br label %28
28: ; preds = %7, %27, %24
%29 = phi i32 [ 1, %24 ], [ 0, %27 ], [ %12, %7 ]
ret i32 %29
}