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


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,-0x30(%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,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%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 [3 x double]
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%8 = load double*, double** %5
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = load double*, double** %6
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = load double*, double** %6
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
%20 = fmul double %16, %19
%21 = call double @llvm.fmuladd.f64(double %10, double %13, double %20)
%22 = load double*, double** %5
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = fadd double %21, %24
%26 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
store double %25, double* %26
%27 = load double*, double** %5
%28 = getelementptr inbounds double, double* %27, i64 3
%29 = load double, double* %28
%30 = load double*, double** %6
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
%33 = load double*, double** %5
%34 = getelementptr inbounds double, double* %33, i64 4
%35 = load double, double* %34
%36 = load double*, double** %6
%37 = getelementptr inbounds double, double* %36, i64 1
%38 = load double, double* %37
%39 = fmul double %35, %38
%40 = call double @llvm.fmuladd.f64(double %29, double %32, double %39)
%41 = load double*, double** %5
%42 = getelementptr inbounds double, double* %41, i64 5
%43 = load double, double* %42
%44 = fadd double %40, %43
%45 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 1
store double %44, double* %45
%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
%64 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
store double %63, double* %64
%65 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%66 = load double, double* %65
%67 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
%68 = load double, double* %67
%69 = fdiv double %66, %68
%70 = load double*, double** %4
%71 = getelementptr inbounds double, double* %70, i64 0
store double %69, double* %71
%72 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 1
%73 = load double, double* %72
%74 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
%75 = load double, double* %74
%76 = fdiv double %73, %75
%77 = load double*, double** %4
%78 = getelementptr inbounds double, double* %77, i64 1
store double %76, double* %78
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
}