#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 fabs(double);
scalar_t__ point_lies_seg(double, double, double, double, double, double);
int seg_inter2(double l1p1x, double l1p1y, double l1p2x, double l1p2y,
               double l2p1x, double l2p1y, double l2p2x, double l2p2y,
               double *ret_x, double *ret_y) {
  double den =
      (l1p1x - l1p2x) * (l2p1y - l2p2y) - (l1p1y - l1p2y) * (l2p1x - l2p2x);
  if (fabs(den) > 1e-6) {
    *ret_x = ((l1p1x * l1p2y - l1p1y * l1p2x) * (l2p1x - l2p2x) -
              (l1p1x - l1p2x) * (l2p1x * l2p2y - l2p1y * l2p2x)) /
             den;
    *ret_y = ((l1p1x * l1p2y - l1p1y * l1p2x) * (l2p1y - l2p2y) -
              (l1p1y - l1p2y) * (l2p1x * l2p2y - l2p1y * l2p2x)) /
             den;
    if (point_lies_seg(l1p1x, l1p1y, l1p2x, l1p2y, *ret_x, *ret_y) &&
        point_lies_seg(l2p1x, l2p1y, l2p2x, l2p2y, *ret_x, *ret_y)) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<seg_inter2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
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  %xmm6,-0x40(%rbp)
movsd  %xmm7,-0x48(%rbp)
mov    %rdi,-0x50(%rbp)
mov    %rsi,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
subsd  -0x40(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe42(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1393 <seg_inter2+0x273>
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm2
subsd  -0x40(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm5
movsd  -0x38(%rbp),%xmm4
mulsd  -0x40(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x60(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm5
movsd  -0x38(%rbp),%xmm4
mulsd  -0x40(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x60(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
mov    -0x50(%rbp),%rax
movsd  (%rax),%xmm4
mov    -0x58(%rbp),%rax
movsd  (%rax),%xmm5
call   1040 <point_lies_seg@plt>
cmp    $0x0,%rax
je     138e <seg_inter2+0x26e>
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm3
mov    -0x50(%rbp),%rax
movsd  (%rax),%xmm4
mov    -0x58(%rbp),%rax
movsd  (%rax),%xmm5
call   1040 <point_lies_seg@plt>
cmp    $0x0,%rax
je     138e <seg_inter2+0x26e>
movl   $0x1,-0x4(%rbp)
jmp    139a <seg_inter2+0x27a>
jmp    1393 <seg_inter2+0x273>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seg_inter2>:
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm0,0x40(%rsp)
movapd %xmm0,%xmm8
movsd  %xmm2,0x50(%rsp)
subsd  %xmm2,%xmm8
movsd  %xmm5,0x8(%rsp)
movsd  %xmm7,0x18(%rsp)
subsd  %xmm7,%xmm5
movsd  %xmm1,0x48(%rsp)
movapd %xmm1,%xmm0
movsd  %xmm3,0x58(%rsp)
subsd  %xmm3,%xmm0
movsd  %xmm4,(%rsp)
movapd %xmm4,%xmm1
movsd  %xmm6,0x10(%rsp)
subsd  %xmm6,%xmm1
movsd  %xmm1,0x20(%rsp)
movapd %xmm0,0x60(%rsp)
mulsd  %xmm0,%xmm1
movsd  %xmm8,0x28(%rsp)
movapd %xmm8,%xmm0
movsd  %xmm5,0x38(%rsp)
mulsd  %xmm5,%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
call   1030 <fabs@plt>
test   %eax,%eax
jle    128c <seg_inter2+0x16c>
movapd 0x60(%rsp),%xmm8
xorpd  0xe39(%rip),%xmm8
movsd  0x48(%rsp),%xmm1
movapd %xmm1,%xmm4
movsd  0x50(%rsp),%xmm2
mulsd  %xmm2,%xmm4
movsd  0x40(%rsp),%xmm0
movapd %xmm0,%xmm5
movsd  0x58(%rsp),%xmm3
mulsd  %xmm3,%xmm5
subsd  %xmm4,%xmm5
movsd  0x8(%rsp),%xmm6
mulsd  0x10(%rsp),%xmm6
movsd  (%rsp),%xmm4
mulsd  0x18(%rsp),%xmm4
subsd  %xmm6,%xmm4
movsd  0x28(%rsp),%xmm6
mulsd  %xmm4,%xmm6
movsd  0x20(%rsp),%xmm7
mulsd  %xmm5,%xmm7
subsd  %xmm6,%xmm7
movsd  0x30(%rsp),%xmm6
divsd  %xmm6,%xmm7
movsd  %xmm7,(%rbx)
mulsd  %xmm8,%xmm4
mulsd  0x38(%rsp),%xmm5
addsd  %xmm4,%xmm5
divsd  %xmm6,%xmm5
movsd  %xmm5,(%r14)
movsd  (%rbx),%xmm4
call   1040 <point_lies_seg@plt>
test   %rax,%rax
je     128c <seg_inter2+0x16c>
movsd  (%rbx),%xmm4
movsd  (%r14),%xmm5
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
call   1040 <point_lies_seg@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    128e <seg_inter2+0x16e>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @seg_inter2(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double* %8, double* %9) {
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double*
%21 = alloca double*
%22 = alloca double
store double %0, double* %12
store double %1, double* %13
store double %2, double* %14
store double %3, double* %15
store double %4, double* %16
store double %5, double* %17
store double %6, double* %18
store double %7, double* %19
store double* %8, double** %20
store double* %9, double** %21
%23 = load double, double* %12
%24 = load double, double* %14
%25 = fsub double %23, %24
%26 = load double, double* %17
%27 = load double, double* %19
%28 = fsub double %26, %27
%29 = load double, double* %13
%30 = load double, double* %15
%31 = fsub double %29, %30
%32 = load double, double* %16
%33 = load double, double* %18
%34 = fsub double %32, %33
%35 = fmul double %31, %34
%36 = fneg double %35
%37 = call double @llvm.fmuladd.f64(double %25, double %28, double %36)
store double %37, double* %22
%38 = load double, double* %22
%39 = call i32 @fabs(double %38)
%40 = sitofp i32 %39 to double
%41 = fcmp ogt double %40, 0x3EB0C6F7A0B5ED8D
br i1 %41, label %42, label %118
42: ; preds = %10
%43 = load double, double* %12
%44 = load double, double* %15
%45 = load double, double* %13
%46 = load double, double* %14
%47 = fmul double %45, %46
%48 = fneg double %47
%49 = call double @llvm.fmuladd.f64(double %43, double %44, double %48)
%50 = load double, double* %16
%51 = load double, double* %18
%52 = fsub double %50, %51
%53 = load double, double* %12
%54 = load double, double* %14
%55 = fsub double %53, %54
%56 = load double, double* %16
%57 = load double, double* %19
%58 = load double, double* %17
%59 = load double, double* %18
%60 = fmul double %58, %59
%61 = fneg double %60
%62 = call double @llvm.fmuladd.f64(double %56, double %57, double %61)
%63 = fmul double %55, %62
%64 = fneg double %63
%65 = call double @llvm.fmuladd.f64(double %49, double %52, double %64)
%66 = load double, double* %22
%67 = fdiv double %65, %66
%68 = load double*, double** %20
store double %67, double* %68
%69 = load double, double* %12
%70 = load double, double* %15
%71 = load double, double* %13
%72 = load double, double* %14
%73 = fmul double %71, %72
%74 = fneg double %73
%75 = call double @llvm.fmuladd.f64(double %69, double %70, double %74)
%76 = load double, double* %17
%77 = load double, double* %19
%78 = fsub double %76, %77
%79 = load double, double* %13
%80 = load double, double* %15
%81 = fsub double %79, %80
%82 = load double, double* %16
%83 = load double, double* %19
%84 = load double, double* %17
%85 = load double, double* %18
%86 = fmul double %84, %85
%87 = fneg double %86
%88 = call double @llvm.fmuladd.f64(double %82, double %83, double %87)
%89 = fmul double %81, %88
%90 = fneg double %89
%91 = call double @llvm.fmuladd.f64(double %75, double %78, double %90)
%92 = load double, double* %22
%93 = fdiv double %91, %92
%94 = load double*, double** %21
store double %93, double* %94
%95 = load double, double* %12
%96 = load double, double* %13
%97 = load double, double* %14
%98 = load double, double* %15
%99 = load double*, double** %20
%100 = load double, double* %99
%101 = load double*, double** %21
%102 = load double, double* %101
%103 = call i64 @point_lies_seg(double %95, double %96, double %97, double %98, double %100, double %102)
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %117
105: ; preds = %42
%106 = load double, double* %16
%107 = load double, double* %17
%108 = load double, double* %18
%109 = load double, double* %19
%110 = load double*, double** %20
%111 = load double, double* %110
%112 = load double*, double** %21
%113 = load double, double* %112
%114 = call i64 @point_lies_seg(double %106, double %107, double %108, double %109, double %111, double %113)
%115 = icmp ne i64 %114, 0
br i1 %115, label %116, label %117
116: ; preds = %105
store i32 1, i32* %11
br label %119
117: ; preds = %105, %42
br label %118
118: ; preds = %117, %10
store i32 0, i32* %11
br label %119
119: ; preds = %118, %116
%120 = load i32, i32* %11
ret i32 %120
}

LLVM IR (-O2):
define i32 @seg_inter2(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double* nocapture %8, double* nocapture %9) {
%11 = fsub double %0, %2
%12 = fsub double %5, %7
%13 = fsub double %1, %3
%14 = fsub double %4, %6
%15 = fneg double %13
%16 = fmul double %14, %15
%17 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %16)
%18 = tail call i32 @fabs(double %17)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %42
20: ; preds = %10
%21 = fneg double %1
%22 = fmul double %21, %2
%23 = tail call double @llvm.fmuladd.f64(double %0, double %3, double %22)
%24 = fneg double %5
%25 = fmul double %24, %6
%26 = tail call double @llvm.fmuladd.f64(double %4, double %7, double %25)
%27 = fneg double %11
%28 = fmul double %26, %27
%29 = tail call double @llvm.fmuladd.f64(double %23, double %14, double %28)
%30 = fdiv double %29, %17
store double %30, double* %8
%31 = fmul double %26, %15
%32 = tail call double @llvm.fmuladd.f64(double %23, double %12, double %31)
%33 = fdiv double %32, %17
store double %33, double* %9
%34 = load double, double* %8
%35 = tail call i64 @point_lies_seg(double %0, double %1, double %2, double %3, double %34, double %33)
%36 = icmp eq i64 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %20
%38 = load double, double* %8
%39 = load double, double* %9
%40 = tail call i64 @point_lies_seg(double %4, double %5, double %6, double %7, double %38, double %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %20, %37, %10
br label %43
43: ; preds = %37, %42
%44 = phi i32 [ 0, %42 ], [ 1, %37 ]
ret i32 %44
}