#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*/ puts(char *);
int scanf(char *, ...);
unsigned int lettura_intero(void) {
  unsigned int intero;
  int esitoScanf;
  do {
    esitoScanf = scanf("%u", &intero);
    if (esitoScanf == 0) {
      scanf("%*[^\n]");
      puts("\nAttenzione valore inserito non valido, inserire un numero intero "
           "positivo: ");
    }
  } while (esitoScanf == 0);
  return (intero);
}


x86 assembly (clang, -O0):
<lettura_intero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1161 <lettura_intero+0x41>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
jmp    1166 <lettura_intero+0x46>
cmpl   $0x0,-0x8(%rbp)
je     1128 <lettura_intero+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lettura_intero>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
test   %eax,%eax
jne    1183 <lettura_intero+0x63>
lea    0xebd(%rip),%r14
lea    0xebd(%rip),%r15
lea    0xeac(%rip),%r12
lea    0x4(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
test   %eax,%eax
je     1160 <lettura_intero+0x40>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [7 x i8] c"%*[^\0A]\00"
@.str.2 = [77 x i8] c"\0AAttenzione valore inserito non valido, inserire un numero intero positivo: \00"
define i32 @lettura_intero() {
%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* %1)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @puts(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %7, %3
br label %11
11: ; preds = %10
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %3, label %14
14: ; preds = %11
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [7 x i8] c"%*[^\0A]\00"
@.str.2 = [77 x i8] c"\0AAttenzione valore inserito non valido, inserire un numero intero positivo: \00"
define i32 @lettura_intero() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0, %5
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %5, label %10
10: ; preds = %5, %0
%11 = load i32, i32* %1
ret i32 %11
}