#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 *);
int scanf(char *, ...);
int /*<<< orphan*/ stampa_messaggi(int /*<<< orphan*/);
int lettura_intero(void) {
  int intero_letto;
  int esitoScanf;
  do {
    printf(">: ");
    esitoScanf = scanf("%d", &intero_letto);
    if (esitoScanf == 0) {
      scanf("%*[^\n]");
      stampa_messaggi(0);
    }
  } while (esitoScanf == 0);
  return (intero_letto);
}


x86 assembly (clang, -O0):
<lettura_intero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1178 <lettura_intero+0x48>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
xor    %edi,%edi
call   1040 <stampa_messaggi@plt>
jmp    117d <lettura_intero+0x4d>
cmpl   $0x0,-0x8(%rbp)
je     1138 <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    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %eax,%eax
jne    11aa <lettura_intero+0x7a>
lea    0xea5(%rip),%r14
lea    0xe97(%rip),%r15
lea    0xe94(%rip),%r12
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
xor    %edi,%edi
call   1040 <stampa_messaggi@plt>
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %eax,%eax
je     1180 <lettura_intero+0x50>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c">: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"%*[^\0A]\00"
define i32 @lettura_intero() {
%1 = alloca i32
%2 = alloca i32
br label %3
3: ; preds = %12, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
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.2, i64 0, i64 0))
%10 = call i32 @stampa_messaggi(i32 0)
br label %11
11: ; preds = %8, %3
br label %12
12: ; preds = %11
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
br i1 %14, label %3, label %15
15: ; preds = %12
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str = [4 x i8] c">: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"%*[^\0A]\00"
define i32 @lettura_intero() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, 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.2, i64 0, i64 0))
%8 = call i32 @stampa_messaggi(i32 0)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, 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
}