#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*/ free(char *);
char *get_string();
int /*<<< orphan*/ printf(char *, char *);
int strtol(char *, char **, int);
int get_int(int *x) {
  char *aux = get_string();
  int out;
  char *aux2;
  if (aux == NULL) {
    return 1;
  }
  out = strtol(aux, &aux2, 10);
  if (aux2 == aux) {
    printf("\tInvalid. Expected number, got '%s'. Please input number: ", aux);
    free(aux);
    return get_int(x);
  } else {
    free(aux);
  }
  *x = out;
  return 0;
}


x86 assembly (clang, -O0):
<get_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <get_string@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117e <get_int+0x2e>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <get_int+0x94>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11cb <get_int+0x7b>
mov    -0x18(%rbp),%rsi
lea    0xe54(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1070 <get_int@plt>
mov    %eax,-0x4(%rbp)
jmp    11e4 <get_int+0x94>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_int>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <get_string@plt>
test   %rax,%rax
je     1194 <get_int+0x44>
mov    %rax,%rbx
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1060 <strtol@plt>
cmp    %rbx,0x8(%rsp)
je     11a2 <get_int+0x52>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,(%r14)
xor    %eax,%eax
jmp    1199 <get_int+0x49>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe57(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <get_int@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"\09Invalid. Expected number, got '%s'. Please input number: \00"
define i32 @get_int(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %3
%7 = call i8* (...) @get_string()
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %30
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i32 @strtol(i8* %12, i8** %6, i32 10)
store i32 %13, i32* %5
%14 = load i8*, i8** %6
%15 = load i8*, i8** %4
%16 = icmp eq i8* %14, %15
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %4
%21 = call i32 @free(i8* %20)
%22 = load i32*, i32** %3
%23 = call i32 @get_int(i32* %22)
store i32 %23, i32* %2
br label %30
24: ; preds = %11
%25 = load i8*, i8** %4
%26 = call i32 @free(i8* %25)
br label %27
27: ; preds = %24
%28 = load i32, i32* %5
%29 = load i32*, i32** %3
store i32 %28, i32* %29
store i32 0, i32* %2
br label %30
30: ; preds = %27, %17, %10
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [59 x i8] c"\09Invalid. Expected number, got '%s'. Please input number: \00"
define i32 @get_int(i32* nocapture writeonly %0) {
%2 = alloca i8*
%3 = tail call i8* (...) @get_string()
%4 = bitcast i8** %2 to i8*
%5 = icmp eq i8* %3, null
br i1 %5, label %16, label %6
6: ; preds = %1
%7 = call i32 @strtol(i8* %3, i8** %2, i32 10)
%8 = load i8*, i8** %2
%9 = icmp eq i8* %8, %3
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = tail call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %3)
%12 = tail call i32 @free(i8* %3)
%13 = tail call i32 @get_int(i32* %0)
br label %16
14: ; preds = %6
%15 = tail call i32 @free(i8* %3)
store i32 %7, i32* %0
br label %16
16: ; preds = %1, %14, %10
%17 = phi i32 [ %13, %10 ], [ 0, %14 ], [ 1, %1 ]
ret i32 %17
}