double _tstv_to_kappa(double tstv, const double *freqs) {
  return (tstv * (freqs[0] + freqs[2]) * (freqs[1] + freqs[3])) /
         ((freqs[0] * freqs[2]) + (freqs[1] * freqs[3]));
}


x86 assembly (clang, -O0):
<_tstv_to_kappa>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
addsd  0x10(%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
addsd  0x18(%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm3
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<_tstv_to_kappa>:
movupd (%rdi),%xmm1
movupd 0x10(%rdi),%xmm2
movapd %xmm1,%xmm3
addpd  %xmm2,%xmm3
mulsd  %xmm3,%xmm0
unpckhpd %xmm3,%xmm3
mulsd  %xmm3,%xmm0
movapd %xmm1,%xmm3
mulpd  %xmm2,%xmm3
unpckhpd %xmm3,%xmm3
mulsd  %xmm2,%xmm1
addsd  %xmm3,%xmm1
divsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @_tstv_to_kappa(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
store double %0, double* %3
store double* %1, double** %4
%5 = load double, double* %3
%6 = load double*, double** %4
%7 = getelementptr inbounds double, double* %6, i64 0
%8 = load double, double* %7
%9 = load double*, double** %4
%10 = getelementptr inbounds double, double* %9, i64 2
%11 = load double, double* %10
%12 = fadd double %8, %11
%13 = fmul double %5, %12
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 3
%19 = load double, double* %18
%20 = fadd double %16, %19
%21 = fmul double %13, %20
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 0
%24 = load double, double* %23
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 2
%27 = load double, double* %26
%28 = load double*, double** %4
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = load double*, double** %4
%32 = getelementptr inbounds double, double* %31, i64 3
%33 = load double, double* %32
%34 = fmul double %30, %33
%35 = call double @llvm.fmuladd.f64(double %24, double %27, double %34)
%36 = fdiv double %21, %35
ret double %36
}

LLVM IR (-O2):
define double @_tstv_to_kappa(double %0, double* nocapture %1) {
%3 = getelementptr inbounds double, double* %1, i64 2
%4 = bitcast double* %1 to <2 x double>*
%5 = load <2 x double>, <2 x double>* %4
%6 = bitcast double* %3 to <2 x double>*
%7 = load <2 x double>, <2 x double>* %6
%8 = fadd <2 x double> %5, %7
%9 = extractelement <2 x double> %8, i64 0
%10 = fmul double %9, %0
%11 = extractelement <2 x double> %8, i64 1
%12 = fmul double %10, %11
%13 = fmul <2 x double> %5, %7
%14 = extractelement <2 x double> %13, i64 1
%15 = extractelement <2 x double> %5, i64 0
%16 = extractelement <2 x double> %7, i64 0
%17 = tail call double @llvm.fmuladd.f64(double %15, double %16, double %14)
%18 = fdiv double %12, %17
ret double %18
}