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


x86 assembly (clang, -O0):
<quat_to_xvec>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
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
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
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,(%rax)
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
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe16(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x18(%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_xvec>:
movsd  0x18(%rsi),%xmm0
movsd  (%rsi),%xmm1
movsd  0x8(%rsi),%xmm2
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm2
subsd  %xmm2,%xmm0
movsd  0x10(%rsi),%xmm1
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rdi)
movsd  0x18(%rsi),%xmm0
mulsd  0x10(%rsi),%xmm0
movsd  (%rsi),%xmm1
mulsd  0x8(%rsi),%xmm1
subsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rdi)
movsd  0x8(%rsi),%xmm0
movsd  0x10(%rsi),%xmm1
mulsd  0x18(%rsi),%xmm0
mulsd  (%rsi),%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
movsd  %xmm1,0x10(%rdi)
ret

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