#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
int scanf(char *, int *);
void input(int *c, char *text) {
  printf(text);
  while (scanf("%d", c) != 1) {
    printf("Inserisci un'intero non una stringa!\n");
    printf(text);
    while (getchar() != '\n')
      ;
  }
}


x86 assembly (clang, -O0):
<input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     1194 <input+0x64>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     118f <input+0x5f>
jmp    1177 <input+0x47>
jmp    1149 <input+0x19>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
je     11ab <input+0x6b>
lea    0xe92(%rip),%r15
lea    0xe88(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1190 <input+0x50>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1180 <input+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [38 x i8] c"Inserisci un'intero non una stringa!\0A\00"
define void @input(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = call i32 @printf(i8* %5)
br label %7
7: ; preds = %20, %2
%8 = load i32*, i32** %3
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%13 = load i8*, i8** %4
%14 = call i32 @printf(i8* %13)
br label %15
15: ; preds = %19, %11
%16 = call signext i8 (...) @getchar()
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %20
19: ; preds = %15
br label %15
20: ; preds = %15
br label %7
21: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [37 x i8] c"Inserisci un'intero non una stringa!\00"
define void @input(i32* %0, i8* nocapture %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) %1)
%4 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %15, label %9
6: ; preds = %12
%7 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %0)
%8 = icmp eq i32 %7, 1
br i1 %8, label %15, label %9
9: ; preds = %2, %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @printf(i8* dereferenceable(1) %1)
br label %12
12: ; preds = %12, %9
%13 = tail call signext i8 (...) @getchar()
%14 = icmp eq i8 %13, 10
br i1 %14, label %6, label %12
15: ; preds = %6, %2
ret void
}