void interpolate_tri2d(const double a[2], const double ab[2],
                       const double ac[2], const double p[2], double c[3]) {
  const double ap[2] = {p[0] - a[0], p[1] - a[1]};
  const double nrm = 1. / (ab[0] * ac[1] - ab[1] * ac[0]);
  c[1] = nrm * (ap[0] * ac[1] - ap[1] * ac[0]);
  c[2] = nrm * (ab[0] * ap[1] - ab[1] * ap[0]);
  c[0] = 1. - (c[1] + c[2]);
}


x86 assembly (clang, -O0):
<interpolate_tri2d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe73(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm3
movsd  -0x38(%rbp),%xmm2
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x38(%rbp),%xmm3
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mulsd  -0x40(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x28(%rbp),%rax
addsd  0x10(%rax),%xmm1
movsd  0xdb8(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpolate_tri2d>:
movsd  (%rcx),%xmm1
movsd  0x8(%rcx),%xmm0
subsd  (%rdi),%xmm1
subsd  0x8(%rdi),%xmm0
movsd  (%rdx),%xmm2
movsd  0x8(%rdx),%xmm3
movsd  0x8(%rsi),%xmm4
mulsd  %xmm2,%xmm4
movapd %xmm1,%xmm5
mulsd  %xmm3,%xmm5
mulsd  (%rsi),%xmm3
subsd  %xmm4,%xmm3
movsd  0xec4(%rip),%xmm4
movapd %xmm4,%xmm6
divsd  %xmm3,%xmm6
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm5
mulsd  %xmm6,%xmm5
movsd  %xmm5,0x8(%r8)
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
subsd  %xmm1,%xmm0
mulsd  %xmm6,%xmm0
movsd  %xmm0,0x10(%r8)
addsd  %xmm5,%xmm0
subsd  %xmm0,%xmm4
movsd  %xmm4,(%r8)
ret

LLVM IR (-O0):
define void @interpolate_tri2d(double* %0, double* %1, double* %2, double* %3, double* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca [2 x double]
%12 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%13 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
%14 = load double*, double** %9
%15 = getelementptr inbounds double, double* %14, i64 0
%16 = load double, double* %15
%17 = load double*, double** %6
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
%20 = fsub double %16, %19
store double %20, double* %13
%21 = getelementptr inbounds double, double* %13, i64 1
%22 = load double*, double** %9
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
%25 = load double*, double** %6
%26 = getelementptr inbounds double, double* %25, i64 1
%27 = load double, double* %26
%28 = fsub double %24, %27
store double %28, double* %21
%29 = load double*, double** %7
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = load double*, double** %8
%33 = getelementptr inbounds double, double* %32, i64 1
%34 = load double, double* %33
%35 = load double*, double** %7
%36 = getelementptr inbounds double, double* %35, i64 1
%37 = load double, double* %36
%38 = load double*, double** %8
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = fmul double %37, %40
%42 = fneg double %41
%43 = call double @llvm.fmuladd.f64(double %31, double %34, double %42)
%44 = fdiv double 1.000000e+00, %43
store double %44, double* %12
%45 = load double, double* %12
%46 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
%47 = load double, double* %46
%48 = load double*, double** %8
%49 = getelementptr inbounds double, double* %48, i64 1
%50 = load double, double* %49
%51 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 1
%52 = load double, double* %51
%53 = load double*, double** %8
%54 = getelementptr inbounds double, double* %53, i64 0
%55 = load double, double* %54
%56 = fmul double %52, %55
%57 = fneg double %56
%58 = call double @llvm.fmuladd.f64(double %47, double %50, double %57)
%59 = fmul double %45, %58
%60 = load double*, double** %10
%61 = getelementptr inbounds double, double* %60, i64 1
store double %59, double* %61
%62 = load double, double* %12
%63 = load double*, double** %7
%64 = getelementptr inbounds double, double* %63, i64 0
%65 = load double, double* %64
%66 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 1
%67 = load double, double* %66
%68 = load double*, double** %7
%69 = getelementptr inbounds double, double* %68, i64 1
%70 = load double, double* %69
%71 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
%72 = load double, double* %71
%73 = fmul double %70, %72
%74 = fneg double %73
%75 = call double @llvm.fmuladd.f64(double %65, double %67, double %74)
%76 = fmul double %62, %75
%77 = load double*, double** %10
%78 = getelementptr inbounds double, double* %77, i64 2
store double %76, double* %78
%79 = load double*, double** %10
%80 = getelementptr inbounds double, double* %79, i64 1
%81 = load double, double* %80
%82 = load double*, double** %10
%83 = getelementptr inbounds double, double* %82, i64 2
%84 = load double, double* %83
%85 = fadd double %81, %84
%86 = fsub double 1.000000e+00, %85
%87 = load double*, double** %10
%88 = getelementptr inbounds double, double* %87, i64 0
store double %86, double* %88
ret void
}

LLVM IR (-O2):
define void @interpolate_tri2d(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4) {
%6 = load double, double* %3
%7 = load double, double* %0
%8 = fsub double %6, %7
%9 = getelementptr inbounds double, double* %3, i64 1
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %0, i64 1
%12 = load double, double* %11
%13 = fsub double %10, %12
%14 = load double, double* %1
%15 = getelementptr inbounds double, double* %2, i64 1
%16 = load double, double* %15
%17 = getelementptr inbounds double, double* %1, i64 1
%18 = load double, double* %17
%19 = load double, double* %2
%20 = fneg double %18
%21 = fmul double %19, %20
%22 = tail call double @llvm.fmuladd.f64(double %14, double %16, double %21)
%23 = fdiv double 1.000000e+00, %22
%24 = fneg double %13
%25 = fmul double %19, %24
%26 = tail call double @llvm.fmuladd.f64(double %8, double %16, double %25)
%27 = fmul double %26, %23
%28 = getelementptr inbounds double, double* %4, i64 1
store double %27, double* %28
%29 = load double, double* %1
%30 = load double, double* %17
%31 = fneg double %30
%32 = fmul double %8, %31
%33 = tail call double @llvm.fmuladd.f64(double %29, double %13, double %32)
%34 = fmul double %23, %33
%35 = getelementptr inbounds double, double* %4, i64 2
store double %34, double* %35
%36 = fadd double %27, %34
%37 = fsub double 1.000000e+00, %36
store double %37, double* %4
ret void
}