#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 */
double hypot(double, double);
int solve_cubic(double, double, double, double, double *);
double dist_to_quadratic(double x, double y, double x0, double y0, double x1,
                         double y1, double x2, double y2) {
  double u0, u1, t0, t1, t2, c0, c1, c2, c3;
  double roots[3];
  int n_roots;
  double ts[4];
  int n_ts;
  int i;
  double minerr = 0;
  u0 = x1 - x0;
  u1 = x0 - 2 * x1 + x2;
  t0 = x0 - x;
  t1 = 2 * u0;
  t2 = u1;
  c0 = t0 * u0;
  c1 = t1 * u0 + t0 * u1;
  c2 = t2 * u0 + t1 * u1;
  c3 = t2 * u1;
  u0 = y1 - y0;
  u1 = y0 - 2 * y1 + y2;
  t0 = y0 - y;
  t1 = 2 * u0;
  t2 = u1;
  c0 += t0 * u0;
  c1 += t1 * u0 + t0 * u1;
  c2 += t2 * u0 + t1 * u1;
  c3 += t2 * u1;
  n_roots = solve_cubic(c0, c1, c2, c3, roots);
  n_ts = 0;
  for (i = 0; i < n_roots; i++) {
    double t = roots[i];
    if (t > 0 && t < 1)
      ts[n_ts++] = t;
  }
  if (n_ts < n_roots) {
    ts[n_ts++] = 0;
    ts[n_ts++] = 1;
  }
  for (i = 0; i < n_ts; i++) {
    double t = ts[i];
    double xa = x0 * (1 - t) * (1 - t) + 2 * x1 * (1 - t) * t + x2 * t * t;
    double ya = y0 * (1 - t) * (1 - t) + 2 * y1 * (1 - t) * t + y2 * t * t;
    double err = hypot(xa - x, ya - y);
    if (i == 0 || err < minerr) {
      minerr = err;
    }
  }
  return minerr;
}


