#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 variance_mean(double *data, double mean, int n) {
  double sum = 0;
  double z = 0;
  int i;
  for (i = 0; i < n; i++) {
    sum += pow(data[i] - mean, 2);
  }
  return sum / n;
}


x86 assembly (clang, -O0):
<variance_mean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1180 <variance_mean+0x70>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    113b <variance_mean+0x2b>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<variance_mean>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
test   %esi,%esi
jle    1150 <variance_mean+0x40>
mov    %rdi,%rbx
movapd %xmm0,%xmm1
mov    %r14d,%r12d
lea    -0x1(%r12),%rax
mov    %r12d,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
movsd  %xmm0,0x8(%rsp)
jae    1159 <variance_mean+0x49>
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
jmp    1220 <variance_mean+0x110>
xorpd  %xmm0,%xmm0
jmp    1268 <variance_mean+0x158>
and    $0xfffffffc,%r12d
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm0,(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx,%rbp,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rbx,%rbp,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rbx,%rbp,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
add    $0x4,%rbp
cmp    %rbp,%r12
jne    1170 <variance_mean+0x60>
test   %r15,%r15
je     1268 <variance_mean+0x158>
lea    (%rbx,%rbp,8),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
addsd  %xmm2,%xmm0
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1230 <variance_mean+0x120>
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
divsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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