void matrix_vector_multiply_4x4_3d(const double m[16], const double v[3],
                                   double result[3]) {
  result[0] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
  result[1] = m[4] * v[0] + m[5] * v[1] + m[6] * v[2] + m[7];
  result[2] = m[8] * v[0] + m[9] * v[1] + m[10] * v[2] + m[11];
}


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

x86 assembly (clang, -O2):
<matrix_vector_multiply_4x4_3d>:
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
movsd  0x10(%rdi),%xmm2
mulsd  0x10(%rsi),%xmm2
addsd  %xmm1,%xmm0
addsd  %xmm0,%xmm2
addsd  0x18(%rdi),%xmm2
movsd  %xmm2,(%rdx)
movsd  0x20(%rdi),%xmm0
movsd  0x28(%rdi),%xmm1
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
movsd  0x30(%rdi),%xmm2
mulsd  0x10(%rsi),%xmm2
addsd  %xmm1,%xmm0
addsd  %xmm0,%xmm2
addsd  0x38(%rdi),%xmm2
movsd  %xmm2,0x8(%rdx)
movsd  0x40(%rdi),%xmm0
movsd  0x48(%rdi),%xmm1
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x50(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm1
addsd  %xmm0,%xmm1
addsd  0x58(%rdi),%xmm1
movsd  %xmm1,0x10(%rdx)
ret

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

LLVM IR (-O2):
define void @matrix_vector_multiply_4x4_3d(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 = fmul double %7, %9
%11 = tail call double @llvm.fmuladd.f64(double %4, double %5, double %10)
%12 = getelementptr inbounds double, double* %0, i64 2
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %1, i64 2
%15 = load double, double* %14
%16 = tail call double @llvm.fmuladd.f64(double %13, double %15, double %11)
%17 = getelementptr inbounds double, double* %0, i64 3
%18 = load double, double* %17
%19 = fadd double %16, %18
store double %19, double* %2
%20 = getelementptr inbounds double, double* %0, i64 4
%21 = load double, double* %20
%22 = load double, double* %1
%23 = getelementptr inbounds double, double* %0, i64 5
%24 = load double, double* %23
%25 = load double, double* %8
%26 = fmul double %24, %25
%27 = tail call double @llvm.fmuladd.f64(double %21, double %22, double %26)
%28 = getelementptr inbounds double, double* %0, i64 6
%29 = load double, double* %28
%30 = load double, double* %14
%31 = tail call double @llvm.fmuladd.f64(double %29, double %30, double %27)
%32 = getelementptr inbounds double, double* %0, i64 7
%33 = load double, double* %32
%34 = fadd double %31, %33
%35 = getelementptr inbounds double, double* %2, i64 1
store double %34, double* %35
%36 = getelementptr inbounds double, double* %0, i64 8
%37 = load double, double* %36
%38 = load double, double* %1
%39 = getelementptr inbounds double, double* %0, i64 9
%40 = load double, double* %39
%41 = load double, double* %8
%42 = fmul double %40, %41
%43 = tail call double @llvm.fmuladd.f64(double %37, double %38, double %42)
%44 = getelementptr inbounds double, double* %0, i64 10
%45 = load double, double* %44
%46 = load double, double* %14
%47 = tail call double @llvm.fmuladd.f64(double %45, double %46, double %43)
%48 = getelementptr inbounds double, double* %0, i64 11
%49 = load double, double* %48
%50 = fadd double %47, %49
%51 = getelementptr inbounds double, double* %2, i64 2
store double %50, double* %51
ret void
}