void mat_vmult_2d(double *out, double *mat, double *v) {
  double t, b;
  t = mat[0] * v[0] + mat[1] * v[1];
  b = mat[2] * v[0] + mat[3] * v[1];
  *(out++) = t;
  *(out) = b;
}


x86 assembly (clang, -O0):
<mat_vmult_2d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat_vmult_2d>:
movsd  (%rdx),%xmm0
movsd  0x8(%rdx),%xmm1
unpcklpd %xmm1,%xmm1
movsd  0x8(%rsi),%xmm2
movhpd 0x18(%rsi),%xmm2
movsd  (%rsi),%xmm3
mulpd  %xmm1,%xmm2
movhpd 0x10(%rsi),%xmm3
unpcklpd %xmm0,%xmm0
mulpd  %xmm3,%xmm0
addpd  %xmm2,%xmm0
movupd %xmm0,(%rdi)
ret

LLVM IR (-O0):
define void @mat_vmult_2d(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%9 = load double*, double** %5
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = load double*, double** %6
%13 = getelementptr inbounds double, double* %12, i64 0
%14 = load double, double* %13
%15 = load double*, double** %5
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = load double*, double** %6
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = fmul double %17, %20
%22 = call double @llvm.fmuladd.f64(double %11, double %14, double %21)
store double %22, double* %7
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 2
%25 = load double, double* %24
%26 = load double*, double** %6
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = load double*, double** %5
%30 = getelementptr inbounds double, double* %29, i64 3
%31 = load double, double* %30
%32 = load double*, double** %6
%33 = getelementptr inbounds double, double* %32, i64 1
%34 = load double, double* %33
%35 = fmul double %31, %34
%36 = call double @llvm.fmuladd.f64(double %25, double %28, double %35)
store double %36, double* %8
%37 = load double, double* %7
%38 = load double*, double** %4
%39 = getelementptr inbounds double, double* %38, i32 1
store double* %39, double** %4
store double %37, double* %38
%40 = load double, double* %8
%41 = load double*, double** %4
store double %40, double* %41
ret void
}

LLVM IR (-O2):
define void @mat_vmult_2d(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* %1, i64 3
%13 = load double, double* %12
%14 = insertelement <2 x double> poison, double %9, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
%16 = insertelement <2 x double> poison, double %7, i64 0
%17 = insertelement <2 x double> %16, double %13, i64 1
%18 = fmul <2 x double> %15, %17
%19 = insertelement <2 x double> poison, double %4, i64 0
%20 = insertelement <2 x double> %19, double %11, i64 1
%21 = insertelement <2 x double> poison, double %5, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> %22, <2 x double> %18)
%24 = bitcast double* %0 to <2 x double>*
store <2 x double> %23, <2 x double>* %24
ret void
}