#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 scanf(char *, ...);
int inputControllatoIntero(void) {
  int esitoScanf;
  int intero;
  do {
    esitoScanf = scanf("%d", &intero);
    if (esitoScanf == 0) {
      printf("%s", "Attenzione non e' stato inserito un input valido, "
                   "reinserire il valore!\n");
      scanf("%*[^\n]");
    }
  } while (esitoScanf != 1);
  return intero;
}


x86 assembly (clang, -O0):
<inputControllatoIntero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1168 <inputControllatoIntero+0x48>
lea    0xeb5(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    116d <inputControllatoIntero+0x4d>
cmpl   $0x1,-0x4(%rbp)
jne    1128 <inputControllatoIntero+0x8>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inputControllatoIntero>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecc(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0xec3(%rip),%r15
lea    0xebf(%rip),%r12
lea    0xf01(%rip),%r13
jmp    1165 <inputControllatoIntero+0x45>
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
test   %eax,%eax
je     1150 <inputControllatoIntero+0x30>
cmp    $0x1,%eax
jne    1165 <inputControllatoIntero+0x45>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [73 x i8] c"Attenzione non e' stato inserito un input valido, reinserire il valore!\0A\00"
@.str.3 = [7 x i8] c"%*[^\0A]\00"
define i32 @inputControllatoIntero() {
%1 = alloca i32
%2 = alloca i32
br label %3
3: ; preds = %11, %0
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %10
10: ; preds = %7, %3
br label %11
11: ; preds = %10
%12 = load i32, i32* %1
%13 = icmp ne i32 %12, 1
br i1 %13, label %3, label %14
14: ; preds = %11
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [73 x i8] c"Attenzione non e' stato inserito un input valido, reinserire il valore!\0A\00"
@.str.3 = [7 x i8] c"%*[^\0A]\00"
define i32 @inputControllatoIntero() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %5, %0
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
switch i32 %4, label %5 [
i32 0, label %6
i32 1, label %9
]
5: ; preds = %3, %6
br label %3
6: ; preds = %3
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %5
9: ; preds = %3
%10 = load i32, i32* %1
ret i32 %10
}