#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 arrotondamento(float x);
  int valoreSentinella = -1;
  float numeroInserito;
  printf("\t\t\t\t\t%16s\t%18s ", "Numero Originale", "Numero Arrotondato");
  do {
    printf("%s", "Inserire il numero da arrotondare: ");
    scanf("%f", &numeroInserito);
    if (numeroInserito != valoreSentinella && numeroInserito > 0) {
      printf("\t\t\t\t\t%8.2f\t%10u\n", numeroInserito,
             arrotondamento(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    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
lea    0xea3(%rip),%rdi
lea    0xeac(%rip),%rsi
lea    0xeb6(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
lea    0xeb7(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    11b5 <main+0x75>
jp     11b5 <main+0x75>
jmp    11f8 <main+0xb8>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11f8 <main+0xb8>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
call   1060 <arrotondamento@plt>
movsd  -0x18(%rbp),%xmm0
mov    %eax,%esi
lea    0xe72(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1227 <main+0xe7>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    1216 <main+0xd6>
jp     1216 <main+0xd6>
jmp    1222 <main+0xe2>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
jmp    1227 <main+0xe7>
jmp    122c <main+0xec>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    1172 <main+0x32>
jp     1172 <main+0x32>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb3(%rip),%rdi
lea    0xebc(%rip),%rsi
lea    0xec6(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%r14
lea    0xec7(%rip),%r15
lea    0xee4(%rip),%r12
lea    0xc(%rsp),%rbx
lea    0xedb(%rip),%r13
lea    0xee5(%rip),%rbp
jmp    11d9 <main+0x99>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1060 <arrotondamento@plt>
mov    %r13,%rdi
movsd  0x10(%rsp),%xmm0
mov    %eax,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
movss  0xe2e(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11d9 <main+0x99>
jnp    1220 <main+0xe0>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movss  0xe07(%rip),%xmm1
movss  0xc(%rsp),%xmm0
ucomiss %xmm1,%xmm0
jne    1206 <main+0xc6>
jnp    120f <main+0xcf>
ucomiss 0xdf7(%rip),%xmm0
ja     11a0 <main+0x60>
ucomiss %xmm1,%xmm0
jne    1216 <main+0xd6>
jnp    1220 <main+0xe0>
mov    %rbp,%rdi
call   1030 <puts@plt>
jmp    11c4 <main+0x84>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\09\09\09\09\09%16s\09%18s \00"
@.str.1 = [17 x i8] c"Numero Originale\00"
@.str.2 = [19 x i8] c"Numero Arrotondato\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [36 x i8] c"Inserire il numero da arrotondare: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [17 x i8] c"\09\09\09\09\09%8.2f\09%10u\0A\00"
@.str.7 = [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
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %5
5: ; preds = %30, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %3)
%8 = load float, float* %3
%9 = load i32, i32* %2
%10 = sitofp i32 %9 to float
%11 = fcmp une float %8, %10
br i1 %11, label %12, label %21
12: ; preds = %5
%13 = load float, float* %3
%14 = fcmp ogt float %13, 0.000000e+00
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load float, float* %3
%17 = fpext float %16 to double
%18 = load float, float* %3
%19 = call i32 @arrotondamento(float %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double %17, i32 %19)
br label %29
21: ; preds = %12, %5
%22 = load float, float* %3
%23 = load i32, i32* %2
%24 = sitofp i32 %23 to float
%25 = fcmp une float %22, %24
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %26, %21
br label %29
29: ; preds = %28, %15
br label %30
30: ; preds = %29
%31 = load float, float* %3
%32 = load i32, i32* %2
%33 = sitofp i32 %32 to float
%34 = fcmp une float %31, %33
br i1 %34, label %5, label %35
35: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"\09\09\09\09\09%16s\09%18s \00"
@.str.1 = [17 x i8] c"Numero Originale\00"
@.str.2 = [19 x i8] c"Numero Arrotondato\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [36 x i8] c"Inserire il numero da arrotondare: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [17 x i8] c"\09\09\09\09\09%8.2f\09%10u\0A\00"
@.str.7 = [39 x i8] c"E' stato inserito un valore non valido\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %4
4: ; preds = %18, %0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %1)
%7 = load float, float* %1
%8 = fcmp une float %7, -1.000000e+00
%9 = fcmp ogt float %7, 0.000000e+00
%10 = and i1 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = fpext float %7 to double
%13 = call i32 @arrotondamento(float %7)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double %12, i32 %13)
br label %18
15: ; preds = %4
br i1 %8, label %16, label %21
16: ; preds = %15
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
br label %18
18: ; preds = %11, %16
%19 = load float, float* %1
%20 = fcmp une float %19, -1.000000e+00
br i1 %20, label %4, label %21
21: ; preds = %15, %18
ret i32 0
}