#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 */
scalar_t__ fabs(double);
double point_distance_2d(double, double, double, double);
double line_segment_dist_2dx(double z0, double r0, double z1, double r1,
                             double z, double r, double *f) {
  double x, y, x0, y0, x1, y1, xmin, ymin, m, b;
  int swapped;
  if (z0 == z1 && r0 == r1) {
    if (f != NULL)
      (*f) = 0.;
    return (point_distance_2d(z0, r0, z, r));
  }
  if (fabs(z0 - z1) < fabs(r0 - r1)) {
    x0 = r0;
    x1 = r1;
    x = r;
    y0 = z0;
    y1 = z1;
    y = z;
  } else {
    x0 = z0;
    x1 = z1;
    x = z;
    y0 = r0;
    y1 = r1;
    y = r;
  }
  if (x0 > x1) {
    double t;
    t = x0;
    x0 = x1;
    x1 = t;
    t = y0;
    y0 = y1;
    y1 = t;
    swapped = 1;
  } else
    swapped = 0;
  m = (y1 - y0) / (x1 - x0);
  b = y0 - m * x0;
  xmin = (x + m * y - m * b) / (m * m + 1);
  if (xmin < x0) {
    if (f != NULL)
      (*f) = swapped ? 1. : 0.;
    return (point_distance_2d(x0, y0, x, y));
  }
  if (xmin > x1) {
    if (f != NULL)
      (*f) = swapped ? 0. : 1.;
    return (point_distance_2d(x1, y1, x, y));
  }
  ymin = m * xmin + b;
  if (f != NULL) {
    (*f) = point_distance_2d(xmin, ymin, x0, y0) /
           point_distance_2d(x1, y1, x0, y0);
    if (swapped)
      (*f) = 1. - (*f);
  }
  return (point_distance_2d(xmin, ymin, x, y));
}


