#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 inversione(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int scanf(char *, ...);
int main(void) {
  int esitoScanf;
  int numeroDaInvertire;
  do {
    printf("Inserire l'intero positivo da invrtire: ");
    if (((esitoScanf = scanf("%d", &numeroDaInvertire)) == 0) &&
        numeroDaInvertire >= 1) {
      scanf("%*[^\n]");
      puts("Attenzione sono accettati solo interi positivi");
    }
  } while (esitoScanf == 0);
  printf("Il numero invertito e' pari a: %u",
         inversione((unsigned int)numeroDaInvertire));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    119f <main+0x5f>
cmpl   $0x1,-0xc(%rbp)
jl     119f <main+0x5f>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
jmp    11a4 <main+0x64>
cmpl   $0x0,-0x8(%rbp)
je     114f <main+0xf>
mov    -0xc(%rbp),%edi
call   1030 <inversione@plt>
mov    %eax,%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%r14
lea    0xed0(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xec7(%rip),%r12
lea    0xec7(%rip),%r13
jmp    1174 <main+0x34>
xchg   %ax,%ax
test   %ebp,%ebp
jne    11ac <main+0x6c>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1170 <main+0x30>
cmpl   $0x0,0x4(%rsp)
jle    1170 <main+0x30>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
jmp    1170 <main+0x30>
mov    0x4(%rsp),%edi
call   1030 <inversione@plt>
lea    0xea6(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Inserire l'intero positivo da invrtire: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"%*[^\0A]\00"
@.str.3 = [47 x i8] c"Attenzione sono accettati solo interi positivi\00"
@.str.4 = [34 x i8] c"Il numero invertito e' pari a: %u\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %15, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 %6, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = load i32, i32* %3
%10 = icmp sge i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @puts(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %11, %8, %4
br label %15
15: ; preds = %14
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 0
br i1 %17, label %4, label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = call i32 @inversione(i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Inserire l'intero positivo da invrtire: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"%*[^\0A]\00"
@.str.3 = [47 x i8] c"Attenzione sono accettati solo interi positivi\00"
@.str.4 = [34 x i8] c"Il numero invertito e' pari a: %u\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %13, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 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)
%6 = icmp eq i32 %5, 0
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %3, %10
br i1 %6, label %3, label %14
14: ; preds = %13
%15 = load i32, i32* %1
%16 = call i32 @inversione(i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %16)
ret i32 0
}