void quat_to_yvec(double vec[3], double quat[4]) {
  vec[0] = 2.0 * (quat[0] * quat[1] + quat[2] * quat[3]);
  vec[1] = ((quat[3]) * (quat[3])) - ((quat[0]) * (quat[0])) +
           ((quat[1]) * (quat[1])) - ((quat[2]) * (quat[2]));
  vec[2] = 2.0 * (quat[1] * quat[2] - quat[0] * quat[3]);
}


x86 assembly (clang, -O0):
<quat_to_yvec>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xec1(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdd6(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<quat_to_yvec>:
movsd  0x10(%rsi),%xmm0
mulsd  0x18(%rsi),%xmm0
movsd  (%rsi),%xmm1
mulsd  0x8(%rsi),%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
movsd  %xmm1,(%rdi)
movsd  0x18(%rsi),%xmm0
movsd  (%rsi),%xmm1
movsd  0x8(%rsi),%xmm2
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
movsd  0x10(%rsi),%xmm0
mulsd  %xmm0,%xmm0
subsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rdi)
movsd  0x8(%rsi),%xmm0
movsd  0x18(%rsi),%xmm1
mulsd  (%rsi),%xmm1
mulsd  0x10(%rsi),%xmm0
subsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rdi)
ret

LLVM IR (-O0):
define void @quat_to_yvec(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
store double* %0, double** %3
store double* %1, double** %4
%5 = load double*, double** %4
%6 = getelementptr inbounds double, double* %5, i64 0
%7 = load double, double* %6
%8 = load double*, double** %4
%9 = getelementptr inbounds double, double* %8, i64 1
%10 = load double, double* %9
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 2
%13 = load double, double* %12
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 3
%16 = load double, double* %15
%17 = fmul double %13, %16
%18 = call double @llvm.fmuladd.f64(double %7, double %10, double %17)
%19 = fmul double 2.000000e+00, %18
%20 = load double*, double** %3
%21 = getelementptr inbounds double, double* %20, i64 0
store double %19, double* %21
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 3
%24 = load double, double* %23
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 3
%27 = load double, double* %26
%28 = load double*, double** %4
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double, double* %29
%31 = load double*, double** %4
%32 = getelementptr inbounds double, double* %31, i64 0
%33 = load double, double* %32
%34 = fmul double %30, %33
%35 = fneg double %34
%36 = call double @llvm.fmuladd.f64(double %24, double %27, double %35)
%37 = load double*, double** %4
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
%40 = load double*, double** %4
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = call double @llvm.fmuladd.f64(double %39, double %42, double %36)
%44 = load double*, double** %4
%45 = getelementptr inbounds double, double* %44, i64 2
%46 = load double, double* %45
%47 = load double*, double** %4
%48 = getelementptr inbounds double, double* %47, i64 2
%49 = load double, double* %48
%50 = fneg double %46
%51 = call double @llvm.fmuladd.f64(double %50, double %49, double %43)
%52 = load double*, double** %3
%53 = getelementptr inbounds double, double* %52, i64 1
store double %51, double* %53
%54 = load double*, double** %4
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = load double, double* %55
%57 = load double*, double** %4
%58 = getelementptr inbounds double, double* %57, i64 2
%59 = load double, double* %58
%60 = load double*, double** %4
%61 = getelementptr inbounds double, double* %60, i64 0
%62 = load double, double* %61
%63 = load double*, double** %4
%64 = getelementptr inbounds double, double* %63, i64 3
%65 = load double, double* %64
%66 = fmul double %62, %65
%67 = fneg double %66
%68 = call double @llvm.fmuladd.f64(double %56, double %59, double %67)
%69 = fmul double 2.000000e+00, %68
%70 = load double*, double** %3
%71 = getelementptr inbounds double, double* %70, i64 2
store double %69, double* %71
ret void
}

LLVM IR (-O2):
define void @quat_to_yvec(double* nocapture writeonly %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = getelementptr inbounds double, double* %1, i64 1
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %1, i64 2
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %1, i64 3
%9 = load double, double* %8
%10 = fmul double %7, %9
%11 = tail call double @llvm.fmuladd.f64(double %3, double %5, double %10)
%12 = fmul double %11, 2.000000e+00
store double %12, double* %0
%13 = load double, double* %8
%14 = load double, double* %1
%15 = fneg double %14
%16 = fmul double %14, %15
%17 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %16)
%18 = load double, double* %4
%19 = tail call double @llvm.fmuladd.f64(double %18, double %18, double %17)
%20 = load double, double* %6
%21 = fneg double %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double %20, double %19)
%23 = getelementptr inbounds double, double* %0, i64 1
store double %22, double* %23
%24 = load double, double* %4
%25 = load double, double* %6
%26 = load double, double* %1
%27 = load double, double* %8
%28 = fneg double %26
%29 = fmul double %27, %28
%30 = tail call double @llvm.fmuladd.f64(double %24, double %25, double %29)
%31 = fmul double %30, 2.000000e+00
%32 = getelementptr inbounds double, double* %0, i64 2
store double %31, double* %32
ret void
}