#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 */
double mean(double *, int);
double pow(double, int);
double population_variance(double values[], int count) {
  int i = 0;
  double u = mean(values, count);
  double sum = 0.0;
  while (i < count) {
    sum = sum + pow((values[i] - u), 2);
    i++;
  }
  return sum / count;
}


x86 assembly (clang, -O0):
<population_variance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <mean@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a0 <population_variance+0x80>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <population_variance+0x2f>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<population_variance>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
call   1040 <mean@plt>
test   %r14d,%r14d
jle    1166 <population_variance+0x46>
mov    %r14d,%r12d
lea    -0x1(%r12),%rax
mov    %r12d,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
movsd  %xmm0,0x8(%rsp)
jae    116f <population_variance+0x4f>
xorpd  %xmm2,%xmm2
xor    %ebp,%ebp
movapd %xmm0,%xmm1
jmp    1214 <population_variance+0xf4>
xorpd  %xmm2,%xmm2
jmp    1250 <population_variance+0x130>
and    $0xfffffffc,%r12d
xorpd  %xmm2,%xmm2
xor    %ebp,%ebp
movapd %xmm0,%xmm1
nopl   (%rax)
movsd  %xmm2,(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx,%rbp,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rbx,%rbp,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
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
movapd %xmm0,%xmm2
addsd  (%rsp),%xmm2
add    $0x4,%rbp
cmp    %rbp,%r12
jne    1180 <population_variance+0x60>
test   %r15,%r15
je     1250 <population_variance+0x130>
lea    (%rbx,%rbp,8),%rbx
xor    %ebp,%ebp
nop
movsd  %xmm2,(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm2
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1220 <population_variance+0x100>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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