double owl_stats_skew_stable(double *x, double mean, double std, int n) {
  double t = 0;
  for (int i = 0; i < n; i++) {
    double d = (*(x + i) - mean) / std;
    t += (d * d * d - t) / (i + 1);
  }
  return t;
}


x86 assembly (clang, -O0):
<owl_stats_skew_stable>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11a5 <owl_stats_skew_stable+0xa5>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1124 <owl_stats_skew_stable+0x24>
movsd  -0x28(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<owl_stats_skew_stable>:
test   %esi,%esi
jle    114e <owl_stats_skew_stable+0x4e>
mov    %esi,%eax
xorpd  %xmm3,%xmm3
xor    %ecx,%ecx
nopl   0x0(%rax)
movsd  (%rdi,%rcx,8),%xmm4
subsd  %xmm0,%xmm4
divsd  %xmm1,%xmm4
movapd %xmm4,%xmm2
mulsd  %xmm4,%xmm2
mulsd  %xmm4,%xmm2
add    $0x1,%rcx
xorps  %xmm4,%xmm4
cvtsi2sd %ecx,%xmm4
subsd  %xmm3,%xmm2
divsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movapd %xmm2,%xmm3
cmp    %rcx,%rax
jne    1110 <owl_stats_skew_stable+0x10>
movapd %xmm2,%xmm0
ret
xorps  %xmm2,%xmm2
movaps %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @owl_stats_skew_stable(double* %0, double %1, double %2, i32 %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
%11 = alloca double
store double* %0, double** %5
store double %1, double* %6
store double %2, double* %7
store i32 %3, i32* %8
store double 0.000000e+00, double* %9
store i32 0, i32* %10
br label %12
12: ; preds = %39, %4
%13 = load i32, i32* %10
%14 = load i32, i32* %8
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %42
16: ; preds = %12
%17 = load double*, double** %5
%18 = load i32, i32* %10
%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 = load double, double* %7
%25 = fdiv double %23, %24
store double %25, double* %11
%26 = load double, double* %11
%27 = load double, double* %11
%28 = fmul double %26, %27
%29 = load double, double* %11
%30 = load double, double* %9
%31 = fneg double %30
%32 = call double @llvm.fmuladd.f64(double %28, double %29, double %31)
%33 = load i32, i32* %10
%34 = add nsw i32 %33, 1
%35 = sitofp i32 %34 to double
%36 = fdiv double %32, %35
%37 = load double, double* %9
%38 = fadd double %37, %36
store double %38, double* %9
br label %39
39: ; preds = %16
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 1
store i32 %41, i32* %10
br label %12
42: ; preds = %12
%43 = load double, double* %9
ret double %43
}

LLVM IR (-O2):
define double @owl_stats_skew_stable(double* nocapture %0, double %1, double %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %10
8: ; preds = %10, %4
%9 = phi double [ 0.000000e+00, %4 ], [ %24, %10 ]
ret double %9
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %20, %10 ]
%12 = phi double [ 0.000000e+00, %6 ], [ %24, %10 ]
%13 = getelementptr inbounds double, double* %0, i64 %11
%14 = load double, double* %13
%15 = fsub double %14, %1
%16 = fdiv double %15, %2
%17 = fmul double %16, %16
%18 = fneg double %12
%19 = tail call double @llvm.fmuladd.f64(double %17, double %16, double %18)
%20 = add nuw nsw i64 %11, 1
%21 = trunc i64 %20 to i32
%22 = sitofp i32 %21 to double
%23 = fdiv double %19, %22
%24 = fadd double %12, %23
%25 = icmp eq i64 %20, %7
br i1 %25, label %8, label %10
}