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


x86 assembly (clang, -O0):
<mulmv4>:
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  0x20(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x40(%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  0x8(%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  0x48(%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  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x30(%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  0x18(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x38(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x58(%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):
<mulmv4>:
movsd  (%rdx),%xmm0
movsd  0x8(%rdx),%xmm1
movsd  0x10(%rdx),%xmm2
unpcklpd %xmm1,%xmm1
movupd (%rsi),%xmm3
movupd 0x10(%rsi),%xmm4
movupd 0x20(%rsi),%xmm5
movupd 0x30(%rsi),%xmm6
mulpd  %xmm1,%xmm5
unpcklpd %xmm0,%xmm0
mulpd  %xmm0,%xmm3
addpd  %xmm5,%xmm3
movupd 0x40(%rsi),%xmm5
unpcklpd %xmm2,%xmm2
mulpd  %xmm2,%xmm5
addpd  %xmm3,%xmm5
mulpd  %xmm1,%xmm6
mulpd  %xmm4,%xmm0
addpd  %xmm6,%xmm0
movupd 0x50(%rsi),%xmm1
mulpd  %xmm2,%xmm1
addpd  %xmm0,%xmm1
movupd %xmm5,(%rdi)
movupd %xmm1,0x10(%rdi)
ret

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