#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 CLIReadNum(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ safeGetString(char *, int);
int safeGetInt(char *message, int min, int max) {
  char str[255];
  int temp;
  do {
    printf(message);
    safeGetString(str, 255);
    temp = CLIReadNum(str);
    if (temp < min || temp > max)
      printf("Invalid Input! Number:(%d - %d)\n", min, max);
    else
      return temp;
  } while (1);
}


x86 assembly (clang, -O0):
<safeGetInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    $0xff,%esi
call   1030 <safeGetString@plt>
lea    -0x120(%rbp),%rdi
call   1050 <CLIReadNum@plt>
mov    %eax,-0x124(%rbp)
mov    -0x124(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1191 <safeGetInt+0x61>
mov    -0x124(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11aa <safeGetInt+0x7a>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b8 <safeGetInt+0x88>
mov    -0x124(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cc <safeGetInt+0x9c>
jmp    11bd <safeGetInt+0x8d>
mov    $0x1,%al
test   $0x1,%al
jne    1145 <safeGetInt+0x15>
jmp    11cc <safeGetInt+0x9c>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<safeGetInt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1030 <safeGetString@plt>
mov    %rbx,%rdi
call   1050 <CLIReadNum@plt>
cmp    %ebp,%eax
jl     116f <safeGetInt+0x3f>
cmp    %r12d,%eax
jle    11b7 <safeGetInt+0x87>
lea    0xe8a(%rip),%r15
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xff,%esi
call   1030 <safeGetString@plt>
mov    %rbx,%rdi
call   1050 <CLIReadNum@plt>
cmp    %ebp,%eax
jl     1180 <safeGetInt+0x50>
cmp    %r12d,%eax
jg     1180 <safeGetInt+0x50>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Invalid Input! Number:(%d - %d)\0A\00"
define i32 @safeGetInt(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [255 x i8]
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
br label %10
10: ; preds = %31, %3
%11 = load i8*, i8** %5
%12 = call i32 (i8*, ...) @printf(i8* %11)
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%14 = call i32 @safeGetString(i8* %13, i32 255)
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%16 = call i32 @CLIReadNum(i8* %15)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %24, label %20
20: ; preds = %10
%21 = load i32, i32* %9
%22 = load i32, i32* %7
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %28
24: ; preds = %20, %10
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26)
br label %30
28: ; preds = %20
%29 = load i32, i32* %9
store i32 %29, i32* %4
br label %32
30: ; preds = %24
br label %31
31: ; preds = %30
br i1 true, label %10, label %32
32: ; preds = %28, %31
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@.str = [33 x i8] c"Invalid Input! Number:(%d - %d)\0A\00"
define i32 @safeGetInt(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [255 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %0)
%7 = call i32 @safeGetString(i8* %5, i32 255)
%8 = call i32 @CLIReadNum(i8* %5)
%9 = icmp slt i32 %8, %1
%10 = icmp sgt i32 %8, %2
%11 = or i1 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %3, %12
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %0)
%15 = call i32 @safeGetString(i8* %5, i32 255)
%16 = call i32 @CLIReadNum(i8* %5)
%17 = icmp slt i32 %16, %1
%18 = icmp sgt i32 %16, %2
%19 = or i1 %17, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %3
%21 = phi i32 [ %8, %3 ], [ %16, %12 ]
ret i32 %21
}