void Calc_Var_Stddev(Array, Mean, Var, Stddev) double Array[], Mean, *Var,
    *Stddev;
{
  int i;
  double diffs;
  diffs = 0.0;
  for (i = 0; i < 1000; i++)
    diffs += Square(Array[i] - Mean);
  *Var = diffs / 1000;
  *Stddev = sqrt(*Var);
}


x86 assembly (clang, -O0):
<Calc_Var_Stddev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3e8,-0x24(%rbp)
jge    118a <Calc_Var_Stddev+0x6a>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
call   1030 <Square@plt>
cvtsi2sd %eax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1148 <Calc_Var_Stddev+0x28>
movsd  -0x30(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <sqrt@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Calc_Var_Stddev>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%r12
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
movsd  %xmm0,0x10(%rsp)
movsd  (%r12,%rbx,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1030 <Square@plt>
movsd  0x10(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rbx
cmp    $0x3e8,%rbx
jne    1140 <Calc_Var_Stddev+0x20>
divsd  0xe81(%rip),%xmm0
movsd  %xmm0,(%r15)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1194 <Calc_Var_Stddev+0x74>
sqrtsd %xmm0,%xmm0
jmp    1199 <Calc_Var_Stddev+0x79>
call   1040 <sqrt@plt>
movsd  %xmm0,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @Calc_Var_Stddev(double* %0, double %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
store double* %0, double** %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
store double 0.000000e+00, double* %10
store i32 0, i32* %9
br label %11
11: ; preds = %26, %4
%12 = load i32, i32* %9
%13 = icmp slt i32 %12, 1000
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = load double*, double** %5
%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* %6
%21 = fsub double %19, %20
%22 = call i32 (double, ...) bitcast (i32 (...)* @Square to i32 (double, ...)*)(double %21)
%23 = sitofp i32 %22 to double
%24 = load double, double* %10
%25 = fadd double %24, %23
store double %25, double* %10
br label %26
26: ; preds = %14
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %11
29: ; preds = %11
%30 = load double, double* %10
%31 = fdiv double %30, 1.000000e+03
%32 = load double*, double** %7
store double %31, double* %32
%33 = load double*, double** %7
%34 = load double, double* %33
%35 = call double @sqrt(double %34)
%36 = load double*, double** %8
store double %35, double* %36
ret void
}

LLVM IR (-O2):
define void @Calc_Var_Stddev(double* nocapture %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
br label %5
5: ; preds = %4, %5
%6 = phi i64 [ 0, %4 ], [ %14, %5 ]
%7 = phi double [ 0.000000e+00, %4 ], [ %13, %5 ]
%8 = getelementptr inbounds double, double* %0, i64 %6
%9 = load double, double* %8
%10 = fsub double %9, %1
%11 = tail call i32 (double, ...) bitcast (i32 (...)* @Square to i32 (double, ...)*)(double %10)
%12 = sitofp i32 %11 to double
%13 = fadd double %7, %12
%14 = add nuw nsw i64 %6, 1
%15 = icmp eq i64 %14, 1000
br i1 %15, label %16, label %5
16: ; preds = %5
%17 = fdiv double %13, 1.000000e+03
store double %17, double* %2
%18 = tail call double @sqrt(double %17)
store double %18, double* %3
ret void
}