#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*/ get_opt_int(char, int /*<<< orphan*/, int *);
int /*<<< orphan*/ msg(char *, char, int, int);
int get_opt_int_between(char key, int withErrorMsg, int from, int to, int dflt,
                        int *intAddr) {
  int val;
  if (!get_opt_int(key, 0, &val))
    val = dflt;
  if (val < from || val > to) {
    if (withErrorMsg)
      msg("ERROR: "
          "Value of option '-%c' is not a valide integer from [%d..%d].",
          key, from, to);
    return 0;
  }
  *intAddr = val;
  return 1;
}


x86 assembly (clang, -O0):
<get_opt_int_between>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
xor    %esi,%esi
lea    -0x24(%rbp),%rdx
movsbl -0x5(%rbp),%edi
call   1030 <get_opt_int@plt>
cmp    $0x0,%eax
jne    115d <get_opt_int_between+0x3d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     1175 <get_opt_int_between+0x55>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11a3 <get_opt_int_between+0x83>
cmpl   $0x0,-0xc(%rbp)
je     1197 <get_opt_int_between+0x77>
mov    -0x5(%rbp),%al
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe71(%rip),%rdi
movsbl %al,%esi
call   1040 <msg@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b3 <get_opt_int_between+0x93>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_opt_int_between>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r15
mov    %r8d,%ebp
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %esi,%r13d
mov    %edi,%ebx
lea    0x4(%rsp),%rdx
xor    %esi,%esi
call   1030 <get_opt_int@plt>
test   %eax,%eax
je     1157 <get_opt_int_between+0x37>
mov    0x4(%rsp),%ebp
cmp    %r12d,%ebp
jge    1160 <get_opt_int_between+0x40>
jmp    116f <get_opt_int_between+0x4f>
mov    %ebp,0x4(%rsp)
cmp    %r12d,%ebp
jl     116f <get_opt_int_between+0x4f>
cmp    %r14d,%ebp
jg     116f <get_opt_int_between+0x4f>
mov    %ebp,(%r15)
mov    $0x1,%ebp
jmp    118b <get_opt_int_between+0x6b>
xor    %ebp,%ebp
test   %r13d,%r13d
je     118b <get_opt_int_between+0x6b>
movsbl %bl,%esi
lea    0xe80(%rip),%rdi
mov    %r12d,%edx
mov    %r14d,%ecx
call   1040 <msg@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [68 x i8] c"ERROR: Value of option '-%c' is not a valide integer from [%d..%d].\00"
define i32 @get_opt_int_between(i8 signext %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5) {
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
store i8 %0, i8* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32* %5, i32** %13
%15 = load i8, i8* %8
%16 = call i32 @get_opt_int(i8 signext %15, i32 0, i32* %14)
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %6
%19 = load i32, i32* %12
store i32 %19, i32* %14
br label %20
20: ; preds = %18, %6
%21 = load i32, i32* %14
%22 = load i32, i32* %10
%23 = icmp slt i32 %21, %22
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = load i32, i32* %14
%26 = load i32, i32* %11
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24, %20
%29 = load i32, i32* %9
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i8, i8* %8
%33 = load i32, i32* %10
%34 = load i32, i32* %11
%35 = call i32 @msg(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8 signext %32, i32 %33, i32 %34)
br label %36
36: ; preds = %31, %28
store i32 0, i32* %7
br label %40
37: ; preds = %24
%38 = load i32, i32* %14
%39 = load i32*, i32** %13
store i32 %38, i32* %39
store i32 1, i32* %7
br label %40
40: ; preds = %37, %36
%41 = load i32, i32* %7
ret i32 %41
}

LLVM IR (-O2):
@.str = [68 x i8] c"ERROR: Value of option '-%c' is not a valide integer from [%d..%d].\00"
define i32 @get_opt_int_between(i8 signext %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* nocapture writeonly %5) {
%7 = alloca i32
%8 = bitcast i32* %7 to i8*
%9 = call i32 @get_opt_int(i8 signext %0, i32 0, i32* %7)
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = load i32, i32* %7
br label %14
13: ; preds = %6
store i32 %4, i32* %7
br label %14
14: ; preds = %11, %13
%15 = phi i32 [ %12, %11 ], [ %4, %13 ]
%16 = icmp slt i32 %15, %2
%17 = icmp sgt i32 %15, %3
%18 = or i1 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = icmp eq i32 %1, 0
br i1 %20, label %24, label %21
21: ; preds = %19
%22 = call i32 @msg(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8 signext %0, i32 %2, i32 %3)
br label %24
23: ; preds = %14
store i32 %15, i32* %5
br label %24
24: ; preds = %19, %21, %23
%25 = phi i32 [ 1, %23 ], [ 0, %21 ], [ 0, %19 ]
ret i32 %25
}