#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int ccw_tri_tri_intersection_2d(double *, double *, double *, double *,
                                double *, double *);
int tri_tri_overlap_test_2d(double p1[2], double q1[2], double r1[2],
                            double p2[2], double q2[2], double r2[2]) {
  if (((p1[0] - r1[0]) * (q1[1] - r1[1]) - (p1[1] - r1[1]) * (q1[0] - r1[0])) <
      0.0f)
    if (((p2[0] - r2[0]) * (q2[1] - r2[1]) -
         (p2[1] - r2[1]) * (q2[0] - r2[0])) < 0.0f)
      return ccw_tri_tri_intersection_2d(p1, r1, q1, p2, r2, q2);
    else
      return ccw_tri_tri_intersection_2d(p1, r1, q1, p2, q2, r2);
  else if (((p2[0] - r2[0]) * (q2[1] - r2[1]) -
            (p2[1] - r2[1]) * (q2[0] - r2[0])) < 0.0f)
    return ccw_tri_tri_intersection_2d(p1, q1, r1, p2, r2, q2);
  else
    return ccw_tri_tri_intersection_2d(p1, q1, r1, p2, q2, r2);
}


x86 assembly (clang, -O0):
<tri_tri_overlap_test_2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x20(%rbp),%rax
subsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
subsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm3
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm3
mulsd  %xmm3,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1262 <tri_tri_overlap_test_2d+0x152>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x38(%rbp),%rax
subsd  (%rax),%xmm1
mov    -0x30(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x38(%rbp),%rax
subsd  0x8(%rax),%xmm2
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x38(%rbp),%rax
subsd  0x8(%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm3
mov    -0x38(%rbp),%rax
subsd  (%rax),%xmm3
mulsd  %xmm3,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    123d <tri_tri_overlap_test_2d+0x12d>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1030 <ccw_tri_tri_intersection_2d@plt>
mov    %eax,-0x4(%rbp)
jmp    131b <tri_tri_overlap_test_2d+0x20b>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
call   1030 <ccw_tri_tri_intersection_2d@plt>
mov    %eax,-0x4(%rbp)
jmp    131b <tri_tri_overlap_test_2d+0x20b>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x38(%rbp),%rax
subsd  (%rax),%xmm1
mov    -0x30(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x38(%rbp),%rax
subsd  0x8(%rax),%xmm2
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x38(%rbp),%rax
subsd  0x8(%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm3
mov    -0x38(%rbp),%rax
subsd  (%rax),%xmm3
mulsd  %xmm3,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    12fb <tri_tri_overlap_test_2d+0x1eb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1030 <ccw_tri_tri_intersection_2d@plt>
mov    %eax,-0x4(%rbp)
jmp    131b <tri_tri_overlap_test_2d+0x20b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
call   1030 <ccw_tri_tri_intersection_2d@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tri_tri_overlap_test_2d>:
mov    %r8,%r10
mov    %rsi,%rax
movsd  (%rcx),%xmm1
movsd  0x8(%rcx),%xmm2
movhpd (%rdi),%xmm1
movsd  (%r9),%xmm3
movsd  0x8(%r9),%xmm4
movhpd (%rdx),%xmm3
subpd  %xmm3,%xmm1
movsd  0x8(%r8),%xmm0
movhpd 0x8(%rsi),%xmm0
movhpd 0x8(%rdx),%xmm4
movsd  (%r8),%xmm5
subpd  %xmm4,%xmm0
movhpd 0x8(%rdi),%xmm2
mulpd  %xmm1,%xmm0
subpd  %xmm4,%xmm2
movhpd (%rsi),%xmm5
subpd  %xmm3,%xmm5
mulpd  %xmm2,%xmm5
subpd  %xmm5,%xmm0
xorpd  %xmm1,%xmm1
movapd %xmm0,%xmm2
cmpltpd %xmm1,%xmm2
pextrw $0x4,%xmm2,%esi
xorpd  %xmm1,%xmm1
test   $0x1,%sil
je     119f <tri_tri_overlap_test_2d+0x8f>
mov    %rdx,%rsi
mov    %rax,%rdx
ucomisd %xmm0,%xmm1
jbe    11a8 <tri_tri_overlap_test_2d+0x98>
mov    %r9,%r8
mov    %r10,%r9
jmp    1030 <ccw_tri_tri_intersection_2d@plt>
mov    %rax,%rsi
ucomisd %xmm0,%xmm1
ja     1194 <tri_tri_overlap_test_2d+0x84>
mov    %r10,%r8
jmp    1030 <ccw_tri_tri_intersection_2d@plt>

LLVM IR (-O0):
define i32 @tri_tri_overlap_test_2d(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*
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** %8
%15 = getelementptr inbounds double, double* %14, i64 0
%16 = load double, double* %15
%17 = load double*, double** %10
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
%20 = fsub double %16, %19
%21 = load double*, double** %9
%22 = getelementptr inbounds double, double* %21, i64 1
%23 = load double, double* %22
%24 = load double*, double** %10
%25 = getelementptr inbounds double, double* %24, i64 1
%26 = load double, double* %25
%27 = fsub double %23, %26
%28 = load double*, double** %8
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = load double*, double** %10
%32 = getelementptr inbounds double, double* %31, i64 1
%33 = load double, double* %32
%34 = fsub double %30, %33
%35 = load double*, double** %9
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = load double, double* %36
%38 = load double*, double** %10
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = fsub double %37, %40
%42 = fmul double %34, %41
%43 = fneg double %42
%44 = call double @llvm.fmuladd.f64(double %20, double %27, double %43)
%45 = fcmp olt double %44, 0.000000e+00
br i1 %45, label %46, label %95
46: ; preds = %6
%47 = load double*, double** %11
%48 = getelementptr inbounds double, double* %47, i64 0
%49 = load double, double* %48
%50 = load double*, double** %13
%51 = getelementptr inbounds double, double* %50, i64 0
%52 = load double, double* %51
%53 = fsub double %49, %52
%54 = load double*, double** %12
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = load double, double* %55
%57 = load double*, double** %13
%58 = getelementptr inbounds double, double* %57, i64 1
%59 = load double, double* %58
%60 = fsub double %56, %59
%61 = load double*, double** %11
%62 = getelementptr inbounds double, double* %61, i64 1
%63 = load double, double* %62
%64 = load double*, double** %13
%65 = getelementptr inbounds double, double* %64, i64 1
%66 = load double, double* %65
%67 = fsub double %63, %66
%68 = load double*, double** %12
%69 = getelementptr inbounds double, double* %68, i64 0
%70 = load double, double* %69
%71 = load double*, double** %13
%72 = getelementptr inbounds double, double* %71, i64 0
%73 = load double, double* %72
%74 = fsub double %70, %73
%75 = fmul double %67, %74
%76 = fneg double %75
%77 = call double @llvm.fmuladd.f64(double %53, double %60, double %76)
%78 = fcmp olt double %77, 0.000000e+00
br i1 %78, label %79, label %87
79: ; preds = %46
%80 = load double*, double** %8
%81 = load double*, double** %10
%82 = load double*, double** %9
%83 = load double*, double** %11
%84 = load double*, double** %13
%85 = load double*, double** %12
%86 = call i32 @ccw_tri_tri_intersection_2d(double* %80, double* %81, double* %82, double* %83, double* %84, double* %85)
store i32 %86, i32* %7
br label %144
87: ; preds = %46
%88 = load double*, double** %8
%89 = load double*, double** %10
%90 = load double*, double** %9
%91 = load double*, double** %11
%92 = load double*, double** %12
%93 = load double*, double** %13
%94 = call i32 @ccw_tri_tri_intersection_2d(double* %88, double* %89, double* %90, double* %91, double* %92, double* %93)
store i32 %94, i32* %7
br label %144
95: ; preds = %6
%96 = load double*, double** %11
%97 = getelementptr inbounds double, double* %96, i64 0
%98 = load double, double* %97
%99 = load double*, double** %13
%100 = getelementptr inbounds double, double* %99, i64 0
%101 = load double, double* %100
%102 = fsub double %98, %101
%103 = load double*, double** %12
%104 = getelementptr inbounds double, double* %103, i64 1
%105 = load double, double* %104
%106 = load double*, double** %13
%107 = getelementptr inbounds double, double* %106, i64 1
%108 = load double, double* %107
%109 = fsub double %105, %108
%110 = load double*, double** %11
%111 = getelementptr inbounds double, double* %110, i64 1
%112 = load double, double* %111
%113 = load double*, double** %13
%114 = getelementptr inbounds double, double* %113, i64 1
%115 = load double, double* %114
%116 = fsub double %112, %115
%117 = load double*, double** %12
%118 = getelementptr inbounds double, double* %117, i64 0
%119 = load double, double* %118
%120 = load double*, double** %13
%121 = getelementptr inbounds double, double* %120, i64 0
%122 = load double, double* %121
%123 = fsub double %119, %122
%124 = fmul double %116, %123
%125 = fneg double %124
%126 = call double @llvm.fmuladd.f64(double %102, double %109, double %125)
%127 = fcmp olt double %126, 0.000000e+00
br i1 %127, label %128, label %136
128: ; preds = %95
%129 = load double*, double** %8
%130 = load double*, double** %9
%131 = load double*, double** %10
%132 = load double*, double** %11
%133 = load double*, double** %13
%134 = load double*, double** %12
%135 = call i32 @ccw_tri_tri_intersection_2d(double* %129, double* %130, double* %131, double* %132, double* %133, double* %134)
store i32 %135, i32* %7
br label %144
136: ; preds = %95
%137 = load double*, double** %8
%138 = load double*, double** %9
%139 = load double*, double** %10
%140 = load double*, double** %11
%141 = load double*, double** %12
%142 = load double*, double** %13
%143 = call i32 @ccw_tri_tri_intersection_2d(double* %137, double* %138, double* %139, double* %140, double* %141, double* %142)
store i32 %143, i32* %7
br label %144
144: ; preds = %136, %128, %87, %79
%145 = load i32, i32* %7
ret i32 %145
}

LLVM IR (-O2):
define i32 @tri_tri_overlap_test_2d(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5) {
%7 = load double, double* %0
%8 = load double, double* %2
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %2, i64 1
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %0, i64 1
%14 = load double, double* %13
%15 = load double, double* %1
%16 = load double, double* %3
%17 = load double, double* %5
%18 = insertelement <2 x double> poison, double %16, i64 0
%19 = insertelement <2 x double> %18, double %7, i64 1
%20 = insertelement <2 x double> poison, double %17, i64 0
%21 = insertelement <2 x double> %20, double %8, i64 1
%22 = fsub <2 x double> %19, %21
%23 = getelementptr inbounds double, double* %4, i64 1
%24 = load double, double* %23
%25 = getelementptr inbounds double, double* %5, i64 1
%26 = load double, double* %25
%27 = insertelement <2 x double> poison, double %24, i64 0
%28 = insertelement <2 x double> %27, double %10, i64 1
%29 = insertelement <2 x double> poison, double %26, i64 0
%30 = insertelement <2 x double> %29, double %12, i64 1
%31 = fsub <2 x double> %28, %30
%32 = getelementptr inbounds double, double* %3, i64 1
%33 = load double, double* %32
%34 = insertelement <2 x double> poison, double %33, i64 0
%35 = insertelement <2 x double> %34, double %14, i64 1
%36 = fsub <2 x double> %35, %30
%37 = load double, double* %4
%38 = insertelement <2 x double> poison, double %37, i64 0
%39 = insertelement <2 x double> %38, double %15, i64 1
%40 = fsub <2 x double> %39, %21
%41 = fneg <2 x double> %36
%42 = fmul <2 x double> %40, %41
%43 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> %31, <2 x double> %42)
%44 = fcmp olt <2 x double> %43, zeroinitializer
%45 = extractelement <2 x i1> %44, i64 1
br i1 %45, label %46, label %52
46: ; preds = %6
%47 = extractelement <2 x i1> %44, i64 0
br i1 %47, label %48, label %50
48: ; preds = %46
%49 = tail call i32 @ccw_tri_tri_intersection_2d(double* %0, double* %2, double* %1, double* %3, double* %5, double* %4)
br label %58
50: ; preds = %46
%51 = tail call i32 @ccw_tri_tri_intersection_2d(double* %0, double* %2, double* %1, double* %3, double* %4, double* %5)
br label %58
52: ; preds = %6
%53 = extractelement <2 x i1> %44, i64 0
br i1 %53, label %54, label %56
54: ; preds = %52
%55 = tail call i32 @ccw_tri_tri_intersection_2d(double* %0, double* %1, double* %2, double* %3, double* %5, double* %4)
br label %58
56: ; preds = %52
%57 = tail call i32 @ccw_tri_tri_intersection_2d(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5)
br label %58
58: ; preds = %56, %54, %50, %48
%59 = phi i32 [ %49, %48 ], [ %51, %50 ], [ %55, %54 ], [ %57, %56 ]
ret i32 %59
}