#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*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int ler_intervalo(int min, int max) {
  int num;
  do {
    scanf("%d", &num);
    if (num < min || num > max)
      printf("\nO valor fornecido eh invalido! Digite novamente!\n");
    getchar();
  } while (num < min || num > max);
  return num;
}


x86 assembly (clang, -O0):
<ler_intervalo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xebb(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     1166 <ler_intervalo+0x36>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1172 <ler_intervalo+0x42>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0xc(%rbp),%ecx
mov    $0x1,%al
cmp    -0x4(%rbp),%ecx
mov    %al,-0xd(%rbp)
jl     1196 <ler_intervalo+0x66>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
setg   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    113e <ler_intervalo+0xe>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ler_intervalo>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xeb9(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xeb0(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jl     1177 <ler_intervalo+0x47>
cmp    %ebx,%eax
jle    117f <ler_intervalo+0x4f>
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jl     1160 <ler_intervalo+0x30>
cmp    %ebx,%eax
jg     1160 <ler_intervalo+0x30>
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 = [51 x i8] c"\0AO valor fornecido eh invalido! Digite novamente!\0A\00"
define i32 @ler_intervalo(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 = %27, %2
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%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 = %6
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp sgt i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11, %6
%16 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %11
%18 = call i32 (...) @getchar()
br label %19
19: ; preds = %17
%20 = load i32, i32* %5
%21 = load i32, i32* %3
%22 = icmp slt i32 %20, %21
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i32, i32* %5
%25 = load i32, i32* %4
%26 = icmp sgt i32 %24, %25
br label %27
27: ; preds = %23, %19
%28 = phi i1 [ true, %19 ], [ %26, %23 ]
br i1 %28, label %6, label %29
29: ; preds = %27
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [50 x i8] c"\0AO valor fornecido eh invalido! Digite novamente!\00"
define i32 @ler_intervalo(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %13, %2
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, 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 %13
11: ; preds = %5
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %5, %11
%14 = call i32 (...) @getchar()
%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 %5, label %19
19: ; preds = %13
ret i32 %15
}