x86 assembly (clang, -O0):
<dist_to_quadratic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%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)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe60(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xda7(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x88(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
movsd  -0x80(%rbp),%xmm2
movsd  -0x88(%rbp),%xmm3
ff
lea    -0xa0(%rbp),%rdi
call   1030 <solve_cubic@plt>
mov    %eax,-0xa4(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
mov    -0xd8(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jge    13c6 <dist_to_quadratic+0x2a6>
movslq -0xd8(%rbp),%rax
movsd  -0xa0(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  -0xe8(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    13ad <dist_to_quadratic+0x28d>
movsd  0xc8d(%rip),%xmm0
ucomisd -0xe8(%rbp),%xmm0
ff
jbe    13ad <dist_to_quadratic+0x28d>
movsd  -0xe8(%rbp),%xmm0
ff
mov    -0xd4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xd4(%rbp)
cltq
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
jmp    13b2 <dist_to_quadratic+0x292>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1334 <dist_to_quadratic+0x214>
mov    -0xd4(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jge    141b <dist_to_quadratic+0x2fb>
mov    -0xd4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xd4(%rbp)
cltq
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
mov    -0xd4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xd4(%rbp)
cltq
movsd  0xbf6(%rip),%xmm0
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
movl   $0x0,-0xd8(%rbp)
mov    -0xd8(%rbp),%eax
cmp    -0xd4(%rbp),%eax
jge    15c4 <dist_to_quadratic+0x4a4>
movslq -0xd8(%rbp),%rax
movsd  -0xd0(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  -0x18(%rbp),%xmm1
movsd  0xbac(%rip),%xmm0
subsd  -0xf0(%rbp),%xmm0
ff
mulsd  %xmm0,%xmm1
movsd  0xb98(%rip),%xmm2
subsd  -0xf0(%rbp),%xmm2
ff
movsd  0xb80(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xb7b(%rip),%xmm3
subsd  -0xf0(%rbp),%xmm3
ff
mulsd  %xmm3,%xmm0
mulsd  -0xf0(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  -0xf0(%rbp),%xmm0
ff
movsd  -0xf0(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0x20(%rbp),%xmm1
movsd  0xb2d(%rip),%xmm0
subsd  -0xf0(%rbp),%xmm0
ff
mulsd  %xmm0,%xmm1
movsd  0xb19(%rip),%xmm2
subsd  -0xf0(%rbp),%xmm2
ff
movsd  0xb01(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  0xafc(%rip),%xmm3
subsd  -0xf0(%rbp),%xmm3
ff
mulsd  %xmm3,%xmm0
mulsd  -0xf0(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  -0xf0(%rbp),%xmm0
ff
movsd  -0xf0(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
movsd  -0xf8(%rbp),%xmm0
ff
subsd  -0x8(%rbp),%xmm0
movsd  -0x100(%rbp),%xmm1
ff
subsd  -0x10(%rbp),%xmm1
call   1040 <hypot@plt>
movsd  %xmm0,-0x108(%rbp)
ff
cmpl   $0x0,-0xd8(%rbp)
je     159b <dist_to_quadratic+0x47b>
movsd  -0x108(%rbp),%xmm1
ff
movsd  -0xe0(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    15ab <dist_to_quadratic+0x48b>
movsd  -0x108(%rbp),%xmm0
ff
movsd  %xmm0,-0xe0(%rbp)
ff
jmp    15b0 <dist_to_quadratic+0x490>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1425 <dist_to_quadratic+0x305>
movsd  -0xe0(%rbp),%xmm0
ff
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dist_to_quadratic>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
movapd %xmm4,(%rsp)
movapd %xmm4,%xmm8
movapd %xmm5,0x10(%rsp)
unpcklpd %xmm5,%xmm8
movapd %xmm2,0x90(%rsp)
movapd %xmm2,%xmm5
movapd %xmm3,0xa0(%rsp)
unpcklpd %xmm3,%xmm5
movapd %xmm8,%xmm4
subpd  %xmm5,%xmm4
movapd %xmm0,0x70(%rsp)
movapd %xmm0,%xmm2
movapd %xmm1,0x80(%rsp)
unpcklpd %xmm1,%xmm2
movapd %xmm5,%xmm1
subpd  %xmm2,%xmm1
movapd %xmm1,%xmm2
mulsd  %xmm4,%xmm2
addpd  %xmm8,%xmm8
subpd  %xmm8,%xmm5
movapd %xmm6,0xb0(%rsp)
movapd %xmm6,%xmm3
movapd %xmm7,0xc0(%rsp)
unpcklpd %xmm7,%xmm3
addpd  %xmm5,%xmm3
movapd %xmm4,%xmm7
addpd  %xmm4,%xmm7
movapd %xmm3,%xmm6
mulsd  %xmm3,%xmm6
movapd %xmm4,%xmm5
unpckhpd %xmm4,%xmm5
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
mulsd  %xmm5,%xmm0
addsd  %xmm2,%xmm0
mulpd  %xmm3,%xmm1
movapd %xmm7,%xmm2
mulpd  %xmm4,%xmm2
addpd  %xmm1,%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm2,%xmm1
mulpd  %xmm3,%xmm7
mulpd  %xmm3,%xmm4
addpd  %xmm7,%xmm4
movapd %xmm4,%xmm2
unpckhpd %xmm4,%xmm2
addsd  %xmm4,%xmm2
unpckhpd %xmm3,%xmm3
mulsd  %xmm3,%xmm3
addsd  %xmm6,%xmm3
lea    0x50(%rsp),%rdi
call   1030 <solve_cubic@plt>
test   %eax,%eax
jle    1267 <dist_to_quadratic+0x147>
mov    %eax,%edx
cmp    $0x1,%eax
jne    138f <dist_to_quadratic+0x26f>
xor    %esi,%esi
xor    %ecx,%ecx
test   $0x1,%dl
je     1269 <dist_to_quadratic+0x149>
movsd  0x50(%rsp,%rsi,8),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1269 <dist_to_quadratic+0x149>
movsd  0xdad(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1269 <dist_to_quadratic+0x149>
movslq %ecx,%rdx
add    $0x1,%ecx
movsd  %xmm0,0x30(%rsp,%rdx,8)
jmp    1269 <dist_to_quadratic+0x149>
xor    %ecx,%ecx
cmp    %eax,%ecx
jge    128b <dist_to_quadratic+0x16b>
movslq %ecx,%rax
movq   $0x0,0x30(%rsp,%rax,8)
add    $0x2,%ecx
movabs $0x3ff0000000000000,%rdx
mov    %rdx,0x38(%rsp,%rax,8)
test   %ecx,%ecx
jle    1380 <dist_to_quadratic+0x260>
movapd (%rsp),%xmm0
addsd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
addsd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
mov    %ecx,%r14d
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
jmp    12d1 <dist_to_quadratic+0x1b1>
nopl   0x0(%rax)
add    $0x1,%rbx
movapd %xmm0,%xmm1
cmp    %rbx,%r14
je     1384 <dist_to_quadratic+0x264>
movsd  %xmm1,0x28(%rsp)
movsd  0x30(%rsp,%rbx,8),%xmm2
movsd  0xd1b(%rip),%xmm1
subsd  %xmm2,%xmm1
movapd %xmm1,%xmm3
mulsd  0x90(%rsp),%xmm3
movapd (%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm2,%xmm0
mulsd  0xb0(%rsp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
movapd %xmm1,%xmm3
mulsd  0xa0(%rsp),%xmm3
movapd 0x10(%rsp),%xmm4
mulsd  %xmm1,%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm1,%xmm3
addsd  %xmm4,%xmm3
movapd %xmm2,%xmm1
mulsd  0xc0(%rsp),%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm3,%xmm1
subsd  0x70(%rsp),%xmm0
subsd  0x80(%rsp),%xmm1
call   1040 <hypot@plt>
test   %rbx,%rbx
je     12c0 <dist_to_quadratic+0x1a0>
minsd  0x28(%rsp),%xmm0
jmp    12c0 <dist_to_quadratic+0x1a0>
xorpd  %xmm0,%xmm0
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret
mov    %edx,%edi
and    $0xfffffffe,%edi
xor    %esi,%esi
xorpd  %xmm0,%xmm0
movsd  0xc5e(%rip),%xmm1
xor    %ecx,%ecx
jmp    13bd <dist_to_quadratic+0x29d>
cs nopw 0x0(%rax,%rax,1)
add    $0x2,%rsi
cmp    %rsi,%rdi
je     1236 <dist_to_quadratic+0x116>
movsd  0x50(%rsp,%rsi,8),%xmm2
ucomisd %xmm0,%xmm2
jbe    13db <dist_to_quadratic+0x2bb>
ucomisd %xmm2,%xmm1
jbe    13db <dist_to_quadratic+0x2bb>
movslq %ecx,%rbx
add    $0x1,%ecx
movsd  %xmm2,0x30(%rsp,%rbx,8)
movsd  0x58(%rsp,%rsi,8),%xmm2
ucomisd %xmm0,%xmm2
jbe    13b0 <dist_to_quadratic+0x290>
ucomisd %xmm2,%xmm1
jbe    13b0 <dist_to_quadratic+0x290>
movslq %ecx,%rbx
add    $0x1,%ecx
movsd  %xmm2,0x30(%rsp,%rbx,8)
jmp    13b0 <dist_to_quadratic+0x290>

LLVM IR (-O0):
define double @dist_to_quadratic(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%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 [3 x double]
%27 = alloca i32
%28 = alloca [4 x double]
%29 = alloca i32
%30 = alloca i32
%31 = alloca double
%32 = alloca double
%33 = alloca double
%34 = alloca double
%35 = alloca double
%36 = 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
store double %7, double* %16
store double 0.000000e+00, double* %31
%37 = load double, double* %13
%38 = load double, double* %11
%39 = fsub double %37, %38
store double %39, double* %17
%40 = load double, double* %11
%41 = load double, double* %13
%42 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %41, double %40)
%43 = load double, double* %15
%44 = fadd double %42, %43
store double %44, double* %18
%45 = load double, double* %11
%46 = load double, double* %9
%47 = fsub double %45, %46
store double %47, double* %19
%48 = load double, double* %17
%49 = fmul double 2.000000e+00, %48
store double %49, double* %20
%50 = load double, double* %18
store double %50, double* %21
%51 = load double, double* %19
%52 = load double, double* %17
%53 = fmul double %51, %52
store double %53, double* %22
%54 = load double, double* %20
%55 = load double, double* %17
%56 = load double, double* %19
%57 = load double, double* %18
%58 = fmul double %56, %57
%59 = call double @llvm.fmuladd.f64(double %54, double %55, double %58)
store double %59, double* %23
%60 = load double, double* %21
%61 = load double, double* %17
%62 = load double, double* %20
%63 = load double, double* %18
%64 = fmul double %62, %63
%65 = call double @llvm.fmuladd.f64(double %60, double %61, double %64)
store double %65, double* %24
%66 = load double, double* %21
%67 = load double, double* %18
%68 = fmul double %66, %67
store double %68, double* %25
%69 = load double, double* %14
%70 = load double, double* %12
%71 = fsub double %69, %70
store double %71, double* %17
%72 = load double, double* %12
%73 = load double, double* %14
%74 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %73, double %72)
%75 = load double, double* %16
%76 = fadd double %74, %75
store double %76, double* %18
%77 = load double, double* %12
%78 = load double, double* %10
%79 = fsub double %77, %78
store double %79, double* %19
%80 = load double, double* %17
%81 = fmul double 2.000000e+00, %80
store double %81, double* %20
%82 = load double, double* %18
store double %82, double* %21
%83 = load double, double* %19
%84 = load double, double* %17
%85 = load double, double* %22
%86 = call double @llvm.fmuladd.f64(double %83, double %84, double %85)
store double %86, double* %22
%87 = load double, double* %20
%88 = load double, double* %17
%89 = load double, double* %19
%90 = load double, double* %18
%91 = fmul double %89, %90
%92 = call double @llvm.fmuladd.f64(double %87, double %88, double %91)
%93 = load double, double* %23
%94 = fadd double %93, %92
store double %94, double* %23
%95 = load double, double* %21
%96 = load double, double* %17
%97 = load double, double* %20
%98 = load double, double* %18
%99 = fmul double %97, %98
%100 = call double @llvm.fmuladd.f64(double %95, double %96, double %99)
%101 = load double, double* %24
%102 = fadd double %101, %100
store double %102, double* %24
%103 = load double, double* %21
%104 = load double, double* %18
%105 = load double, double* %25
%106 = call double @llvm.fmuladd.f64(double %103, double %104, double %105)
store double %106, double* %25
%107 = load double, double* %22
%108 = load double, double* %23
%109 = load double, double* %24
%110 = load double, double* %25
%111 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 0
%112 = call i32 @solve_cubic(double %107, double %108, double %109, double %110, double* %111)
store i32 %112, i32* %27
store i32 0, i32* %29
store i32 0, i32* %30
br label %113
113: ; preds = %134, %8
%114 = load i32, i32* %30
%115 = load i32, i32* %27
%116 = icmp slt i32 %114, %115
br i1 %116, label %117, label %137
117: ; preds = %113
%118 = load i32, i32* %30
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 %119
%121 = load double, double* %120
store double %121, double* %32
%122 = load double, double* %32
%123 = fcmp ogt double %122, 0.000000e+00
br i1 %123, label %124, label %133
124: ; preds = %117
%125 = load double, double* %32
%126 = fcmp olt double %125, 1.000000e+00
br i1 %126, label %127, label %133
127: ; preds = %124
%128 = load double, double* %32
%129 = load i32, i32* %29
%130 = add nsw i32 %129, 1
store i32 %130, i32* %29
%131 = sext i32 %129 to i64
%132 = getelementptr inbounds [4 x double], [4 x double]* %28, i64 0, i64 %131
store double %128, double* %132
br label %133
133: ; preds = %127, %124, %117
br label %134
134: ; preds = %133
%135 = load i32, i32* %30
%136 = add nsw i32 %135, 1
store i32 %136, i32* %30
br label %113
137: ; preds = %113
%138 = load i32, i32* %29
%139 = load i32, i32* %27
%140 = icmp slt i32 %138, %139
br i1 %140, label %141, label %150
141: ; preds = %137
%142 = load i32, i32* %29
%143 = add nsw i32 %142, 1
store i32 %143, i32* %29
%144 = sext i32 %142 to i64
%145 = getelementptr inbounds [4 x double], [4 x double]* %28, i64 0, i64 %144
store double 0.000000e+00, double* %145
%146 = load i32, i32* %29
%147 = add nsw i32 %146, 1
store i32 %147, i32* %29
%148 = sext i32 %146 to i64
%149 = getelementptr inbounds [4 x double], [4 x double]* %28, i64 0, i64 %148
store double 1.000000e+00, double* %149
br label %150
150: ; preds = %141, %137
store i32 0, i32* %30
br label %151
151: ; preds = %214, %150
%152 = load i32, i32* %30
%153 = load i32, i32* %29
%154 = icmp slt i32 %152, %153
br i1 %154, label %155, label %217
155: ; preds = %151
%156 = load i32, i32* %30
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds [4 x double], [4 x double]* %28, i64 0, i64 %157
%159 = load double, double* %158
store double %159, double* %33
%160 = load double, double* %11
%161 = load double, double* %33
%162 = fsub double 1.000000e+00, %161
%163 = fmul double %160, %162
%164 = load double, double* %33
%165 = fsub double 1.000000e+00, %164
%166 = load double, double* %13
%167 = fmul double 2.000000e+00, %166
%168 = load double, double* %33
%169 = fsub double 1.000000e+00, %168
%170 = fmul double %167, %169
%171 = load double, double* %33
%172 = fmul double %170, %171
%173 = call double @llvm.fmuladd.f64(double %163, double %165, double %172)
%174 = load double, double* %15
%175 = load double, double* %33
%176 = fmul double %174, %175
%177 = load double, double* %33
%178 = call double @llvm.fmuladd.f64(double %176, double %177, double %173)
store double %178, double* %34
%179 = load double, double* %12
%180 = load double, double* %33
%181 = fsub double 1.000000e+00, %180
%182 = fmul double %179, %181
%183 = load double, double* %33
%184 = fsub double 1.000000e+00, %183
%185 = load double, double* %14
%186 = fmul double 2.000000e+00, %185
%187 = load double, double* %33
%188 = fsub double 1.000000e+00, %187
%189 = fmul double %186, %188
%190 = load double, double* %33
%191 = fmul double %189, %190
%192 = call double @llvm.fmuladd.f64(double %182, double %184, double %191)
%193 = load double, double* %16
%194 = load double, double* %33
%195 = fmul double %193, %194
%196 = load double, double* %33
%197 = call double @llvm.fmuladd.f64(double %195, double %196, double %192)
store double %197, double* %35
%198 = load double, double* %34
%199 = load double, double* %9
%200 = fsub double %198, %199
%201 = load double, double* %35
%202 = load double, double* %10
%203 = fsub double %201, %202
%204 = call double @hypot(double %200, double %203)
store double %204, double* %36
%205 = load i32, i32* %30
%206 = icmp eq i32 %205, 0
br i1 %206, label %211, label %207
207: ; preds = %155
%208 = load double, double* %36
%209 = load double, double* %31
%210 = fcmp olt double %208, %209
br i1 %210, label %211, label %213
211: ; preds = %207, %155
%212 = load double, double* %36
store double %212, double* %31
br label %213
213: ; preds = %211, %207
br label %214
214: ; preds = %213
%215 = load i32, i32* %30
%216 = add nsw i32 %215, 1
store i32 %216, i32* %30
br label %151
217: ; preds = %151
%218 = load double, double* %31
ret double %218
}

LLVM IR (-O2):
define double @dist_to_quadratic(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%9 = alloca [3 x double]
%10 = alloca [4 x double]
%11 = bitcast [3 x double]* %9 to i8*
%12 = bitcast [4 x double]* %10 to i8*
%13 = insertelement <2 x double> poison, double %4, i64 0
%14 = insertelement <2 x double> %13, double %5, i64 1
%15 = insertelement <2 x double> poison, double %2, i64 0
%16 = insertelement <2 x double> %15, double %3, i64 1
%17 = fsub <2 x double> %14, %16
%18 = insertelement <2 x double> poison, double %0, i64 0
%19 = insertelement <2 x double> %18, double %1, i64 1
%20 = fsub <2 x double> %16, %19
%21 = fmul <2 x double> %20, %17
%22 = extractelement <2 x double> %21, i64 0
%23 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %14, <2 x double> <double -2.000000e+00, double -2.000000e+00>, <2 x double> %16)
%24 = insertelement <2 x double> poison, double %6, i64 0
%25 = insertelement <2 x double> %24, double %7, i64 1
%26 = fadd <2 x double> %23, %25
%27 = fmul <2 x double> %17, <double 2.000000e+00, double 2.000000e+00>
%28 = fmul <2 x double> %26, %26
%29 = extractelement <2 x double> %28, i64 0
%30 = extractelement <2 x double> %17, i64 1
%31 = extractelement <2 x double> %20, i64 1
%32 = tail call double @llvm.fmuladd.f64(double %31, double %30, double %22)
%33 = fmul <2 x double> %20, %26
%34 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %17, <2 x double> %33)
%35 = shufflevector <2 x double> %34, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%36 = fadd <2 x double> %34, %35
%37 = extractelement <2 x double> %36, i64 0
%38 = fmul <2 x double> %27, %26
%39 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %26, <2 x double> %17, <2 x double> %38)
%40 = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%41 = fadd <2 x double> %39, %40
%42 = extractelement <2 x double> %41, i64 0
%43 = extractelement <2 x double> %26, i64 1
%44 = tail call double @llvm.fmuladd.f64(double %43, double %43, double %29)
%45 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%46 = call i32 @solve_cubic(double %32, double %37, double %42, double %44, double* %45)
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %99
48: ; preds = %8
%49 = zext i32 %46 to i64
%50 = and i64 %49, 1
%51 = icmp eq i32 %46, 1
br i1 %51, label %84, label %52
52: ; preds = %48
%53 = and i64 %49, 4294967294
br label %54
54: ; preds = %79, %52
%55 = phi i64 [ 0, %52 ], [ %81, %79 ]
%56 = phi i32 [ 0, %52 ], [ %80, %79 ]
%57 = phi i64 [ 0, %52 ], [ %82, %79 ]
%58 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 %55
%59 = load double, double* %58
%60 = fcmp ogt double %59, 0.000000e+00
%61 = fcmp olt double %59, 1.000000e+00
%62 = and i1 %60, %61
br i1 %62, label %63, label %67
63: ; preds = %54
%64 = add nsw i32 %56, 1
%65 = sext i32 %56 to i64
%66 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 %65
store double %59, double* %66
br label %67
67: ; preds = %63, %54
%68 = phi i32 [ %64, %63 ], [ %56, %54 ]
%69 = or i64 %55, 1
%70 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 %69
%71 = load double, double* %70
%72 = fcmp ogt double %71, 0.000000e+00
%73 = fcmp olt double %71, 1.000000e+00
%74 = and i1 %72, %73
br i1 %74, label %75, label %79
75: ; preds = %67
%76 = add nsw i32 %68, 1
%77 = sext i32 %68 to i64
%78 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 %77
store double %71, double* %78
br label %79
79: ; preds = %75, %67
%80 = phi i32 [ %76, %75 ], [ %68, %67 ]
%81 = add nuw nsw i64 %55, 2
%82 = add i64 %57, 2
%83 = icmp eq i64 %82, %53
br i1 %83, label %84, label %54
84: ; preds = %79, %48
%85 = phi i32 [ undef, %48 ], [ %80, %79 ]
%86 = phi i64 [ 0, %48 ], [ %81, %79 ]
%87 = phi i32 [ 0, %48 ], [ %80, %79 ]
%88 = icmp eq i64 %50, 0
br i1 %88, label %99, label %89
89: ; preds = %84
%90 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 %86
%91 = load double, double* %90
%92 = fcmp ogt double %91, 0.000000e+00
%93 = fcmp olt double %91, 1.000000e+00
%94 = and i1 %92, %93
br i1 %94, label %95, label %99
95: ; preds = %89
%96 = add nsw i32 %87, 1
%97 = sext i32 %87 to i64
%98 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 %97
store double %91, double* %98
br label %99
99: ; preds = %84, %95, %89, %8
%100 = phi i32 [ 0, %8 ], [ %85, %84 ], [ %96, %95 ], [ %87, %89 ]
%101 = icmp slt i32 %100, %46
br i1 %101, label %102, label %109
102: ; preds = %99
%103 = add nsw i32 %100, 1
%104 = sext i32 %100 to i64
%105 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 %104
store double 0.000000e+00, double* %105
%106 = add nsw i32 %100, 2
%107 = sext i32 %103 to i64
%108 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 %107
store double 1.000000e+00, double* %108
br label %109
109: ; preds = %102, %99
%110 = phi i32 [ %106, %102 ], [ %100, %99 ]
%111 = icmp sgt i32 %110, 0
br i1 %111, label %112, label %143
112: ; preds = %109
%113 = fmul double %4, 2.000000e+00
%114 = fmul double %5, 2.000000e+00
%115 = zext i32 %110 to i64
br label %116
116: ; preds = %112, %116
%117 = phi i64 [ 0, %112 ], [ %141, %116 ]
%118 = phi double [ 0.000000e+00, %112 ], [ %140, %116 ]
%119 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 %117
%120 = load double, double* %119
%121 = fsub double 1.000000e+00, %120
%122 = fmul double %121, %2
%123 = fmul double %113, %121
%124 = fmul double %120, %123
%125 = call double @llvm.fmuladd.f64(double %122, double %121, double %124)
%126 = fmul double %120, %6
%127 = call double @llvm.fmuladd.f64(double %126, double %120, double %125)
%128 = fmul double %121, %3
%129 = fmul double %114, %121
%130 = fmul double %120, %129
%131 = call double @llvm.fmuladd.f64(double %128, double %121, double %130)
%132 = fmul double %120, %7
%133 = call double @llvm.fmuladd.f64(double %132, double %120, double %131)
%134 = fsub double %127, %0
%135 = fsub double %133, %1
%136 = call double @hypot(double %134, double %135)
%137 = icmp eq i64 %117, 0
%138 = fcmp olt double %136, %118
%139 = select i1 %137, i1 true, i1 %138
%140 = select i1 %139, double %136, double %118
%141 = add nuw nsw i64 %117, 1
%142 = icmp eq i64 %141, %115
br i1 %142, label %143, label %116
143: ; preds = %116, %109
%144 = phi double [ 0.000000e+00, %109 ], [ %140, %116 ]
ret double %144
}