#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 */
scalar_t__ pow(double, int);
double promedio(double *, int);
double varianza(double arreglo[], int size) {
  double suma, var;
  double pro = promedio(arreglo, size);
  int i;
  for (i = 0; i < size; i++) {
    suma += pow(arreglo[i], 2);
  }
  var = (double)suma / pro;
  return var;
}


x86 assembly (clang, -O0):
<varianza>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <promedio@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1187 <varianza+0x67>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1147 <varianza+0x27>
movsd  -0x18(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<varianza>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <promedio@plt>
test   %ebp,%ebp
movsd  %xmm0,0x10(%rsp)
jle    1159 <varianza+0x39>
mov    %ebp,%r15d
lea    -0x1(%r15),%rax
mov    %r15d,%r14d
and    $0x3,%r14d
cmp    $0x3,%rax
jae    115e <varianza+0x3e>
xor    %ebp,%ebp
jmp    120c <varianza+0xec>
jmp    125c <varianza+0x13c>
and    $0xfffffffc,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rbx,%rbp,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx,%rbp,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rbx,%rbp,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x4,%rbp
cmp    %rbp,%r15
jne    1170 <varianza+0x50>
test   %r14,%r14
je     125c <varianza+0x13c>
lea    (%rbx,%rbp,8),%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1220 <varianza+0x100>
divsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @varianza(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%9 = load double*, double** %3
%10 = load i32, i32* %4
%11 = call double @promedio(double* %9, i32 %10)
store double %11, double* %7
store i32 0, i32* %8
br label %12
12: ; preds = %26, %2
%13 = load i32, i32* %8
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load double*, double** %3
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = call i64 @pow(double %21, i32 2)
%23 = sitofp i64 %22 to double
%24 = load double, double* %5
%25 = fadd double %24, %23
store double %25, double* %5
br label %26
26: ; preds = %16
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %12
29: ; preds = %12
%30 = load double, double* %5
%31 = load double, double* %7
%32 = fdiv double %30, %31
store double %32, double* %6
%33 = load double, double* %6
ret double %33
}

LLVM IR (-O2):
define double @varianza(double* %0, i32 %1) {
%3 = tail call double @promedio(double* %0, i32 %1)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %58
5: ; preds = %2
%6 = zext i32 %1 to i64
%7 = add nsw i64 %6, -1
%8 = and i64 %6, 3
%9 = icmp ult i64 %7, 3
br i1 %9, label %42, label %10
10: ; preds = %5
%11 = and i64 %6, 4294967292
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %39, %12 ]
%14 = phi double [ undef, %10 ], [ %38, %12 ]
%15 = phi i64 [ 0, %10 ], [ %40, %12 ]
%16 = getelementptr inbounds double, double* %0, i64 %13
%17 = load double, double* %16
%18 = tail call i64 @pow(double %17, i32 2)
%19 = sitofp i64 %18 to double
%20 = fadd double %14, %19
%21 = or i64 %13, 1
%22 = getelementptr inbounds double, double* %0, i64 %21
%23 = load double, double* %22
%24 = tail call i64 @pow(double %23, i32 2)
%25 = sitofp i64 %24 to double
%26 = fadd double %20, %25
%27 = or i64 %13, 2
%28 = getelementptr inbounds double, double* %0, i64 %27
%29 = load double, double* %28
%30 = tail call i64 @pow(double %29, i32 2)
%31 = sitofp i64 %30 to double
%32 = fadd double %26, %31
%33 = or i64 %13, 3
%34 = getelementptr inbounds double, double* %0, i64 %33
%35 = load double, double* %34
%36 = tail call i64 @pow(double %35, i32 2)
%37 = sitofp i64 %36 to double
%38 = fadd double %32, %37
%39 = add nuw nsw i64 %13, 4
%40 = add i64 %15, 4
%41 = icmp eq i64 %40, %11
br i1 %41, label %42, label %12
42: ; preds = %12, %5
%43 = phi i64 [ 0, %5 ], [ %39, %12 ]
%44 = phi double [ undef, %5 ], [ %38, %12 ]
%45 = icmp eq i64 %8, 0
br i1 %45, label %58, label %46
46: ; preds = %42, %46
%47 = phi i64 [ %55, %46 ], [ %43, %42 ]
%48 = phi double [ %54, %46 ], [ %44, %42 ]
%49 = phi i64 [ %56, %46 ], [ 0, %42 ]
%50 = getelementptr inbounds double, double* %0, i64 %47
%51 = load double, double* %50
%52 = tail call i64 @pow(double %51, i32 2)
%53 = sitofp i64 %52 to double
%54 = fadd double %48, %53
%55 = add nuw nsw i64 %47, 1
%56 = add i64 %49, 1
%57 = icmp eq i64 %56, %8
br i1 %57, label %58, label %46
58: ; preds = %42, %46, %2
%59 = phi double [ undef, %2 ], [ %44, %42 ], [ %54, %46 ]
%60 = fdiv double %59, %3
ret double %60
}