#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 */
scalar_t__ errno;
scalar_t__ is_int_p(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rstdin_s(char *, int);
int strtol(char *, int /*<<< orphan*/ *, int);
int rstdin_d(void) {
  char d[256];
  int ret;
  rstdin_s(d, sizeof d);
  if (is_int_p(d)) {
    ret = strtol(d, NULL, 10);
    if (errno) {
      printf("error encontrado intente de nuevo.\n");
      return rstdin_d();
    }
    return ret;
  } else {
    printf("%s no es un numero, intente de nuevo: ", d);
    return rstdin_d();
  }
}


x86 assembly (clang, -O0):
<rstdin_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   1030 <rstdin_s@plt>
lea    -0x110(%rbp),%rdi
call   1040 <is_int_p@plt>
cmp    $0x0,%rax
je     11d7 <rstdin_d+0x87>
lea    -0x110(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x114(%rbp)
mov    0x2e3c(%rip),%rax
cmpq   $0x0,(%rax)
je     11c9 <rstdin_d+0x79>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
call   1070 <rstdin_d@plt>
mov    %eax,-0x4(%rbp)
jmp    11f4 <rstdin_d+0xa4>
mov    -0x114(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f4 <rstdin_d+0xa4>
lea    -0x110(%rbp),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
call   1070 <rstdin_d@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rstdin_d>:
push   %rbx
sub    $0x100,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1030 <rstdin_s@plt>
mov    %rbx,%rdi
call   1050 <is_int_p@plt>
test   %rax,%rax
je     11af <rstdin_d+0x4f>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    0x2e45(%rip),%rcx
cmpq   $0x0,(%rcx)
je     11c5 <rstdin_d+0x65>
lea    0xe7f(%rip),%rdi
call   1040 <puts@plt>
jmp    11c0 <rstdin_d+0x60>
lea    0xe4a(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
call   1080 <rstdin_d@plt>
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [36 x i8] c"error encontrado intente de nuevo.\0A\00"
@.str.1 = [39 x i8] c"%s no es un numero, intente de nuevo: \00"
define i32 @rstdin_d() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = call i32 @rstdin_s(i8* %4, i32 256)
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = call i64 @is_int_p(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = call i32 @strtol(i8* %10, i32* null, i32 10)
store i32 %11, i32* %3
%12 = load i64, i64* @errno
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @rstdin_d()
store i32 %16, i32* %1
br label %23
17: ; preds = %9
%18 = load i32, i32* %3
store i32 %18, i32* %1
br label %23
19: ; preds = %0
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i32 @rstdin_d()
store i32 %22, i32* %1
br label %23
23: ; preds = %19, %17, %14
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@errno = global i64 0
@.str.1 = [39 x i8] c"%s no es un numero, intente de nuevo: \00"
@str = [35 x i8] c"error encontrado intente de nuevo.\00"
define i32 @rstdin_d() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 @rstdin_s(i8* %2, i32 256)
%4 = call i64 @is_int_p(i8* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %0
%7 = call i32 @strtol(i8* nocapture %2, i32* null, i32 10)
%8 = load i64, i64* @errno
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %6
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %14
14: ; preds = %10, %12
%15 = call i32 @rstdin_d()
br label %16
16: ; preds = %14, %6
%17 = phi i32 [ %7, %6 ], [ %15, %14 ]
ret i32 %17
}