#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*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
unsigned int scanf(char *, ...);
int lettura_numero(void) {
  int numero_input;
  unsigned int esito_scanf = 0;
  do {
    printf("%s", "Inserisci un numero intero da convertire: ");
    esito_scanf = scanf("%d", &numero_input);
    if (0 == esito_scanf) {
      scanf("%*[^\n]");
      puts("Input non valido");
    }
  } while (0 == esito_scanf);
  return numero_input;
}


x86 assembly (clang, -O0):
<lettura_numero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
lea    0xeba(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jne    118c <lettura_numero+0x5c>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
jmp    1191 <lettura_numero+0x61>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
je     113f <lettura_numero+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lettura_numero>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %eax,%eax
jne    11be <lettura_numero+0x8e>
lea    0xec5(%rip),%r14
lea    0xec5(%rip),%r15
lea    0xe86(%rip),%r12
lea    0xe82(%rip),%r13
lea    0xea6(%rip),%rbx
lea    0x4(%rsp),%rbp
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %eax,%eax
je     1190 <lettura_numero+0x60>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [43 x i8] c"Inserisci un numero intero da convertire: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [7 x i8] c"%*[^\0A]\00"
@.str.4 = [17 x i8] c"Input non valido\00"
define i32 @lettura_numero() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %12, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 0, %6
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %11
11: ; preds = %8, %3
br label %12
12: ; preds = %11
%13 = load i32, i32* %2
%14 = icmp eq i32 0, %13
br i1 %14, label %3, label %15
15: ; preds = %12
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [43 x i8] c"Inserisci un numero intero da convertire: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [7 x i8] c"%*[^\0A]\00"
@.str.4 = [17 x i8] c"Input non valido\00"
define i32 @lettura_numero() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %0, %6
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %6, %0
%13 = load i32, i32* %1
ret i32 %13
}