double scalingCoefficient(int n_exp, double *experimental, double *theoretical,
                          double *sigma) {
  int i = 0;
  double c = 0.0;
  double tempSum1 = 0.0;
  double tempSum2 = 0.0;
  for (i = 0; i < n_exp; i++) {
    double sigmaSqrd = (sigma[i] * sigma[i]);
    tempSum1 += ((experimental[i] * theoretical[i]) / sigmaSqrd);
    tempSum2 += ((theoretical[i] * theoretical[i]) / sigmaSqrd);
  }
  c = (tempSum1 / tempSum2);
  return c;
}


x86 assembly (clang, -O0):
<scalingCoefficient>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c4 <scalingCoefficient+0xc4>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
divsd  -0x48(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
divsd  -0x48(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1139 <scalingCoefficient+0x39>
movsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<scalingCoefficient>:
test   %edi,%edi
jle    1151 <scalingCoefficient+0x51>
mov    %edi,%eax
xorpd  %xmm1,%xmm1
xor    %edi,%edi
nopl   0x0(%rax)
movsd  (%rcx,%rdi,8),%xmm0
movsd  (%rdx,%rdi,8),%xmm2
movapd %xmm2,%xmm3
movhpd (%rsi,%rdi,8),%xmm3
mulsd  %xmm0,%xmm0
unpcklpd %xmm2,%xmm2
mulpd  %xmm3,%xmm2
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm2
addpd  %xmm2,%xmm1
add    $0x1,%rdi
cmp    %rdi,%rax
jne    1110 <scalingCoefficient+0x10>
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
divsd  %xmm1,%xmm0
ret
movsd  0xea7(%rip),%xmm0
ret

LLVM IR (-O0):
define double @scalingCoefficient(i32 %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store i32 0, i32* %9
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
store i32 0, i32* %9
br label %14
14: ; preds = %60, %4
%15 = load i32, i32* %9
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %63
18: ; preds = %14
%19 = load double*, double** %8
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = load double*, double** %8
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = fmul double %23, %28
store double %29, double* %13
%30 = load double*, double** %6
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = load double*, double** %7
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fmul double %34, %39
%41 = load double, double* %13
%42 = fdiv double %40, %41
%43 = load double, double* %11
%44 = fadd double %43, %42
store double %44, double* %11
%45 = load double*, double** %7
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
%50 = load double*, double** %7
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
%54 = load double, double* %53
%55 = fmul double %49, %54
%56 = load double, double* %13
%57 = fdiv double %55, %56
%58 = load double, double* %12
%59 = fadd double %58, %57
store double %59, double* %12
br label %60
60: ; preds = %18
%61 = load i32, i32* %9
%62 = add nsw i32 %61, 1
store i32 %62, i32* %9
br label %14
63: ; preds = %14
%64 = load double, double* %11
%65 = load double, double* %12
%66 = fdiv double %64, %65
store double %66, double* %10
%67 = load double, double* %10
ret double %67
}

LLVM IR (-O2):
define double @scalingCoefficient(i32 %0, double* nocapture %1, double* nocapture %2, double* nocapture %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %32
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %26, %8 ]
%10 = phi <2 x double> [ zeroinitializer, %6 ], [ %25, %8 ]
%11 = getelementptr inbounds double, double* %3, i64 %9
%12 = load double, double* %11
%13 = fmul double %12, %12
%14 = getelementptr inbounds double, double* %1, i64 %9
%15 = load double, double* %14
%16 = getelementptr inbounds double, double* %2, i64 %9
%17 = load double, double* %16
%18 = insertelement <2 x double> poison, double %17, i64 0
%19 = insertelement <2 x double> %18, double %15, i64 1
%20 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
%21 = fmul <2 x double> %19, %20
%22 = insertelement <2 x double> poison, double %13, i64 0
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
%24 = fdiv <2 x double> %21, %23
%25 = fadd <2 x double> %10, %24
%26 = add nuw nsw i64 %9, 1
%27 = icmp eq i64 %26, %7
br i1 %27, label %28, label %8
28: ; preds = %8
%29 = extractelement <2 x double> %25, i64 0
%30 = extractelement <2 x double> %25, i64 1
%31 = fdiv double %30, %29
br label %32
32: ; preds = %28, %4
%33 = phi double [ %31, %28 ], [ 0x7FF8000000000000, %4 ]
ret double %33
}