int ccw(double p0x, double p0y, double p1x, double p1y, double p2x,
        double p2y) {
  double dx1, dx2, dy1, dy2;
  dx1 = p1x - p0x;
  dy1 = p1y - p0y;
  dx2 = p2x - p0x;
  dy2 = p2y - p0y;
  if (dx1 * dy2 > dy1 * dx2)
    return +1;
  if (dx1 * dy2 < dy1 * dx2)
    return -1;
  if ((dx1 * dx2 < 0) || (dy1 * dy2 < 0))
    return -1;
  if ((dx1 * dx1 + dy1 * dy1) < (dx2 * dx2 + dy2 * dy2))
    return +1;
  return 0;
}


x86 assembly (clang, -O0):
<ccw>:
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  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1188 <ccw+0x88>
movl   $0x1,-0x4(%rbp)
jmp    1241 <ccw+0x141>
movsd  -0x40(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b2 <ccw+0xb2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <ccw+0x141>
movsd  -0x40(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     11e0 <ccw+0xe0>
movsd  -0x50(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11ec <ccw+0xec>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <ccw+0x141>
movsd  -0x40(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm3
movsd  -0x58(%rbp),%xmm2
mulsd  -0x58(%rbp),%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    123a <ccw+0x13a>
movl   $0x1,-0x4(%rbp)
jmp    1241 <ccw+0x141>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ccw>:
unpcklpd %xmm4,%xmm2
unpcklpd %xmm0,%xmm0
subpd  %xmm0,%xmm2
unpcklpd %xmm5,%xmm3
unpcklpd %xmm1,%xmm1
subpd  %xmm1,%xmm3
movapd %xmm3,%xmm0
shufpd $0x1,%xmm3,%xmm0
mulpd  %xmm2,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
mov    $0x1,%eax
ucomisd %xmm1,%xmm0
ja     1188 <ccw+0x88>
mov    $0xffffffff,%eax
ucomisd %xmm0,%xmm1
ja     1188 <ccw+0x88>
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     1188 <ccw+0x88>
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
ucomisd %xmm1,%xmm0
ja     1188 <ccw+0x88>
mulpd  %xmm3,%xmm3
mulpd  %xmm2,%xmm2
addpd  %xmm3,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
xor    %eax,%eax
ucomisd %xmm2,%xmm0
seta   %al
ret

LLVM IR (-O0):
define i32 @ccw(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = 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
%18 = load double, double* %10
%19 = load double, double* %8
%20 = fsub double %18, %19
store double %20, double* %14
%21 = load double, double* %11
%22 = load double, double* %9
%23 = fsub double %21, %22
store double %23, double* %16
%24 = load double, double* %12
%25 = load double, double* %8
%26 = fsub double %24, %25
store double %26, double* %15
%27 = load double, double* %13
%28 = load double, double* %9
%29 = fsub double %27, %28
store double %29, double* %17
%30 = load double, double* %14
%31 = load double, double* %17
%32 = fmul double %30, %31
%33 = load double, double* %16
%34 = load double, double* %15
%35 = fmul double %33, %34
%36 = fcmp ogt double %32, %35
br i1 %36, label %37, label %38
37: ; preds = %6
store i32 1, i32* %7
br label %74
38: ; preds = %6
%39 = load double, double* %14
%40 = load double, double* %17
%41 = fmul double %39, %40
%42 = load double, double* %16
%43 = load double, double* %15
%44 = fmul double %42, %43
%45 = fcmp olt double %41, %44
br i1 %45, label %46, label %47
46: ; preds = %38
store i32 -1, i32* %7
br label %74
47: ; preds = %38
%48 = load double, double* %14
%49 = load double, double* %15
%50 = fmul double %48, %49
%51 = fcmp olt double %50, 0.000000e+00
br i1 %51, label %57, label %52
52: ; preds = %47
%53 = load double, double* %16
%54 = load double, double* %17
%55 = fmul double %53, %54
%56 = fcmp olt double %55, 0.000000e+00
br i1 %56, label %57, label %58
57: ; preds = %52, %47
store i32 -1, i32* %7
br label %74
58: ; preds = %52
%59 = load double, double* %14
%60 = load double, double* %14
%61 = load double, double* %16
%62 = load double, double* %16
%63 = fmul double %61, %62
%64 = call double @llvm.fmuladd.f64(double %59, double %60, double %63)
%65 = load double, double* %15
%66 = load double, double* %15
%67 = load double, double* %17
%68 = load double, double* %17
%69 = fmul double %67, %68
%70 = call double @llvm.fmuladd.f64(double %65, double %66, double %69)
%71 = fcmp olt double %64, %70
br i1 %71, label %72, label %73
72: ; preds = %58
store i32 1, i32* %7
br label %74
73: ; preds = %58
store i32 0, i32* %7
br label %74
74: ; preds = %73, %72, %57, %46, %37
%75 = load i32, i32* %7
ret i32 %75
}

LLVM IR (-O2):
define i32 @ccw(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 %4, i64 1
%9 = insertelement <2 x double> poison, double %0, i64 0
%10 = shufflevector <2 x double> %9, <2 x double> poison, <2 x i32> zeroinitializer
%11 = fsub <2 x double> %8, %10
%12 = insertelement <2 x double> poison, double %3, i64 0
%13 = insertelement <2 x double> %12, double %5, i64 1
%14 = insertelement <2 x double> poison, double %1, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
%16 = fsub <2 x double> %13, %15
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%18 = fmul <2 x double> %17, %11
%19 = extractelement <2 x double> %18, i64 0
%20 = extractelement <2 x double> %18, i64 1
%21 = fcmp ogt double %19, %20
br i1 %21, label %41, label %22
22: ; preds = %6
%23 = fcmp olt double %19, %20
br i1 %23, label %41, label %24
24: ; preds = %22
%25 = shufflevector <2 x double> %11, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%26 = fmul <2 x double> %11, %25
%27 = extractelement <2 x double> %26, i64 0
%28 = fcmp olt double %27, 0.000000e+00
%29 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%30 = fmul <2 x double> %16, %29
%31 = extractelement <2 x double> %30, i64 0
%32 = fcmp olt double %31, 0.000000e+00
%33 = or i1 %28, %32
br i1 %33, label %41, label %34
34: ; preds = %24
%35 = fmul <2 x double> %16, %16
%36 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %11, <2 x double> %11, <2 x double> %35)
%37 = extractelement <2 x double> %36, i64 0
%38 = extractelement <2 x double> %36, i64 1
%39 = fcmp olt double %37, %38
%40 = zext i1 %39 to i32
br label %41
41: ; preds = %34, %24, %22, %6
%42 = phi i32 [ 1, %6 ], [ -1, %22 ], [ -1, %24 ], [ %40, %34 ]
ret i32 %42
}