#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 fabs(double);
double pythagoras(double, double);
double nearLine(double x, double y, double x1, double y1, double x2,
                double y2) {
  double d1 = pythagoras(x - x1, y - y1), d2 = pythagoras(x - x2, y - y2), d3,
         distance = d1, slope = (y1 - y2) / (x1 - x2), x3, y3;
  if (d2 < d1)
    distance = d2;
  if (fabs(slope) < 1.0e-6) {
    if (((x > x1) && (x > x2)) || ((x < x1) && (x < x2)))
      return distance;
    else
      return fabs(y - y1 + y - y2) / 2.0;
  } else if (fabs(slope) > (1 / 1.0e-6)) {
    if (((y > y1) && (y > y2)) || ((y < y1) && (y < y2)))
      return distance;
    else
      return fabs(x - x1 + x - x2) / 2.0;
  } else {
    x3 = (slope * slope * x1 - slope * (y1 - y) + x) / (slope * slope + 1);
    y3 = (slope * slope * y - slope * (x1 - x) + y1) / (slope * slope + 1);
    d3 = pythagoras(x - x3, y - y3);
    if (((x3 > x1) && (x3 > x2)) || ((x3 < x1) && (x3 < x2)))
      return distance;
    else
      return d3;
  }
}


x86 assembly (clang, -O0):
<nearLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%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  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
call   1030 <pythagoras@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
call   1030 <pythagoras@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b7 <nearLine+0xa7>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x60(%rbp),%xmm1
movaps 0xe5d(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe31(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1265 <nearLine+0x155>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11f9 <nearLine+0xe9>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
ja     1221 <nearLine+0x111>
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1230 <nearLine+0x120>
movsd  -0x10(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1230 <nearLine+0x120>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1464 <nearLine+0x354>
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movaps 0xdd5(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xdc1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1464 <nearLine+0x354>
movsd  -0x60(%rbp),%xmm0
movaps 0xdaf(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd8b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1313 <nearLine+0x203>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    12a7 <nearLine+0x197>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
ja     12cf <nearLine+0x1bf>
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12de <nearLine+0x1ce>
movsd  -0x18(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12de <nearLine+0x1ce>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1464 <nearLine+0x354>
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movaps 0xd27(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd13(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1464 <nearLine+0x354>
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm3
subsd  -0x18(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xca1(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
subsd  -0x10(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xc38(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x70(%rbp),%xmm1
call   1030 <pythagoras@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x68(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1423 <nearLine+0x313>
movsd  -0x68(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
ja     144b <nearLine+0x33b>
movsd  -0x68(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    145a <nearLine+0x34a>
movsd  -0x68(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    145a <nearLine+0x34a>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1464 <nearLine+0x354>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nearLine>:
sub    $0x78,%rsp
movsd  %xmm5,0x30(%rsp)
movsd  %xmm4,0x18(%rsp)
movsd  %xmm3,0x48(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x10(%rsp)
subsd  %xmm2,%xmm0
subsd  %xmm3,%xmm1
movapd %xmm0,0x60(%rsp)
movapd %xmm1,0x50(%rsp)
call   1030 <pythagoras@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  0x30(%rsp),%xmm1
call   1030 <pythagoras@plt>
movsd  0x30(%rsp),%xmm6
movsd  0x48(%rsp),%xmm7
movsd  0x8(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movapd %xmm7,%xmm5
subsd  %xmm6,%xmm5
movapd %xmm3,%xmm1
subsd  %xmm4,%xmm1
divsd  %xmm1,%xmm5
minsd  0x20(%rsp),%xmm0
movapd 0xe54(%rip),%xmm1
andpd  %xmm5,%xmm1
movsd  0xe58(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    11db <nearLine+0xcb>
movapd 0x50(%rsp),%xmm5
movsd  0x10(%rsp),%xmm2
ucomisd %xmm3,%xmm2
jbe    1222 <nearLine+0x112>
ucomisd %xmm4,%xmm2
jbe    1222 <nearLine+0x112>
add    $0x78,%rsp
ret
movapd 0x60(%rsp),%xmm2
movsd  0x10(%rsp),%xmm8
ucomisd 0xe28(%rip),%xmm1
jbe    1254 <nearLine+0x144>
movsd  (%rsp),%xmm1
ucomisd %xmm7,%xmm1
jbe    1203 <nearLine+0xf3>
ucomisd %xmm6,%xmm1
ja     11d6 <nearLine+0xc6>
ucomisd %xmm1,%xmm7
movapd %xmm8,%xmm7
jbe    1214 <nearLine+0x104>
ucomisd %xmm1,%xmm6
ja     11d6 <nearLine+0xc6>
movapd %xmm2,%xmm0
addsd  %xmm7,%xmm0
subsd  %xmm4,%xmm0
jmp    123f <nearLine+0x12f>
ucomisd %xmm2,%xmm3
movsd  (%rsp),%xmm1
jbe    1233 <nearLine+0x123>
ucomisd %xmm2,%xmm4
ja     11d6 <nearLine+0xc6>
movapd %xmm5,%xmm0
addsd  %xmm1,%xmm0
subsd  %xmm6,%xmm0
andpd  0xdb9(%rip),%xmm0
mulsd  0xdd9(%rip),%xmm0
add    $0x78,%rsp
ret
movapd %xmm0,0x20(%rsp)
movapd %xmm5,%xmm4
mulsd  %xmm5,%xmm4
movapd %xmm7,%xmm2
movsd  (%rsp),%xmm1
subsd  %xmm1,%xmm2
mulsd  %xmm5,%xmm2
movapd %xmm4,%xmm6
mulsd  %xmm3,%xmm6
subsd  %xmm2,%xmm6
movapd %xmm8,%xmm0
addsd  %xmm8,%xmm6
movsd  0xd8f(%rip),%xmm2
addsd  %xmm4,%xmm2
divsd  %xmm2,%xmm6
movapd %xmm6,0x30(%rsp)
movsd  0x8(%rsp),%xmm3
subsd  %xmm8,%xmm3
mulsd  %xmm5,%xmm3
mulsd  %xmm1,%xmm4
subsd  %xmm3,%xmm4
addsd  %xmm7,%xmm4
divsd  %xmm2,%xmm4
subsd  %xmm6,%xmm0
subsd  %xmm4,%xmm1
call   1030 <pythagoras@plt>
movapd 0x30(%rsp),%xmm4
movsd  0x8(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
ucomisd %xmm3,%xmm4
jbe    12f3 <nearLine+0x1e3>
ucomisd %xmm2,%xmm4
jbe    12f3 <nearLine+0x1e3>
movaps 0x20(%rsp),%xmm0
add    $0x78,%rsp
ret
movapd %xmm4,%xmm1
cmpltsd %xmm2,%xmm1
movapd 0x20(%rsp),%xmm2
andpd  %xmm1,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
cmpltsd %xmm3,%xmm4
andpd  %xmm4,%xmm1
andnpd %xmm0,%xmm4
orpd   %xmm1,%xmm4
movapd %xmm4,%xmm0
add    $0x78,%rsp
ret

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

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