void doubles_mat44_transform_xyz(const double M[16], const double in[3],
                                 double out[3]) {
  for (int i = 0; i < 3; i++)
    out[i] = M[4 * i + 0] * in[0] + M[4 * i + 1] * in[1] +
             M[4 * i + 2] * in[2] + M[4 * i + 3];
}


x86 assembly (clang, -O0):
<doubles_mat44_transform_xyz>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11ba <doubles_mat44_transform_xyz+0xba>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <doubles_mat44_transform_xyz+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_mat44_transform_xyz>:
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 @doubles_mat44_transform_xyz(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
store i32 0, i32* %7
br label %8
8: ; preds = %57, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %60
11: ; preds = %8
%12 = load double*, double** %4
%13 = load i32, i32* %7
%14 = mul nsw i32 4, %13
%15 = add nsw i32 %14, 0
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %12, i64 %16
%18 = load double, double* %17
%19 = load double*, double** %5
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = load double*, double** %4
%23 = load i32, i32* %7
%24 = mul nsw i32 4, %23
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %22, i64 %26
%28 = load double, double* %27
%29 = load double*, double** %5
%30 = getelementptr inbounds double, double* %29, i64 1
%31 = load double, double* %30
%32 = fmul double %28, %31
%33 = call double @llvm.fmuladd.f64(double %18, double %21, double %32)
%34 = load double*, double** %4
%35 = load i32, i32* %7
%36 = mul nsw i32 4, %35
%37 = add nsw i32 %36, 2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %34, i64 %38
%40 = load double, double* %39
%41 = load double*, double** %5
%42 = getelementptr inbounds double, double* %41, i64 2
%43 = load double, double* %42
%44 = call double @llvm.fmuladd.f64(double %40, double %43, double %33)
%45 = load double*, double** %4
%46 = load i32, i32* %7
%47 = mul nsw i32 4, %46
%48 = add nsw i32 %47, 3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %45, i64 %49
%51 = load double, double* %50
%52 = fadd double %44, %51
%53 = load double*, double** %6
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
store double %52, double* %56
br label %57
57: ; preds = %11
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
br label %8
60: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @doubles_mat44_transform_xyz(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds double, double* %1, i64 1
%5 = getelementptr inbounds double, double* %1, i64 2
%6 = load double, double* %0
%7 = load double, double* %1
%8 = getelementptr inbounds double, double* %0, i64 1
%9 = load double, double* %8
%10 = load double, double* %4
%11 = fmul double %9, %10
%12 = tail call double @llvm.fmuladd.f64(double %6, double %7, double %11)
%13 = getelementptr inbounds double, double* %0, i64 2
%14 = load double, double* %13
%15 = load double, double* %5
%16 = tail call double @llvm.fmuladd.f64(double %14, double %15, double %12)
%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* %4
%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* %5
%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* %4
%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* %5
%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
}