#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 getInt();
scalar_t__ printf(char *, int, int);
int getLimInt(int lowerLimit, int upperLimit) {
  int val;
  do {
    val = getInt();
  } while ((val < lowerLimit || val > upperLimit) &&
           printf("Invalid value, %d < value < %d: ", lowerLimit, upperLimit));
  return val;
}


x86 assembly (clang, -O0):
<getLimInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getInt@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     1155 <getLimInt+0x35>
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0xd(%rbp)
jle    1171 <getLimInt+0x51>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    112e <getLimInt+0xe>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLimInt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%ebp
lea    0xecd(%rip),%r14
jmp    1152 <getLimInt+0x32>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <printf@plt>
test   %rax,%rax
je     1164 <getLimInt+0x44>
xor    %eax,%eax
call   1040 <getInt@plt>
mov    %eax,%ebx
cmp    %ebp,%eax
jl     1140 <getLimInt+0x20>
cmp    %r15d,%ebx
jg     1140 <getLimInt+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Invalid value, %d < value < %d: \00"
define i32 @getLimInt(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 = call i32 (...) @getInt()
store i32 %7, i32* %5
br label %8
8: ; preds = %6
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %12, %8
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i64 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
%20 = icmp ne i64 %19, 0
br label %21
21: ; preds = %16, %12
%22 = phi i1 [ false, %12 ], [ %20, %16 ]
br i1 %22, label %6, label %23
23: ; preds = %21
%24 = load i32, i32* %5
ret i32 %24
}

LLVM IR (-O2):
@.str = [33 x i8] c"Invalid value, %d < value < %d: \00"
define i32 @getLimInt(i32 %0, i32 %1) {
br label %3
3: ; preds = %8, %2
%4 = tail call i32 (...) @getInt()
%5 = icmp slt i32 %4, %0
%6 = icmp sgt i32 %4, %1
%7 = or i1 %5, %6
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = tail call i64 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %3
11: ; preds = %3, %8
ret i32 %4
}