#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 *);
ler_intervalo(int min, int max) {
  int num;
  do {
    scanf("%d", &num);
    getchar();
    if (num < min || num > max)
      printf("\nO valor fornecido eh invalido! Digite novamente!\n");
  } 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    $0x0,%al
call   1040 <getchar@plt>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     116d <ler_intervalo+0x3d>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1179 <ler_intervalo+0x49>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
jmp    117e <ler_intervalo+0x4e>
mov    -0xc(%rbp),%ecx
mov    $0x1,%al
cmp    -0x4(%rbp),%ecx
mov    %al,-0xd(%rbp)
jl     119b <ler_intervalo+0x6b>
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>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jl     1190 <ler_intervalo+0x60>
cmp    %ebx,%eax
jg     1190 <ler_intervalo+0x60>
cmp    %ebp,%eax
jl     1160 <ler_intervalo+0x30>
cmp    %ebx,%eax
jg     1160 <ler_intervalo+0x30>
jmp    11a2 <ler_intervalo+0x72>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jge    1182 <ler_intervalo+0x52>
jmp    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 = call i32 (...) @getchar()
%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 = %6
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12, %6
%17 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
br label %19
19: ; preds = %18
%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 = %15, %2
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = call i32 (...) @getchar()
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, %0
%10 = icmp sgt i32 %8, %1
%11 = or i1 %9, %10
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* %3
br label %15
15: ; preds = %5, %12
%16 = phi i32 [ %8, %5 ], [ %14, %12 ]
%17 = icmp slt i32 %16, %0
%18 = icmp sgt i32 %16, %1
%19 = or i1 %17, %18
br i1 %19, label %5, label %20
20: ; preds = %15
ret i32 %16
}