void mulmn(double *result, const double *s1, const double *s2) {
  const double x = s1[(0 + (0 << 2))] * s2[0] + s1[(1 + (0 << 2))] * s2[1] +
                   s1[(2 + (0 << 2))] * s2[2];
  const double y = s1[(0 + (1 << 2))] * s2[0] + s1[(1 + (1 << 2))] * s2[1] +
                   s1[(2 + (1 << 2))] * s2[2];
  const double z = s1[(0 + (2 << 2))] * s2[0] + s1[(1 + (2 << 2))] * s2[1] +
                   s1[(2 + (2 << 2))] * s2[2];
  result[0] = x;
  result[1] = y;
  result[2] = z;
}


x86 assembly (clang, -O0):
<mulmn>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x40(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x48(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x50(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mulmn>:
movsd  (%rdx),%xmm0
movsd  0x8(%rdx),%xmm2
movsd  0x10(%rdx),%xmm1
movapd %xmm2,%xmm3
unpcklpd %xmm2,%xmm3
movsd  (%rsi),%xmm4
movsd  0x8(%rsi),%xmm5
movsd  0x10(%rsi),%xmm6
movhpd 0x28(%rsi),%xmm5
mulpd  %xmm3,%xmm5
movhpd 0x20(%rsi),%xmm4
movapd %xmm0,%xmm3
unpcklpd %xmm0,%xmm3
mulpd  %xmm4,%xmm3
addpd  %xmm5,%xmm3
movhpd 0x30(%rsi),%xmm6
movapd %xmm1,%xmm4
unpcklpd %xmm1,%xmm4
mulpd  %xmm6,%xmm4
addpd  %xmm3,%xmm4
mulsd  0x48(%rsi),%xmm2
mulsd  0x40(%rsi),%xmm0
mulsd  0x50(%rsi),%xmm1
addsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
movupd %xmm4,(%rdi)
movsd  %xmm1,0x10(%rdi)
ret

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

LLVM IR (-O2):
define void @mulmn(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2) {
%4 = load double, double* %1
%5 = load double, double* %2
%6 = getelementptr inbounds double, double* %1, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %2, i64 1
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %1, i64 2
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %2, i64 2
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %1, i64 4
%15 = load double, double* %14
%16 = getelementptr inbounds double, double* %1, i64 5
%17 = load double, double* %16
%18 = insertelement <2 x double> poison, double %9, i64 0
%19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
%20 = insertelement <2 x double> poison, double %7, i64 0
%21 = insertelement <2 x double> %20, double %17, i64 1
%22 = fmul <2 x double> %19, %21
%23 = insertelement <2 x double> poison, double %4, i64 0
%24 = insertelement <2 x double> %23, double %15, i64 1
%25 = insertelement <2 x double> poison, double %5, i64 0
%26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
%27 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %24, <2 x double> %26, <2 x double> %22)
%28 = getelementptr inbounds double, double* %1, i64 6
%29 = load double, double* %28
%30 = insertelement <2 x double> poison, double %11, i64 0
%31 = insertelement <2 x double> %30, double %29, i64 1
%32 = insertelement <2 x double> poison, double %13, i64 0
%33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
%34 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %33, <2 x double> %27)
%35 = getelementptr inbounds double, double* %1, i64 8
%36 = load double, double* %35
%37 = getelementptr inbounds double, double* %1, i64 9
%38 = load double, double* %37
%39 = fmul double %9, %38
%40 = tail call double @llvm.fmuladd.f64(double %36, double %5, double %39)
%41 = getelementptr inbounds double, double* %1, i64 10
%42 = load double, double* %41
%43 = tail call double @llvm.fmuladd.f64(double %42, double %13, double %40)
%44 = bitcast double* %0 to <2 x double>*
store <2 x double> %34, <2 x double>* %44
%45 = getelementptr inbounds double, double* %0, i64 2
store double %43, double* %45
ret void
}