void apply_homography(double y[2], double H[9], double x[2]) {
  double X = H[0] * x[0] + H[1] * x[1] + H[2];
  double Y = H[3] * x[0] + H[4] * x[1] + H[5];
  double Z = H[6] * x[0] + H[7] * x[1] + H[8];
  y[0] = X / Z;
  y[1] = Y / Z;
}


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

x86 assembly (clang, -O2):
<apply_homography>:
movsd  (%rdx),%xmm0
movsd  0x8(%rdx),%xmm1
movapd %xmm1,%xmm2
unpcklpd %xmm1,%xmm2
movsd  (%rsi),%xmm3
movsd  0x8(%rsi),%xmm4
movhpd 0x20(%rsi),%xmm4
movsd  0x10(%rsi),%xmm5
mulpd  %xmm2,%xmm4
movhpd 0x18(%rsi),%xmm3
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
mulpd  %xmm3,%xmm2
movhpd 0x28(%rsi),%xmm5
mulsd  0x38(%rsi),%xmm1
mulsd  0x30(%rsi),%xmm0
addpd  %xmm4,%xmm2
addsd  %xmm1,%xmm0
addsd  0x40(%rsi),%xmm0
addpd  %xmm2,%xmm5
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm5
movupd %xmm5,(%rdi)
ret

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

LLVM IR (-O2):
define void @apply_homography(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2) {
%4 = load double, double* %1
%5 = load double, double* %2
%6 = getelementptr inbounds double, double* %1, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %2, i64 1
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %1, i64 2
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %1, i64 3
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %1, i64 4
%15 = load double, double* %14
%16 = insertelement <2 x double> poison, double %9, i64 0
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
%18 = insertelement <2 x double> poison, double %7, i64 0
%19 = insertelement <2 x double> %18, double %15, i64 1
%20 = fmul <2 x double> %17, %19
%21 = insertelement <2 x double> poison, double %4, i64 0
%22 = insertelement <2 x double> %21, double %13, i64 1
%23 = insertelement <2 x double> poison, double %5, i64 0
%24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> zeroinitializer
%25 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> %24, <2 x double> %20)
%26 = getelementptr inbounds double, double* %1, i64 5
%27 = load double, double* %26
%28 = insertelement <2 x double> poison, double %11, i64 0
%29 = insertelement <2 x double> %28, double %27, i64 1
%30 = fadd <2 x double> %29, %25
%31 = getelementptr inbounds double, double* %1, i64 6
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %1, i64 7
%34 = load double, double* %33
%35 = fmul double %9, %34
%36 = tail call double @llvm.fmuladd.f64(double %32, double %5, double %35)
%37 = getelementptr inbounds double, double* %1, i64 8
%38 = load double, double* %37
%39 = fadd double %38, %36
%40 = insertelement <2 x double> poison, double %39, i64 0
%41 = shufflevector <2 x double> %40, <2 x double> poison, <2 x i32> zeroinitializer
%42 = fdiv <2 x double> %30, %41
%43 = bitcast double* %0 to <2 x double>*
store <2 x double> %42, <2 x double>* %43
ret void
}