#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 *, long *);
int main() {
  printf("Insert(*>99999): ");
  int ok = 0;
  float n;
  int x, s = 0, i = 0;
  long nr = 0;
  while (nr < 100000) {
    if (ok) {
      printf("Insert(*>99999): ");
      scanf("%ld", &nr);
    } else {
      scanf("%ld", &nr);
      ok = 1;
    }
  }
  while (x) {
    s = s + x % 10;
    x = x / 10;
    i++;
  }
  n = s / i;
  printf("Media Aritmetica: %.4f \n", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x186a0,-0x20(%rbp)
jge    11b1 <main+0x91>
cmpl   $0x0,-0x8(%rbp)
je     1195 <main+0x75>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
jmp    11ac <main+0x8c>
lea    0xe76(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
jmp    115a <main+0x3a>
jmp    11b6 <main+0x96>
cmpl   $0x0,-0x10(%rbp)
je     11f5 <main+0xd5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b6 <main+0x96>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe01(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movq   $0x0,0x8(%rsp)
lea    0xecb(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
cmpq   $0x1869f,0x8(%rsp)
jg     1190 <main+0x70>
lea    0xe9d(%rip),%r14
lea    0xea8(%rip),%r15
lea    0x8(%rsp),%rbx
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmpq   $0x186a0,0x8(%rsp)
jl     1170 <main+0x50>
lea    0xe7f(%rip),%rdi
xorps  %xmm0,%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Insert(*>99999): \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [25 x i8] c"Media Aritmetica: %.4f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
store i32 0, i32* %5
store i32 0, i32* %6
store i64 0, i64* %7
br label %9
9: ; preds = %20, %0
%10 = load i64, i64* %7
%11 = icmp slt i64 %10, 100000
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %7)
br label %20
18: ; preds = %12
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %7)
store i32 1, i32* %2
br label %20
20: ; preds = %18, %15
br label %9
21: ; preds = %9
br label %22
22: ; preds = %25, %21
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i32, i32* %5
%27 = load i32, i32* %4
%28 = srem i32 %27, 10
%29 = add nsw i32 %26, %28
store i32 %29, i32* %5
%30 = load i32, i32* %4
%31 = sdiv i32 %30, 10
store i32 %31, i32* %4
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %22
34: ; preds = %22
%35 = load i32, i32* %5
%36 = load i32, i32* %6
%37 = sdiv i32 %35, %36
%38 = sitofp i32 %37 to float
store float %38, float* %3
%39 = load float, float* %3
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Insert(*>99999): \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [25 x i8] c"Media Aritmetica: %.4f \0A\00"
define i32 @main() {
%1 = alloca i64
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%5 = load i64, i64* %1
%6 = icmp slt i64 %5, 100000
br i1 %6, label %7, label %12
7: ; preds = %0, %7
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%10 = load i64, i64* %1
%11 = icmp slt i64 %10, 100000
br i1 %11, label %7, label %12
12: ; preds = %7, %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double 0.000000e+00)
ret i32 0
}