x86 assembly (clang, -O0):
<line_segment_dist_2dx>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%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)
mov    %rdi,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    11b2 <line_segment_dist_2dx+0x92>
jp     11b2 <line_segment_dist_2dx+0x92>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jne    11b2 <line_segment_dist_2dx+0x92>
jp     11b2 <line_segment_dist_2dx+0x92>
cmpq   $0x0,-0x40(%rbp)
je     118f <line_segment_dist_2dx+0x6f>
mov    -0x40(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
call   1040 <point_distance_2d@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    157d <line_segment_dist_2dx+0x45d>
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0xa8(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
cmp    %rcx,%rax
jge    122b <line_segment_dist_2dx+0x10b>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1267 <line_segment_dist_2dx+0x147>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    12ce <line_segment_dist_2dx+0x1ae>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0x70(%rbp)
movl   $0x1,-0x94(%rbp)
jmp    12d8 <line_segment_dist_2dx+0x1b8>
movl   $0x0,-0x94(%rbp)
movsd  -0x70(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
subsd  -0x58(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x60(%rbp),%xmm1
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x58(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x90(%rbp),%xmm2
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x88(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm1
movsd  0xc6a(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    142f <line_segment_dist_2dx+0x30f>
cmpq   $0x0,-0x40(%rbp)
je     140c <line_segment_dist_2dx+0x2ec>
mov    -0x94(%rbp),%eax
movsd  0xc30(%rip),%xmm0
xorps  %xmm1,%xmm1
movsd  %xmm1,-0xb8(%rbp)
ff
cmp    $0x0,%eax
movsd  %xmm0,-0xb0(%rbp)
ff
jne    13fc <line_segment_dist_2dx+0x2dc>
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
call   1040 <point_distance_2d@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    157d <line_segment_dist_2dx+0x45d>
movsd  -0x78(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    14b7 <line_segment_dist_2dx+0x397>
cmpq   $0x0,-0x40(%rbp)
je     1494 <line_segment_dist_2dx+0x374>
mov    -0x94(%rbp),%eax
xorps  %xmm0,%xmm0
movsd  0xba5(%rip),%xmm1
movsd  %xmm1,-0xc8(%rbp)
ff
cmp    $0x0,%eax
movsd  %xmm0,-0xc0(%rbp)
ff
jne    1484 <line_segment_dist_2dx+0x364>
movsd  -0xc8(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xc0(%rbp),%xmm0
ff
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
call   1040 <point_distance_2d@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    157d <line_segment_dist_2dx+0x45d>
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x78(%rbp),%xmm2
movsd  -0x90(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     155f <line_segment_dist_2dx+0x43f>
movsd  -0x78(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm3
call   1040 <point_distance_2d@plt>
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm3
call   1040 <point_distance_2d@plt>
movaps %xmm0,%xmm1
movsd  -0xd0(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
cmpl   $0x0,-0x94(%rbp)
je     155a <line_segment_dist_2dx+0x43a>
mov    -0x40(%rbp),%rax
movsd  0xab2(%rip),%xmm0
subsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    155f <line_segment_dist_2dx+0x43f>
movsd  -0x78(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
call   1040 <point_distance_2d@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<line_segment_dist_2dx>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%r14
movapd %xmm0,%xmm6
ucomisd %xmm2,%xmm0
jne    115b <line_segment_dist_2dx+0x3b>
jp     115b <line_segment_dist_2dx+0x3b>
ucomisd %xmm3,%xmm1
jne    115b <line_segment_dist_2dx+0x3b>
jp     115b <line_segment_dist_2dx+0x3b>
test   %r14,%r14
je     114a <line_segment_dist_2dx+0x2a>
movq   $0x0,(%r14)
movapd %xmm6,%xmm0
movapd %xmm4,%xmm2
movapd %xmm5,%xmm3
jmp    13b7 <line_segment_dist_2dx+0x297>
movsd  %xmm5,0x18(%rsp)
movsd  %xmm4,0x28(%rsp)
movapd %xmm6,%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm6,0x20(%rsp)
movsd  %xmm3,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm2,0x30(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jl     11e3 <line_segment_dist_2dx+0xc3>
movsd  0x30(%rsp),%xmm12
movsd  0x8(%rsp),%xmm7
movsd  0x18(%rsp),%xmm8
movsd  0x28(%rsp),%xmm9
movsd  0x20(%rsp),%xmm3
movsd  0x10(%rsp),%xmm0
ucomisd %xmm12,%xmm3
ja     1211 <line_segment_dist_2dx+0xf1>
movapd %xmm12,%xmm11
movapd %xmm0,%xmm10
movapd %xmm3,%xmm6
jmp    1224 <line_segment_dist_2dx+0x104>
movsd  0x10(%rsp),%xmm12
movsd  0x30(%rsp),%xmm0
movsd  0x20(%rsp),%xmm7
movsd  0x8(%rsp),%xmm3
movsd  0x28(%rsp),%xmm8
movsd  0x18(%rsp),%xmm9
ucomisd %xmm12,%xmm3
jbe    11d3 <line_segment_dist_2dx+0xb3>
movapd %xmm3,%xmm11
movapd %xmm7,%xmm10
movapd %xmm0,%xmm7
movapd %xmm12,%xmm6
movapd %xmm10,%xmm1
subsd  %xmm7,%xmm1
movapd %xmm11,%xmm0
subsd  %xmm6,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm2
mulsd  %xmm6,%xmm2
movapd %xmm7,%xmm0
subsd  %xmm2,%xmm0
movapd %xmm1,%xmm4
mulsd  %xmm8,%xmm4
addsd  %xmm9,%xmm4
movapd %xmm1,%xmm5
mulsd  %xmm0,%xmm5
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
addsd  0xd90(%rip),%xmm2
subsd  %xmm5,%xmm4
divsd  %xmm2,%xmm4
ucomisd %xmm4,%xmm6
jbe    12a8 <line_segment_dist_2dx+0x188>
test   %r14,%r14
je     129b <line_segment_dist_2dx+0x17b>
cmpltsd %xmm3,%xmm12
movsd  0xd6f(%rip),%xmm0
andpd  %xmm12,%xmm0
movlpd %xmm0,(%r14)
movapd %xmm6,%xmm0
movapd %xmm7,%xmm1
jmp    13ad <line_segment_dist_2dx+0x28d>
ucomisd %xmm11,%xmm4
jbe    12db <line_segment_dist_2dx+0x1bb>
test   %r14,%r14
je     12cc <line_segment_dist_2dx+0x1ac>
cmpltsd %xmm3,%xmm12
movsd  0xd3e(%rip),%xmm0
andnpd %xmm0,%xmm12
movlpd %xmm12,(%r14)
movapd %xmm11,%xmm0
movapd %xmm10,%xmm1
jmp    13ad <line_segment_dist_2dx+0x28d>
mulsd  %xmm4,%xmm1
addsd  %xmm0,%xmm1
test   %r14,%r14
je     13a9 <line_segment_dist_2dx+0x289>
movapd %xmm4,%xmm0
movapd %xmm6,%xmm2
movsd  %xmm3,0x20(%rsp)
movapd %xmm7,%xmm3
movsd  %xmm9,0x28(%rsp)
movsd  %xmm8,0x10(%rsp)
movapd %xmm12,0x30(%rsp)
movsd  %xmm7,0x60(%rsp)
movsd  %xmm11,0x40(%rsp)
movsd  %xmm10,0x48(%rsp)
movsd  %xmm6,0x50(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm4,0x18(%rsp)
call   1040 <point_distance_2d@plt>
movsd  %xmm0,0x58(%rsp)
movsd  0x40(%rsp),%xmm0
movsd  0x48(%rsp),%xmm1
movsd  0x50(%rsp),%xmm2
movsd  0x60(%rsp),%xmm3
call   1040 <point_distance_2d@plt>
movsd  0x58(%rsp),%xmm2
movsd  0x18(%rsp),%xmm4
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm8
movsd  0x28(%rsp),%xmm9
movsd  0x20(%rsp),%xmm3
ucomisd 0x30(%rsp),%xmm3
divsd  %xmm0,%xmm2
movsd  %xmm2,(%r14)
jbe    13a9 <line_segment_dist_2dx+0x289>
movsd  0xc60(%rip),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,(%r14)
movapd %xmm4,%xmm0
movapd %xmm9,%xmm2
movapd %xmm8,%xmm3
add    $0x68,%rsp
pop    %rbx
pop    %r14
jmp    1040 <point_distance_2d@plt>

LLVM IR (-O0):
define double @line_segment_dist_2dx(double %0, double %1, double %2, double %3, double %4, double %5, double* %6) {
%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
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca i32
%27 = alloca double
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store double* %6, double** %15
%28 = load double, double* %9
%29 = load double, double* %11
%30 = fcmp oeq double %28, %29
br i1 %30, label %31, label %46
31: ; preds = %7
%32 = load double, double* %10
%33 = load double, double* %12
%34 = fcmp oeq double %32, %33
br i1 %34, label %35, label %46
35: ; preds = %31
%36 = load double*, double** %15
%37 = icmp ne double* %36, null
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load double*, double** %15
store double 0.000000e+00, double* %39
br label %40
40: ; preds = %38, %35
%41 = load double, double* %9
%42 = load double, double* %10
%43 = load double, double* %13
%44 = load double, double* %14
%45 = call double @point_distance_2d(double %41, double %42, double %43, double %44)
store double %45, double* %8
br label %178
46: ; preds = %31, %7
%47 = load double, double* %9
%48 = load double, double* %11
%49 = fsub double %47, %48
%50 = call i64 @fabs(double %49)
%51 = load double, double* %10
%52 = load double, double* %12
%53 = fsub double %51, %52
%54 = call i64 @fabs(double %53)
%55 = icmp slt i64 %50, %54
br i1 %55, label %56, label %63
56: ; preds = %46
%57 = load double, double* %10
store double %57, double* %18
%58 = load double, double* %12
store double %58, double* %20
%59 = load double, double* %14
store double %59, double* %16
%60 = load double, double* %9
store double %60, double* %19
%61 = load double, double* %11
store double %61, double* %21
%62 = load double, double* %13
store double %62, double* %17
br label %70
63: ; preds = %46
%64 = load double, double* %9
store double %64, double* %18
%65 = load double, double* %11
store double %65, double* %20
%66 = load double, double* %13
store double %66, double* %16
%67 = load double, double* %10
store double %67, double* %19
%68 = load double, double* %12
store double %68, double* %21
%69 = load double, double* %14
store double %69, double* %17
br label %70
70: ; preds = %63, %56
%71 = load double, double* %18
%72 = load double, double* %20
%73 = fcmp ogt double %71, %72
br i1 %73, label %74, label %81
74: ; preds = %70
%75 = load double, double* %18
store double %75, double* %27
%76 = load double, double* %20
store double %76, double* %18
%77 = load double, double* %27
store double %77, double* %20
%78 = load double, double* %19
store double %78, double* %27
%79 = load double, double* %21
store double %79, double* %19
%80 = load double, double* %27
store double %80, double* %21
store i32 1, i32* %26
br label %82
81: ; preds = %70
store i32 0, i32* %26
br label %82
82: ; preds = %81, %74
%83 = load double, double* %21
%84 = load double, double* %19
%85 = fsub double %83, %84
%86 = load double, double* %20
%87 = load double, double* %18
%88 = fsub double %86, %87
%89 = fdiv double %85, %88
store double %89, double* %24
%90 = load double, double* %19
%91 = load double, double* %24
%92 = load double, double* %18
%93 = fneg double %91
%94 = call double @llvm.fmuladd.f64(double %93, double %92, double %90)
store double %94, double* %25
%95 = load double, double* %16
%96 = load double, double* %24
%97 = load double, double* %17
%98 = call double @llvm.fmuladd.f64(double %96, double %97, double %95)
%99 = load double, double* %24
%100 = load double, double* %25
%101 = fneg double %99
%102 = call double @llvm.fmuladd.f64(double %101, double %100, double %98)
%103 = load double, double* %24
%104 = load double, double* %24
%105 = call double @llvm.fmuladd.f64(double %103, double %104, double 1.000000e+00)
%106 = fdiv double %102, %105
store double %106, double* %22
%107 = load double, double* %22
%108 = load double, double* %18
%109 = fcmp olt double %107, %108
br i1 %109, label %110, label %125
110: ; preds = %82
%111 = load double*, double** %15
%112 = icmp ne double* %111, null
br i1 %112, label %113, label %119
113: ; preds = %110
%114 = load i32, i32* %26
%115 = icmp ne i32 %114, 0
%116 = zext i1 %115 to i64
%117 = select i1 %115, double 1.000000e+00, double 0.000000e+00
%118 = load double*, double** %15
store double %117, double* %118
br label %119
119: ; preds = %113, %110
%120 = load double, double* %18
%121 = load double, double* %19
%122 = load double, double* %16
%123 = load double, double* %17
%124 = call double @point_distance_2d(double %120, double %121, double %122, double %123)
store double %124, double* %8
br label %178
125: ; preds = %82
%126 = load double, double* %22
%127 = load double, double* %20
%128 = fcmp ogt double %126, %127
br i1 %128, label %129, label %144
129: ; preds = %125
%130 = load double*, double** %15
%131 = icmp ne double* %130, null
br i1 %131, label %132, label %138
132: ; preds = %129
%133 = load i32, i32* %26
%134 = icmp ne i32 %133, 0
%135 = zext i1 %134 to i64
%136 = select i1 %134, double 0.000000e+00, double 1.000000e+00
%137 = load double*, double** %15
store double %136, double* %137
br label %138
138: ; preds = %132, %129
%139 = load double, double* %20
%140 = load double, double* %21
%141 = load double, double* %16
%142 = load double, double* %17
%143 = call double @point_distance_2d(double %139, double %140, double %141, double %142)
store double %143, double* %8
br label %178
144: ; preds = %125
%145 = load double, double* %24
%146 = load double, double* %22
%147 = load double, double* %25
%148 = call double @llvm.fmuladd.f64(double %145, double %146, double %147)
store double %148, double* %23
%149 = load double*, double** %15
%150 = icmp ne double* %149, null
br i1 %150, label %151, label %172
151: ; preds = %144
%152 = load double, double* %22
%153 = load double, double* %23
%154 = load double, double* %18
%155 = load double, double* %19
%156 = call double @point_distance_2d(double %152, double %153, double %154, double %155)
%157 = load double, double* %20
%158 = load double, double* %21
%159 = load double, double* %18
%160 = load double, double* %19
%161 = call double @point_distance_2d(double %157, double %158, double %159, double %160)
%162 = fdiv double %156, %161
%163 = load double*, double** %15
store double %162, double* %163
%164 = load i32, i32* %26
%165 = icmp ne i32 %164, 0
br i1 %165, label %166, label %171
166: ; preds = %151
%167 = load double*, double** %15
%168 = load double, double* %167
%169 = fsub double 1.000000e+00, %168
%170 = load double*, double** %15
store double %169, double* %170
br label %171
171: ; preds = %166, %151
br label %172
172: ; preds = %171, %144
%173 = load double, double* %22
%174 = load double, double* %23
%175 = load double, double* %16
%176 = load double, double* %17
%177 = call double @point_distance_2d(double %173, double %174, double %175, double %176)
store double %177, double* %8
br label %178
178: ; preds = %172, %138, %119, %40
%179 = load double, double* %8
ret double %179
}

LLVM IR (-O2):
define double @line_segment_dist_2dx(double %0, double %1, double %2, double %3, double %4, double %5, double* writeonly %6) {
%8 = fcmp oeq double %0, %2
%9 = fcmp oeq double %1, %3
%10 = and i1 %8, %9
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = icmp eq double* %6, null
br i1 %12, label %14, label %13
13: ; preds = %11
store double 0.000000e+00, double* %6
br label %14
14: ; preds = %13, %11
%15 = tail call double @point_distance_2d(double %0, double %1, double %4, double %5)
br label %70
16: ; preds = %7
%17 = fsub double %0, %2
%18 = tail call i64 @fabs(double %17)
%19 = fsub double %1, %3
%20 = tail call i64 @fabs(double %19)
%21 = icmp slt i64 %18, %20
%22 = select i1 %21, double %3, double %2
%23 = select i1 %21, double %2, double %3
%24 = select i1 %21, double %0, double %1
%25 = select i1 %21, double %1, double %0
%26 = select i1 %21, double %4, double %5
%27 = select i1 %21, double %5, double %4
%28 = fcmp ogt double %25, %22
br i1 %28, label %30, label %29
29: ; preds = %16
br label %30
30: ; preds = %16, %29
%31 = phi double [ %22, %29 ], [ %25, %16 ]
%32 = phi double [ %23, %29 ], [ %24, %16 ]
%33 = phi double [ %24, %29 ], [ %23, %16 ]
%34 = phi double [ %25, %29 ], [ %22, %16 ]
%35 = fsub double %32, %33
%36 = fsub double %31, %34
%37 = fdiv double %35, %36
%38 = fneg double %37
%39 = tail call double @llvm.fmuladd.f64(double %38, double %34, double %33)
%40 = tail call double @llvm.fmuladd.f64(double %37, double %26, double %27)
%41 = tail call double @llvm.fmuladd.f64(double %38, double %39, double %40)
%42 = tail call double @llvm.fmuladd.f64(double %37, double %37, double 1.000000e+00)
%43 = fdiv double %41, %42
%44 = fcmp olt double %43, %34
br i1 %44, label %45, label %51
45: ; preds = %30
%46 = icmp eq double* %6, null
br i1 %46, label %49, label %47
47: ; preds = %45
%48 = select i1 %28, double 1.000000e+00, double 0.000000e+00
store double %48, double* %6
br label %49
49: ; preds = %47, %45
%50 = tail call double @point_distance_2d(double %34, double %33, double %27, double %26)
br label %70
51: ; preds = %30
%52 = fcmp ogt double %43, %31
br i1 %52, label %53, label %59
53: ; preds = %51
%54 = icmp eq double* %6, null
br i1 %54, label %57, label %55
55: ; preds = %53
%56 = select i1 %28, double 0.000000e+00, double 1.000000e+00
store double %56, double* %6
br label %57
57: ; preds = %55, %53
%58 = tail call double @point_distance_2d(double %31, double %32, double %27, double %26)
br label %70
59: ; preds = %51
%60 = tail call double @llvm.fmuladd.f64(double %37, double %43, double %39)
%61 = icmp eq double* %6, null
br i1 %61, label %68, label %62
62: ; preds = %59
%63 = tail call double @point_distance_2d(double %43, double %60, double %34, double %33)
%64 = tail call double @point_distance_2d(double %31, double %32, double %34, double %33)
%65 = fdiv double %63, %64
store double %65, double* %6
br i1 %28, label %66, label %68
66: ; preds = %62
%67 = fsub double 1.000000e+00, %65
store double %67, double* %6
br label %68
68: ; preds = %62, %66, %59
%69 = tail call double @point_distance_2d(double %43, double %60, double %27, double %26)
br label %70
70: ; preds = %68, %57, %49, %14
%71 = phi double [ %15, %14 ], [ %50, %49 ], [ %58, %57 ], [ %69, %68 ]
ret double %71
}