#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*/ messaggi(int);
int scanf(char *, ...);
unsigned int leggi_intero(void) {
  unsigned int numero_letto;
  int esito_scanf;
  do {
    esito_scanf = scanf("%u", &numero_letto);
    if (esito_scanf == 0) {
      scanf("%*[^\n]");
      messaggi(2);
    }
  } while (esito_scanf == 0);
  return (numero_letto);
}


x86 assembly (clang, -O0):
<leggi_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    115f <leggi_intero+0x3f>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    $0x2,%edi
call   1030 <messaggi@plt>
jmp    1164 <leggi_intero+0x44>
cmpl   $0x0,-0x8(%rbp)
je     1128 <leggi_intero+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leggi_intero>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
test   %eax,%eax
jne    1185 <leggi_intero+0x65>
lea    0xebc(%rip),%r14
lea    0xeb2(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    $0x2,%edi
call   1030 <messaggi@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
test   %eax,%eax
je     1160 <leggi_intero+0x40>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [7 x i8] c"%*[^\0A]\00"
define i32 @leggi_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 @messaggi(i32 2)
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"
define i32 @leggi_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 @messaggi(i32 2)
%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
}