#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 /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, float *);
int main(void) {
  unsigned int numeroArrotondatoAIntero(float x);
  float numeroArrotondatoADecimi(float x);
  float numeroArrotondatoACentesimi(float x);
  float numeroArrotondatoAMigliaia(float x);
  int valoreSentinella = -1;
  float numeroInserito;
  do {
    printf("%s", "Inserire il numero da arrotondare: ");
    scanf("%f", &numeroInserito);
    if (numeroInserito != valoreSentinella && numeroInserito > 0) {
      printf("Numero Originale: \t\t\t%f\n", numeroInserito);
      printf("Numero Arrotondato a Intero: \t\t%d\n",
             numeroArrotondatoAIntero(numeroInserito));
      printf("Numero Arrotondato ai decimali: \t%f\n",
             numeroArrotondatoADecimi(numeroInserito));
      printf("Numero Arrotondato ai centesimi: \t%f\n",
             numeroArrotondatoACentesimi(numeroInserito));
      printf("Numero Arrotondato ai millesimi: \t%f\n",
             numeroArrotondatoAMigliaia(numeroInserito));
    } else if (numeroInserito != valoreSentinella) {
      puts("E' stato inserito un valore non valido");
    }
  } while (numeroInserito != valoreSentinella);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
lea    0xe73(%rip),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1090 <scanf@plt>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    11c9 <main+0x59>
jp     11c9 <main+0x59>
jmp    1264 <main+0xf4>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1264 <main+0xf4>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0xc(%rbp),%xmm0
call   1050 <numeroArrotondatoAIntero@plt>
mov    %eax,%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0xc(%rbp),%xmm0
call   1060 <numeroArrotondatoADecimi@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe46(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0xc(%rbp),%xmm0
call   1070 <numeroArrotondatoACentesimi@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe4f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0xc(%rbp),%xmm0
call   1080 <numeroArrotondatoAMigliaia@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1293 <main+0x123>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    1282 <main+0x112>
jp     1282 <main+0x112>
jmp    128e <main+0x11e>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
jmp    1293 <main+0x123>
jmp    1298 <main+0x128>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    1186 <main+0x16>
jp     1186 <main+0x16>
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    0xe86(%rip),%r14
lea    0xe82(%rip),%r15
lea    0xe9f(%rip),%r12
lea    0x4(%rsp),%rbx
lea    0xef7(%rip),%rbp
lea    0xf16(%rip),%r13
jmp    1241 <main+0xd1>
nopl   0x0(%rax,%rax,1)
cvtss2sd %xmm0,%xmm0
lea    0xe77(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
call   1050 <numeroArrotondatoAIntero@plt>
lea    0xe77(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
call   1060 <numeroArrotondatoADecimi@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe7b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
call   1070 <numeroArrotondatoACentesimi@plt>
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
call   1080 <numeroArrotondatoAMigliaia@plt>
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
movss  0xdc6(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1241 <main+0xd1>
jnp    1290 <main+0x120>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
movss  0xd9f(%rip),%xmm1
movss  0x4(%rsp),%xmm0
ucomiss %xmm1,%xmm0
jne    126e <main+0xfe>
jnp    127b <main+0x10b>
ucomiss 0xd8f(%rip),%xmm0
ja     11b0 <main+0x40>
ucomiss %xmm1,%xmm0
jne    1282 <main+0x112>
jnp    1290 <main+0x120>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
jmp    122c <main+0xbc>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [36 x i8] c"Inserire il numero da arrotondare: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [25 x i8] c"Numero Originale: \09\09\09%f\0A\00"
@.str.4 = [35 x i8] c"Numero Arrotondato a Intero: \09\09%d\0A\00"
@.str.5 = [37 x i8] c"Numero Arrotondato ai decimali: \09%f\0A\00"
@.str.6 = [38 x i8] c"Numero Arrotondato ai centesimi: \09%f\0A\00"
@.str.7 = [38 x i8] c"Numero Arrotondato ai millesimi: \09%f\0A\00"
@.str.8 = [39 x i8] c"E' stato inserito un valore non valido\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
store i32 0, i32* %1
store i32 -1, i32* %2
br label %4
4: ; preds = %42, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%7 = load float, float* %3
%8 = load i32, i32* %2
%9 = sitofp i32 %8 to float
%10 = fcmp une float %7, %9
br i1 %10, label %11, label %33
11: ; preds = %4
%12 = load float, float* %3
%13 = fcmp ogt float %12, 0.000000e+00
br i1 %13, label %14, label %33
14: ; preds = %11
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %16)
%18 = load float, float* %3
%19 = call i32 @numeroArrotondatoAIntero(float %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = load float, float* %3
%22 = call float @numeroArrotondatoADecimi(float %21)
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), double %23)
%25 = load float, float* %3
%26 = call float @numeroArrotondatoACentesimi(float %25)
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), double %27)
%29 = load float, float* %3
%30 = call float @numeroArrotondatoAMigliaia(float %29)
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), double %31)
br label %41
33: ; preds = %11, %4
%34 = load float, float* %3
%35 = load i32, i32* %2
%36 = sitofp i32 %35 to float
%37 = fcmp une float %34, %36
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %40
40: ; preds = %38, %33
br label %41
41: ; preds = %40, %14
br label %42
42: ; preds = %41
%43 = load float, float* %3
%44 = load i32, i32* %2
%45 = sitofp i32 %44 to float
%46 = fcmp une float %43, %45
br i1 %46, label %4, label %47
47: ; preds = %42
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [36 x i8] c"Inserire il numero da arrotondare: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [25 x i8] c"Numero Originale: \09\09\09%f\0A\00"
@.str.4 = [35 x i8] c"Numero Arrotondato a Intero: \09\09%d\0A\00"
@.str.5 = [37 x i8] c"Numero Arrotondato ai decimali: \09%f\0A\00"
@.str.6 = [38 x i8] c"Numero Arrotondato ai centesimi: \09%f\0A\00"
@.str.7 = [38 x i8] c"Numero Arrotondato ai millesimi: \09%f\0A\00"
@.str.8 = [39 x i8] c"E' stato inserito un valore non valido\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
br label %3
3: ; preds = %31, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%6 = load float, float* %1
%7 = fcmp une float %6, -1.000000e+00
%8 = fcmp ogt float %6, 0.000000e+00
%9 = and i1 %7, %8
br i1 %9, label %10, label %28
10: ; preds = %3
%11 = fpext float %6 to double
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %11)
%13 = load float, float* %1
%14 = call i32 @numeroArrotondatoAIntero(float %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = load float, float* %1
%17 = call float @numeroArrotondatoADecimi(float %16)
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), double %18)
%20 = load float, float* %1
%21 = call float @numeroArrotondatoACentesimi(float %20)
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), double %22)
%24 = load float, float* %1
%25 = call float @numeroArrotondatoAMigliaia(float %24)
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), double %26)
br label %31
28: ; preds = %3
br i1 %7, label %29, label %34
29: ; preds = %28
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %31
31: ; preds = %10, %29
%32 = load float, float* %1
%33 = fcmp une float %32, -1.000000e+00
br i1 %33, label %3, label %34
34: ; preds = %28, %31
ret i32 0
}