#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 sqrt(double);
double compute_cov(const double *times, double mean) {
  double variance = 0;
  int i;
  for (i = 0; i < 5; ++i) {
    variance += (times[i] - mean) * (times[i] - mean);
  }
  variance /= 5;
  double cov = sqrt(variance);
  ;
  cov /= mean;
  return cov;
}


x86 assembly (clang, -O0):
<compute_cov>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    117e <compute_cov+0x6e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
subsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1130 <compute_cov+0x20>
movsd  -0x18(%rbp),%xmm0
movsd  0xe75(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_cov>:
push   %rax
movapd %xmm0,%xmm3
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
subsd  %xmm3,%xmm0
mulsd  %xmm0,%xmm0
xorpd  %xmm2,%xmm2
addsd  %xmm2,%xmm0
subsd  %xmm3,%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rdi),%xmm0
subsd  %xmm3,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0x18(%rdi),%xmm1
subsd  %xmm3,%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x20(%rdi),%xmm0
subsd  %xmm3,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe8b(%rip),%xmm0
ucomisd %xmm2,%xmm0
jb     1181 <compute_cov+0x71>
sqrtsd %xmm0,%xmm0
jmp    1190 <compute_cov+0x80>
movsd  %xmm3,(%rsp)
call   1030 <sqrt@plt>
movsd  (%rsp),%xmm3
divsd  %xmm3,%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
define double @compute_cov(double* nocapture %0, double %1) {
%3 = load double, double* %0
%4 = fsub double %3, %1
%5 = tail call double @llvm.fmuladd.f64(double %4, double %4, double 0.000000e+00)
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = fsub double %7, %1
%9 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %5)
%10 = getelementptr inbounds double, double* %0, i64 2
%11 = load double, double* %10
%12 = fsub double %11, %1
%13 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %9)
%14 = getelementptr inbounds double, double* %0, i64 3
%15 = load double, double* %14
%16 = fsub double %15, %1
%17 = tail call double @llvm.fmuladd.f64(double %16, double %16, double %13)
%18 = getelementptr inbounds double, double* %0, i64 4
%19 = load double, double* %18
%20 = fsub double %19, %1
%21 = tail call double @llvm.fmuladd.f64(double %20, double %20, double %17)
%22 = fdiv double %21, 5.000000e+00
%23 = tail call double @sqrt(double %22)
%24 = fdiv double %23, %1
ret double %24
}