double triangle(double x1, double y1, double x2, double y2, double x3,
                double y3) {
  x2 = (x2 - x1) * (y3 - y1);
  x3 = (y2 - y1) * (x3 - x1);
  if (x2 > x3) {
    return (x2 - x3) / 2.0;
  } else {
    return (x3 - x2) / 2.0;
  }
}


x86 assembly (clang, -O0):
<triangle>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    118c <triangle+0x8c>
movsd  -0x20(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xe82(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a7 <triangle+0xa7>
movsd  -0x30(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xe62(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<triangle>:
unpcklpd %xmm3,%xmm2
movapd %xmm0,%xmm3
unpcklpd %xmm1,%xmm3
subpd  %xmm3,%xmm2
unpcklpd %xmm4,%xmm5
unpcklpd %xmm0,%xmm1
subpd  %xmm1,%xmm5
mulpd  %xmm2,%xmm5
movapd %xmm5,%xmm0
unpckhpd %xmm5,%xmm0
movapd %xmm5,%xmm1
subsd  %xmm0,%xmm1
movapd %xmm0,%xmm2
subsd  %xmm5,%xmm2
cmpltsd %xmm5,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
mulsd  0xeaf(%rip),%xmm0
ret

LLVM IR (-O0):
define double @triangle(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
%14 = load double, double* %10
%15 = load double, double* %8
%16 = fsub double %14, %15
%17 = load double, double* %13
%18 = load double, double* %9
%19 = fsub double %17, %18
%20 = fmul double %16, %19
store double %20, double* %10
%21 = load double, double* %11
%22 = load double, double* %9
%23 = fsub double %21, %22
%24 = load double, double* %12
%25 = load double, double* %8
%26 = fsub double %24, %25
%27 = fmul double %23, %26
store double %27, double* %12
%28 = load double, double* %10
%29 = load double, double* %12
%30 = fcmp ogt double %28, %29
br i1 %30, label %31, label %36
31: ; preds = %6
%32 = load double, double* %10
%33 = load double, double* %12
%34 = fsub double %32, %33
%35 = fdiv double %34, 2.000000e+00
store double %35, double* %7
br label %41
36: ; preds = %6
%37 = load double, double* %12
%38 = load double, double* %10
%39 = fsub double %37, %38
%40 = fdiv double %39, 2.000000e+00
store double %40, double* %7
br label %41
41: ; preds = %36, %31
%42 = load double, double* %7
ret double %42
}

LLVM IR (-O2):
define double @triangle(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = insertelement <2 x double> poison, double %2, i64 0
%8 = insertelement <2 x double> %7, double %3, i64 1
%9 = insertelement <2 x double> poison, double %0, i64 0
%10 = insertelement <2 x double> %9, double %1, i64 1
%11 = fsub <2 x double> %8, %10
%12 = insertelement <2 x double> poison, double %5, i64 0
%13 = insertelement <2 x double> %12, double %4, i64 1
%14 = insertelement <2 x double> poison, double %1, i64 0
%15 = insertelement <2 x double> %14, double %0, i64 1
%16 = fsub <2 x double> %13, %15
%17 = fmul <2 x double> %11, %16
%18 = extractelement <2 x double> %17, i64 0
%19 = extractelement <2 x double> %17, i64 1
%20 = fcmp ogt double %18, %19
%21 = fsub double %18, %19
%22 = fsub double %19, %18
%23 = select i1 %20, double %21, double %22
%24 = fmul double %23, 5.000000e-01
ret double %24
}