#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);
void intersection2DLSSFCT(double x1, double y1, double x2, double y2, double x3,
                          double y3, double x4, double y4, double *result) {
  double denom = (y2 - y1) * (x4 - x3) - (x2 - x1) * (y4 - y3);
  result[0] = x1;
  result[1] = y1;
  if (fabs(denom) < 1e-10) {
    result[0] = (x2 + x3) / 2.0;
    result[1] = (y2 + y3) / 2.0;
  } else {
    double s = ((x1 - x3) * (y4 - y3) - (y1 - y3) * (x4 - x3)) / denom;
    result[0] = x1 + s * (x2 - x1);
    result[1] = y1 + s * (y2 - y1);
  }
}


x86 assembly (clang, -O0):
<intersection2DLSSFCT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  %xmm7,-0x40(%rbp)
mov    %rdi,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
subsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm3
subsd  -0x30(%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,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x50(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe3b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1211 <intersection2DLSSFCT+0x101>
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  0xe27(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  0xe09(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    12af <intersection2DLSSFCT+0x19f>
movsd  -0x8(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
subsd  -0x30(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm3
subsd  -0x28(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
subsd  -0x8(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
subsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intersection2DLSSFCT>:
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
movsd  %xmm3,0x20(%rsp)
subsd  %xmm1,%xmm3
movsd  %xmm4,0x8(%rsp)
subsd  %xmm4,%xmm6
movsd  %xmm2,0x18(%rsp)
movapd %xmm2,%xmm4
subsd  %xmm0,%xmm4
movsd  %xmm5,0x10(%rsp)
subsd  %xmm5,%xmm7
movsd  %xmm7,0x38(%rsp)
movapd %xmm7,%xmm2
movsd  %xmm4,0x30(%rsp)
mulsd  %xmm4,%xmm2
movsd  %xmm3,0x50(%rsp)
movsd  %xmm6,0x48(%rsp)
mulsd  %xmm6,%xmm3
subsd  %xmm2,%xmm3
movsd  %xmm0,0x40(%rsp)
movsd  %xmm0,(%rdi)
movsd  %xmm1,0x58(%rsp)
movsd  %xmm1,0x8(%rdi)
movsd  %xmm3,0x28(%rsp)
movapd %xmm3,%xmm0
call   1030 <fabs@plt>
test   %eax,%eax
jle    11ec <intersection2DLSSFCT+0xdc>
movsd  0x40(%rsp),%xmm4
movapd %xmm4,%xmm1
subsd  0x8(%rsp),%xmm1
movsd  0x58(%rsp),%xmm2
movapd %xmm2,%xmm0
subsd  0x10(%rsp),%xmm0
movsd  0x48(%rsp),%xmm3
mulsd  %xmm0,%xmm3
mulsd  0x38(%rsp),%xmm1
subsd  %xmm3,%xmm1
divsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm4,%xmm0
movsd  %xmm0,(%rbx)
mulsd  0x50(%rsp),%xmm1
addsd  %xmm2,%xmm1
jmp    1218 <intersection2DLSSFCT+0x108>
movsd  0x18(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  0xe00(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
movsd  0x20(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rbx)
add    $0x60,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @intersection2DLSSFCT(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double* nocapture writeonly %8) {
%10 = fsub double %3, %1
%11 = fsub double %6, %4
%12 = fsub double %2, %0
%13 = fsub double %7, %5
%14 = fneg double %12
%15 = fmul double %13, %14
%16 = tail call double @llvm.fmuladd.f64(double %10, double %11, double %15)
store double %0, double* %8
%17 = getelementptr inbounds double, double* %8, i64 1
store double %1, double* %17
%18 = tail call i32 @fabs(double %16)
%19 = icmp slt i32 %18, 1
br i1 %19, label %20, label %25
20: ; preds = %9
%21 = fadd double %2, %4
%22 = fmul double %21, 5.000000e-01
store double %22, double* %8
%23 = fadd double %3, %5
%24 = fmul double %23, 5.000000e-01
br label %34
25: ; preds = %9
%26 = fsub double %0, %4
%27 = fsub double %1, %5
%28 = fneg double %27
%29 = fmul double %11, %28
%30 = tail call double @llvm.fmuladd.f64(double %26, double %13, double %29)
%31 = fdiv double %30, %16
%32 = tail call double @llvm.fmuladd.f64(double %31, double %12, double %0)
store double %32, double* %8
%33 = tail call double @llvm.fmuladd.f64(double %31, double %10, double %1)
br label %34
34: ; preds = %25, %20
%35 = phi double [ %33, %25 ], [ %24, %20 ]
store double %35, double* %17
ret void
}