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


x86 assembly (clang, -O0):
<kappa_to_tstv>:
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
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
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
addsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
addsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
pop    %rbp
ret

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

LLVM IR (-O0):
define double @kappa_to_tstv(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 = load double*, double** %4
%13 = getelementptr inbounds double, double* %12, i64 1
%14 = load double, double* %13
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i64 3
%17 = load double, double* %16
%18 = fmul double %14, %17
%19 = call double @llvm.fmuladd.f64(double %8, double %11, double %18)
%20 = fmul double %5, %19
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = load double*, double** %4
%25 = getelementptr inbounds double, double* %24, i64 2
%26 = load double, double* %25
%27 = fadd double %23, %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 = fadd double %30, %33
%35 = fmul double %27, %34
%36 = fdiv double %20, %35
ret double %36
}

LLVM IR (-O2):
define double @kappa_to_tstv(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 = fmul <2 x double> %5, %7
%9 = extractelement <2 x double> %8, i64 1
%10 = extractelement <2 x double> %5, i64 0
%11 = extractelement <2 x double> %7, i64 0
%12 = tail call double @llvm.fmuladd.f64(double %10, double %11, double %9)
%13 = fmul double %12, %0
%14 = fadd <2 x double> %5, %7
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%16 = fmul <2 x double> %14, %15
%17 = extractelement <2 x double> %16, i64 0
%18 = fdiv double %13, %17
ret double %18
}