void homo_op_mul_vec(double o[4], double H[3][4], const double v[4]) {
  int i;
  for (i = 0; i < 3; i++)
    o[i] = H[i][0] * v[0] + H[i][1] * v[1] + H[i][2] * v[2] + H[i][3] * v[3];
  o[3] = v[3];
}


x86 assembly (clang, -O0):
<homo_op_mul_vec>:
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    11c6 <homo_op_mul_vec+0xc6>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x18(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%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 <homo_op_mul_vec+0x17>
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
pop    %rbp
ret

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

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

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