#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 */
typedef int /*<<< orphan*/ st;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int int_input(const int lower, const int upper, const char *text) {
  char st[200];
  int result;
  int number;
  printf("%s", text);
  do {
    fgets(st, sizeof(st), stdin);
    result = sscanf(st, "%d", &number);
    if (result < 1 || (number < lower || number > upper)) {
      printf("Invalid input. Enter a number between [%d, %d]: ", lower, upper);
    }
  } while (result < 1 || (number < lower || number > upper));
  return number;
}


x86 assembly (clang, -O0):
<int_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
mov    $0xc8,%esi
call   1040 <fgets@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe84(%rip),%rsi
lea    -0xe8(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0xe4(%rbp)
cmpl   $0x1,-0xe4(%rbp)
jl     11bc <int_input+0x8c>
mov    -0xe8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     11bc <int_input+0x8c>
mov    -0xe8(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11d0 <int_input+0xa0>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d5 <int_input+0xa5>
mov    $0x1,%al
cmpl   $0x1,-0xe4(%rbp)
mov    %al,-0xe9(%rbp)
jl     121f <int_input+0xef>
mov    -0xe8(%rbp),%ecx
mov    $0x1,%al
cmp    -0x4(%rbp),%ecx
mov    %al,-0xea(%rbp)
jl     1213 <int_input+0xe3>
mov    -0xe8(%rbp),%eax
cmp    -0x8(%rbp),%eax
setg   %al
mov    %al,-0xea(%rbp)
mov    -0xea(%rbp),%al
mov    %al,-0xe9(%rbp)
mov    -0xe9(%rbp),%al
test   $0x1,%al
jne    1157 <int_input+0x27>
mov    -0xe8(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_input>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xeb4(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e8b(%rip),%r13
lea    0x10(%rsp),%r14
lea    0xe9a(%rip),%r15
lea    0xc(%rsp),%r12
jmp    1182 <int_input+0x52>
lea    0xe8f(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x0(%r13),%edx
mov    %r14,%rdi
mov    $0xc8,%esi
call   1040 <fgets@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <sscanf@plt>
test   %eax,%eax
jle    1170 <int_input+0x40>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jl     11c0 <int_input+0x90>
cmp    %ebx,%eax
jg     11c0 <int_input+0x90>
cmp    %ebp,%eax
jl     1182 <int_input+0x52>
cmp    %ebx,%eax
jg     1182 <int_input+0x52>
jmp    11dc <int_input+0xac>
nopl   0x0(%rax,%rax,1)
lea    0xe3f(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jge    11b5 <int_input+0x85>
jmp    1182 <int_input+0x52>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [49 x i8] c"Invalid input. Enter a number between [%d, %d]: \00"
define i32 @int_input(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [200 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %46, %3
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 200, i32 %14)
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 1
br i1 %19, label %28, label %20
20: ; preds = %12
%21 = load i32, i32* %9
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = load i32, i32* %9
%26 = load i32, i32* %5
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24, %20, %12
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %30)
br label %32
32: ; preds = %28, %24
br label %33
33: ; preds = %32
%34 = load i32, i32* %8
%35 = icmp slt i32 %34, 1
br i1 %35, label %46, label %36
36: ; preds = %33
%37 = load i32, i32* %9
%38 = load i32, i32* %4
%39 = icmp slt i32 %37, %38
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = load i32, i32* %9
%42 = load i32, i32* %5
%43 = icmp sgt i32 %41, %42
br label %44
44: ; preds = %40, %36
%45 = phi i1 [ true, %36 ], [ %43, %40 ]
br label %46
46: ; preds = %44, %33
%47 = phi i1 [ true, %33 ], [ %45, %44 ]
br i1 %47, label %12, label %48
48: ; preds = %46
%49 = load i32, i32* %9
ret i32 %49
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [49 x i8] c"Invalid input. Enter a number between [%d, %d]: \00"
define i32 @int_input(i32 %0, i32 %1, i8* %2) {
%4 = alloca [200 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %9
9: ; preds = %29, %3
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %6, i32 200, i32 %10)
%12 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%13 = icmp slt i32 %12, 1
br i1 %13, label %22, label %14
14: ; preds = %9
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, %0
%17 = icmp sgt i32 %15, %1
%18 = or i1 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %1)
%21 = load i32, i32* %5
br label %24
22: ; preds = %9
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %1)
br label %29
24: ; preds = %14, %19
%25 = phi i32 [ %15, %14 ], [ %21, %19 ]
%26 = icmp slt i32 %25, %0
%27 = icmp sgt i32 %25, %1
%28 = or i1 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %24, %22
br label %9
30: ; preds = %24
ret i32 %25
}