void mulmn4(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];
  const double w = s1[(0 + (3 << 2))] * s2[0] + s1[(1 + (3 << 2))] * s2[1] +
                   s1[(2 + (3 << 2))] * s2[2];
  result[0] = x;
  result[1] = y;
  result[2] = z;
  result[3] = w;
}


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

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

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

LLVM IR (-O2):
define void @mulmn4(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 = getelementptr inbounds double, double* %1, i64 10
%40 = load double, double* %39
%41 = getelementptr inbounds double, double* %1, i64 12
%42 = load double, double* %41
%43 = getelementptr inbounds double, double* %1, i64 13
%44 = load double, double* %43
%45 = insertelement <2 x double> poison, double %38, i64 0
%46 = insertelement <2 x double> %45, double %44, i64 1
%47 = fmul <2 x double> %19, %46
%48 = insertelement <2 x double> poison, double %36, i64 0
%49 = insertelement <2 x double> %48, double %42, i64 1
%50 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %49, <2 x double> %26, <2 x double> %47)
%51 = getelementptr inbounds double, double* %1, i64 14
%52 = load double, double* %51
%53 = insertelement <2 x double> poison, double %40, i64 0
%54 = insertelement <2 x double> %53, double %52, i64 1
%55 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %54, <2 x double> %33, <2 x double> %50)
%56 = bitcast double* %0 to <2 x double>*
store <2 x double> %34, <2 x double>* %56
%57 = getelementptr inbounds double, double* %0, i64 2
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> %55, <2 x double>* %58
ret void
}