#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ validarEntrada(char *);
int leerNumero() {
  int num;
  char stringNum[5];
  do {
    printf("Ingrese numero entre 1 y 3500: \n");
    scanf("%s", stringNum);
    num = atoi(stringNum);
  } while ((num < 1) || (num > 3500) || (validarEntrada(stringNum) != 0));
  if (num != 0) {
    printf("El numero es: %d\n", num);
  } else {
    printf("No es un numero\n");
  }
  return num;
}


x86 assembly (clang, -O0):
<leerNumero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x9(%rbp),%rsi
lea    0xec0(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x9(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0xa(%rbp)
jl     11a6 <leerNumero+0x66>
mov    $0x1,%al
cmpl   $0xdac,-0x4(%rbp)
mov    %al,-0xa(%rbp)
jg     11a6 <leerNumero+0x66>
lea    -0x9(%rbp),%rdi
call   1060 <validarEntrada@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    1148 <leerNumero+0x8>
cmpl   $0x0,-0x4(%rbp)
je     11d1 <leerNumero+0x91>
mov    -0x4(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11df <leerNumero+0x9f>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leerNumero>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb6(%rip),%r14
lea    0xe9a(%rip),%r15
lea    0x3(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %r12,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
lea    -0xdad(%rbx),%eax
cmp    $0xfffff254,%eax
jb     1170 <leerNumero+0x20>
mov    %r12,%rdi
call   1070 <validarEntrada@plt>
test   %rax,%rax
jne    1170 <leerNumero+0x20>
lea    0xe55(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Ingrese numero entre 1 y 3500: \0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"El numero es: %d\0A\00"
@.str.3 = [17 x i8] c"No es un numero\0A\00"
define i32 @leerNumero() {
%1 = alloca i32
%2 = alloca [5 x i8]
br label %3
3: ; preds = %19, %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%8 = call i32 @atoi(i8* %7)
store i32 %8, i32* %1
br label %9
9: ; preds = %3
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 3500
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%17 = call i64 @validarEntrada(i8* %16)
%18 = icmp ne i64 %17, 0
br label %19
19: ; preds = %15, %12, %9
%20 = phi i1 [ true, %12 ], [ true, %9 ], [ %18, %15 ]
br i1 %20, label %3, label %21
21: ; preds = %19
%22 = load i32, i32* %1
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* %1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %29
27: ; preds = %21
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"El numero es: %d\0A\00"
@str = [32 x i8] c"Ingrese numero entre 1 y 3500: \00"
define i32 @leerNumero() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %12, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = call i32 @atoi(i8* %2)
%7 = add i32 %6, -3501
%8 = icmp ult i32 %7, -3500
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = call i64 @validarEntrada(i8* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %9, %3
br label %3
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %6)
ret i32 %6
}