#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int getIntRange(int minValue, int maxValue) {
  int numEntered;
  do {
    printf("Enter an integer in the range %d to %d: ", minValue, maxValue);
    scanf("%d", &numEntered);
    if (numEntered >= minValue && numEntered <= maxValue)
      break;
    printf("Number out of range.  Try again.\n");
  } while (1);
  return numEntered;
}


x86 assembly (clang, -O0):
<getIntRange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     116f <getIntRange+0x4f>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     116f <getIntRange+0x4f>
jmp    118c <getIntRange+0x6c>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%al
test   $0x1,%al
jne    112e <getIntRange+0xe>
jmp    118c <getIntRange+0x6c>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIntRange>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xeba(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebp,%eax
jl     116e <getIntRange+0x3e>
cmp    %ebx,%eax
jle    11bd <getIntRange+0x8d>
lea    0xeb7(%rip),%r14
lea    0xe84(%rip),%r15
lea    0xea6(%rip),%r12
lea    0x4(%rsp),%r13
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebp,%eax
jl     1190 <getIntRange+0x60>
cmp    %ebx,%eax
jg     1190 <getIntRange+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter an integer in the range %d to %d: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Number out of range. Try again.\0A\00"
define i32 @getIntRange(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
br label %6
6: ; preds = %21, %2
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp sge i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %6
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
br label %22
19: ; preds = %14, %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19
br i1 true, label %6, label %22
22: ; preds = %21, %18
%23 = load i32, i32* %5
ret i32 %23
}

LLVM IR (-O2):
@.str = [41 x i8] c"Enter an integer in the range %d to %d: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [33 x i8] c"Number out of range. Try again.\00"
define i32 @getIntRange(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, %0
%9 = icmp sgt i32 %7, %1
%10 = or i1 %8, %9
br i1 %10, label %11, label %19
11: ; preds = %2, %11
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, %0
%17 = icmp sgt i32 %15, %1
%18 = or i1 %16, %17
br i1 %18, label %11, label %19
19: ; preds = %11, %2
%20 = phi i32 [ %7, %2 ], [ %15, %11 ]
ret i32 %20
}