void htrans(double *dest, double *src, double *transform) {
  int i;
  for (i = 0; i < 4; i++) {
    dest[i] = src[0] * transform[i * 4 + 0] + src[1] * transform[i * 4 + 1] +
              src[2] * transform[i * 4 + 2] + src[3] * transform[i * 4 + 3];
  }
}


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

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

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

LLVM IR (-O2):
define void @htrans(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2) {
%4 = getelementptr inbounds double, double* %1, i64 1
%5 = getelementptr inbounds double, double* %1, i64 2
%6 = getelementptr inbounds double, double* %1, i64 3
%7 = load double, double* %1
%8 = load double, double* %2
%9 = load double, double* %4
%10 = getelementptr inbounds double, double* %2, i64 1
%11 = load double, double* %10
%12 = fmul double %9, %11
%13 = tail call double @llvm.fmuladd.f64(double %7, double %8, double %12)
%14 = load double, double* %5
%15 = getelementptr inbounds double, double* %2, i64 2
%16 = load double, double* %15
%17 = tail call double @llvm.fmuladd.f64(double %14, double %16, double %13)
%18 = load double, double* %6
%19 = getelementptr inbounds double, double* %2, i64 3
%20 = load double, double* %19
%21 = tail call double @llvm.fmuladd.f64(double %18, double %20, double %17)
store double %21, double* %0
%22 = load double, double* %1
%23 = getelementptr inbounds double, double* %2, i64 4
%24 = load double, double* %23
%25 = load double, double* %4
%26 = getelementptr inbounds double, double* %2, i64 5
%27 = load double, double* %26
%28 = fmul double %25, %27
%29 = tail call double @llvm.fmuladd.f64(double %22, double %24, double %28)
%30 = load double, double* %5
%31 = getelementptr inbounds double, double* %2, i64 6
%32 = load double, double* %31
%33 = tail call double @llvm.fmuladd.f64(double %30, double %32, double %29)
%34 = load double, double* %6
%35 = getelementptr inbounds double, double* %2, i64 7
%36 = load double, double* %35
%37 = tail call double @llvm.fmuladd.f64(double %34, double %36, double %33)
%38 = getelementptr inbounds double, double* %0, i64 1
store double %37, double* %38
%39 = load double, double* %1
%40 = getelementptr inbounds double, double* %2, i64 8
%41 = load double, double* %40
%42 = load double, double* %4
%43 = getelementptr inbounds double, double* %2, i64 9
%44 = load double, double* %43
%45 = fmul double %42, %44
%46 = tail call double @llvm.fmuladd.f64(double %39, double %41, double %45)
%47 = load double, double* %5
%48 = getelementptr inbounds double, double* %2, i64 10
%49 = load double, double* %48
%50 = tail call double @llvm.fmuladd.f64(double %47, double %49, double %46)
%51 = load double, double* %6
%52 = getelementptr inbounds double, double* %2, i64 11
%53 = load double, double* %52
%54 = tail call double @llvm.fmuladd.f64(double %51, double %53, double %50)
%55 = getelementptr inbounds double, double* %0, i64 2
store double %54, double* %55
%56 = load double, double* %1
%57 = getelementptr inbounds double, double* %2, i64 12
%58 = load double, double* %57
%59 = load double, double* %4
%60 = getelementptr inbounds double, double* %2, i64 13
%61 = load double, double* %60
%62 = fmul double %59, %61
%63 = tail call double @llvm.fmuladd.f64(double %56, double %58, double %62)
%64 = load double, double* %5
%65 = getelementptr inbounds double, double* %2, i64 14
%66 = load double, double* %65
%67 = tail call double @llvm.fmuladd.f64(double %64, double %66, double %63)
%68 = load double, double* %6
%69 = getelementptr inbounds double, double* %2, i64 15
%70 = load double, double* %69
%71 = tail call double @llvm.fmuladd.f64(double %68, double %70, double %67)
%72 = getelementptr inbounds double, double* %0, i64 3
store double %71, double* %72
ret void
}