void doubles_quat_multiply(const double a[4], const double b[4], double r[4]) {
  r[0] = a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3];
  r[1] = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2];
  r[2] = a[0] * b[2] - a[1] * b[3] + a[2] * b[0] + a[3] * b[1];
  r[3] = a[0] * b[3] + a[1] * b[2] - a[2] * b[1] + a[3] * b[0];
}


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

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

LLVM IR (-O0):
define void @doubles_quat_multiply(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%7 = load double*, double** %4
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
%10 = load double*, double** %5
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = load double, double* %14
%16 = load double*, double** %5
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %17
%19 = fmul double %15, %18
%20 = fneg double %19
%21 = call double @llvm.fmuladd.f64(double %9, double %12, double %20)
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = load double*, double** %5
%26 = getelementptr inbounds double, double* %25, i64 2
%27 = load double, double* %26
%28 = fneg double %24
%29 = call double @llvm.fmuladd.f64(double %28, double %27, double %21)
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 3
%32 = load double, double* %31
%33 = load double*, double** %5
%34 = getelementptr inbounds double, double* %33, i64 3
%35 = load double, double* %34
%36 = fneg double %32
%37 = call double @llvm.fmuladd.f64(double %36, double %35, double %29)
%38 = load double*, double** %6
%39 = getelementptr inbounds double, double* %38, i64 0
store double %37, double* %39
%40 = load double*, double** %4
%41 = getelementptr inbounds double, double* %40, i64 0
%42 = load double, double* %41
%43 = load double*, double** %5
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = load double*, double** %4
%47 = getelementptr inbounds double, double* %46, i64 1
%48 = load double, double* %47
%49 = load double*, double** %5
%50 = getelementptr inbounds double, double* %49, i64 0
%51 = load double, double* %50
%52 = fmul double %48, %51
%53 = call double @llvm.fmuladd.f64(double %42, double %45, double %52)
%54 = load double*, double** %4
%55 = getelementptr inbounds double, double* %54, i64 2
%56 = load double, double* %55
%57 = load double*, double** %5
%58 = getelementptr inbounds double, double* %57, i64 3
%59 = load double, double* %58
%60 = call double @llvm.fmuladd.f64(double %56, double %59, double %53)
%61 = load double*, double** %4
%62 = getelementptr inbounds double, double* %61, i64 3
%63 = load double, double* %62
%64 = load double*, double** %5
%65 = getelementptr inbounds double, double* %64, i64 2
%66 = load double, double* %65
%67 = fneg double %63
%68 = call double @llvm.fmuladd.f64(double %67, double %66, double %60)
%69 = load double*, double** %6
%70 = getelementptr inbounds double, double* %69, i64 1
store double %68, double* %70
%71 = load double*, double** %4
%72 = getelementptr inbounds double, double* %71, i64 0
%73 = load double, double* %72
%74 = load double*, double** %5
%75 = getelementptr inbounds double, double* %74, i64 2
%76 = load double, double* %75
%77 = load double*, double** %4
%78 = getelementptr inbounds double, double* %77, i64 1
%79 = load double, double* %78
%80 = load double*, double** %5
%81 = getelementptr inbounds double, double* %80, i64 3
%82 = load double, double* %81
%83 = fmul double %79, %82
%84 = fneg double %83
%85 = call double @llvm.fmuladd.f64(double %73, double %76, double %84)
%86 = load double*, double** %4
%87 = getelementptr inbounds double, double* %86, i64 2
%88 = load double, double* %87
%89 = load double*, double** %5
%90 = getelementptr inbounds double, double* %89, i64 0
%91 = load double, double* %90
%92 = call double @llvm.fmuladd.f64(double %88, double %91, double %85)
%93 = load double*, double** %4
%94 = getelementptr inbounds double, double* %93, i64 3
%95 = load double, double* %94
%96 = load double*, double** %5
%97 = getelementptr inbounds double, double* %96, i64 1
%98 = load double, double* %97
%99 = call double @llvm.fmuladd.f64(double %95, double %98, double %92)
%100 = load double*, double** %6
%101 = getelementptr inbounds double, double* %100, i64 2
store double %99, double* %101
%102 = load double*, double** %4
%103 = getelementptr inbounds double, double* %102, i64 0
%104 = load double, double* %103
%105 = load double*, double** %5
%106 = getelementptr inbounds double, double* %105, i64 3
%107 = load double, double* %106
%108 = load double*, double** %4
%109 = getelementptr inbounds double, double* %108, i64 1
%110 = load double, double* %109
%111 = load double*, double** %5
%112 = getelementptr inbounds double, double* %111, i64 2
%113 = load double, double* %112
%114 = fmul double %110, %113
%115 = call double @llvm.fmuladd.f64(double %104, double %107, double %114)
%116 = load double*, double** %4
%117 = getelementptr inbounds double, double* %116, i64 2
%118 = load double, double* %117
%119 = load double*, double** %5
%120 = getelementptr inbounds double, double* %119, i64 1
%121 = load double, double* %120
%122 = fneg double %118
%123 = call double @llvm.fmuladd.f64(double %122, double %121, double %115)
%124 = load double*, double** %4
%125 = getelementptr inbounds double, double* %124, i64 3
%126 = load double, double* %125
%127 = load double*, double** %5
%128 = getelementptr inbounds double, double* %127, i64 0
%129 = load double, double* %128
%130 = call double @llvm.fmuladd.f64(double %126, double %129, double %123)
%131 = load double*, double** %6
%132 = getelementptr inbounds double, double* %131, i64 3
store double %130, double* %132
ret void
}

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