void doubles_mat44_rotate_vector(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];
}


x86 assembly (clang, -O0):
<doubles_mat44_rotate_vector>:
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    11a5 <doubles_mat44_rotate_vector+0xa5>
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    -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_rotate_vector+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_mat44_rotate_vector>:
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x10(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx)
movsd  0x20(%rdi),%xmm0
movsd  0x28(%rdi),%xmm1
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x30(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,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
movsd  %xmm1,0x10(%rdx)
ret

LLVM IR (-O0):
define void @doubles_mat44_rotate_vector(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 = %49, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %52
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** %6
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
store double %44, double* %48
br label %49
49: ; preds = %11
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %8
52: ; preds = %8
ret void
}

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