#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() {
  int i, suma = 0, cont = 0;
  printf("\nIntroduzca los valores para calcular la media.");
  do {
    printf("\nNúmero: ");
    scanf("%i", &i);
    suma += i;
    if (i != 0)
      cont++;
  } while (i != 0);
  if (cont != 0)
    printf("\nLa Media Es: %5.f", (float)suma / cont);
  else
    printf("\nNo hubo números");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1185 <main+0x65>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118a <main+0x6a>
cmpl   $0x0,-0x8(%rbp)
jne    114b <main+0x2b>
cmpl   $0x0,-0x10(%rbp)
je     11c3 <main+0xa3>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe87(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11d1 <main+0xb1>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
lea    0xeea(%rip),%r14
lea    0xeee(%rip),%r15
lea    0xc(%rsp),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
add    %eax,%ebx
add    $0x1,%ebp
test   %eax,%eax
jne    1160 <main+0x40>
test   %ebp,%ebp
je     11a6 <main+0x86>
cvtsi2ss %ebx,%xmm0
cvtsi2ss %ebp,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11b4 <main+0x94>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"\0AIntroduzca los valores para calcular la media.\00"
@.str.1 = [11 x i8] c"\0AN\C3\BAmero: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [19 x i8] c"\0ALa Media Es: %5.f\00"
@.str.4 = [18 x i8] c"\0ANo hubo n\C3\BAmeros\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %18, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 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* %2)
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = add nsw i32 %10, %9
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %6
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %17
17: ; preds = %14, %6
br label %18
18: ; preds = %17
%19 = load i32, i32* %2
%20 = icmp ne i32 %19, 0
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 %32
24: ; preds = %21
%25 = load i32, i32* %3
%26 = sitofp i32 %25 to float
%27 = load i32, i32* %4
%28 = sitofp i32 %27 to float
%29 = fdiv float %26, %28
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %30)
br label %34
32: ; preds = %21
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32, %24
ret i32 0
}

LLVM IR (-O2):
@.str = [48 x i8] c"\0AIntroduzca los valores para calcular la media.\00"
@.str.1 = [11 x i8] c"\0AN\C3\BAmero: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [19 x i8] c"\0ALa Media Es: %5.f\00"
@.str.4 = [18 x i8] c"\0ANo hubo n\C3\BAmeros\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %4, %0
%5 = phi i32 [ 0, %0 ], [ %10, %4 ]
%6 = phi i32 [ 0, %0 ], [ %12, %4 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 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* %1)
%9 = load i32, i32* %1
%10 = add nsw i32 %9, %5
%11 = icmp eq i32 %9, 0
%12 = add nuw nsw i32 %6, 1
br i1 %11, label %13, label %4
13: ; preds = %4
%14 = icmp eq i32 %6, 0
br i1 %14, label %21, label %15
15: ; preds = %13
%16 = sitofp i32 %10 to float
%17 = sitofp i32 %6 to float
%18 = fdiv float %16, %17
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %19)
br label %23
21: ; preds = %13
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %21, %15
ret i32 0
}