#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, int);
int /*<<< orphan*/ scanf(char *, int *);
int getint(int low, int high) {
  int t;
  scanf("%d", &t);
  while (t < low || t > high) {
    printf("Invalad. Choose a number between %d and %d : ", low, high);
    scanf("%d", &t);
  }
  return t;
}


x86 assembly (clang, -O0):
<getint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xecb(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%ecx
mov    $0x1,%al
cmp    -0x4(%rbp),%ecx
mov    %al,-0xd(%rbp)
jl     115b <getint+0x3b>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
setg   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    116b <getint+0x4b>
jmp    1192 <getint+0x72>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    113e <getint+0x1e>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getint>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xec9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jl     114d <getint+0x2d>
cmp    %ebx,%eax
jle    1183 <getint+0x63>
lea    0xeaf(%rip),%r14
lea    0xea5(%rip),%r15
lea    0xc(%rsp),%r12
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jl     1160 <getint+0x40>
cmp    %ebx,%eax
jg     1160 <getint+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [46 x i8] c"Invalad. Choose a number between %d and %d : \00"
define i32 @getint(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
br label %7
7: ; preds = %17, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp sgt i32 %12, %13
br label %15
15: ; preds = %11, %7
%16 = phi i1 [ true, %7 ], [ %14, %11 ]
br i1 %16, label %17, label %22
17: ; preds = %15
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19)
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
br label %7
22: ; preds = %15
%23 = load i32, i32* %5
ret i32 %23
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [46 x i8] c"Invalad. Choose a number between %d and %d : \00"
define i32 @getint(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, %0
%8 = icmp sgt i32 %6, %1
%9 = or i1 %7, %8
br i1 %9, label %10, label %17
10: ; preds = %2, %10
%11 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1)
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, %0
%15 = icmp sgt i32 %13, %1
%16 = or i1 %14, %15
br i1 %16, label %10, label %17
17: ; preds = %10, %2
%18 = phi i32 [ %6, %2 ], [ %13, %10 ]
ret i32 %18
}