#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*/ scanf(char *, int *);
int main(void) {
  float mediaInteri;
  int numeroInput;
  int sommaInput = 0;
  unsigned int contatoreInserimenti = 0;
  do {
    printf("%s", "Inserire l'intero su cui calcolare la media (inserisci 9999 "
                 "per uscire): ");
    scanf("%d", &numeroInput);
    if (9999 != numeroInput) {
      sommaInput += numeroInput;
      contatoreInserimenti++;
    }
  } while (numeroInput != (int)9999);
  if (sommaInput != 0)
    mediaInteri = (sommaInput / contatoreInserimenti);
  else
    mediaInteri = 0;
  printf("La media dei %u numeri inseriti e' pari a: %.2f",
         contatoreInserimenti, mediaInteri);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xebc(%rip),%rdi
lea    0xeb8(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x270f,%eax
cmp    -0xc(%rbp),%eax
je     1182 <main+0x62>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1187 <main+0x67>
cmpl   $0x270f,-0xc(%rbp)
jne    113d <main+0x1d>
cmpl   $0x0,-0x10(%rbp)
je     11b7 <main+0x97>
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
xor    %edx,%edx
div    %ecx
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11bf <main+0x9f>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x14(%rbp),%esi
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
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
push   %rax
mov    $0xffffffff,%ebx
lea    0xec9(%rip),%r14
lea    0xec5(%rip),%r15
lea    0xf08(%rip),%r13
lea    0x4(%rsp),%rbp
xor    %eax,%eax
nopl   0x0(%rax)
mov    %eax,%r12d
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
lea    (%rcx,%r12,1),%eax
add    $0x1,%ebx
cmp    $0x270f,%ecx
jne    1150 <main+0x30>
test   %r12d,%r12d
je     1195 <main+0x75>
mov    %r12d,%eax
xor    %edx,%edx
div    %ebx
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
jmp    1198 <main+0x78>
xorps  %xmm0,%xmm0
lea    0xeb1(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1030 <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 = [3 x i8] c"%s\00"
@.str.1 = [74 x i8] c"Inserire l'intero su cui calcolare la media (inserisci 9999 per uscire): \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [48 x i8] c"La media dei %u numeri inseriti e' pari a: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %18, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp ne i32 9999, %9
br i1 %10, label %11, label %17
11: ; preds = %6
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = add nsw i32 %13, %12
store i32 %14, i32* %4
%15 = load i32, i32* %5
%16 = add i32 %15, 1
store i32 %16, i32* %5
br label %17
17: ; preds = %11, %6
br label %18
18: ; preds = %17
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 9999
br i1 %20, label %6, label %21
21: ; preds = %18
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = udiv i32 %25, %26
%28 = uitofp i32 %27 to float
store float %28, float* %2
br label %30
29: ; preds = %21
store float 0.000000e+00, float* %2
br label %30
30: ; preds = %29, %24
%31 = load i32, i32* %5
%32 = load float, float* %2
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %31, double %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [74 x i8] c"Inserire l'intero su cui calcolare la media (inserisci 9999 per uscire): \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [48 x i8] c"La media dei %u numeri inseriti e' pari a: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = phi i32 [ 0, %0 ], [ %10, %3 ]
%5 = phi i32 [ 0, %0 ], [ %11, %3 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 9999
%10 = add nsw i32 %8, %4
%11 = add i32 %5, 1
br i1 %9, label %12, label %3
12: ; preds = %3
%13 = icmp eq i32 %4, 0
br i1 %13, label %18, label %14
14: ; preds = %12
%15 = udiv i32 %4, %5
%16 = uitofp i32 %15 to float
%17 = fpext float %16 to double
br label %18
18: ; preds = %12, %14
%19 = phi double [ %17, %14 ], [ 0.000000e+00, %12 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %5, double %19)
ret i32 0
}