#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 sqrt(double);
double dist_to_line(double A, double B, double C, double x, double y) {
  double d = (A * x) + (B * y) + C;
  if (d < 0)
    d *= -1;
  double s = sqrt((A * A) + (B * B));
  double dist = d / s;
  return dist;
}


x86 assembly (clang, -O0):
<dist_to_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1177 <dist_to_line+0x67>
movsd  0xe93(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dist_to_line>:
sub    $0x18,%rsp
mulsd  %xmm1,%xmm4
mulsd  %xmm0,%xmm3
addsd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
movapd 0xed4(%rip),%xmm2
xorpd  %xmm3,%xmm2
xorpd  %xmm4,%xmm4
movapd %xmm3,%xmm5
cmpltsd %xmm4,%xmm5
andpd  %xmm5,%xmm2
andnpd %xmm3,%xmm5
orpd   %xmm2,%xmm5
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm4,%xmm0
jb     1161 <dist_to_line+0x51>
sqrtsd %xmm0,%xmm0
jmp    1170 <dist_to_line+0x60>
movapd %xmm5,(%rsp)
call   1030 <sqrt@plt>
movapd (%rsp),%xmm5
divsd  %xmm0,%xmm5
movapd %xmm5,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @dist_to_line(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%14 = load double, double* %6
%15 = load double, double* %9
%16 = load double, double* %7
%17 = load double, double* %10
%18 = fmul double %16, %17
%19 = call double @llvm.fmuladd.f64(double %14, double %15, double %18)
%20 = load double, double* %8
%21 = fadd double %19, %20
store double %21, double* %11
%22 = load double, double* %11
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %24, label %27
24: ; preds = %5
%25 = load double, double* %11
%26 = fmul double %25, -1.000000e+00
store double %26, double* %11
br label %27
27: ; preds = %24, %5
%28 = load double, double* %6
%29 = load double, double* %6
%30 = load double, double* %7
%31 = load double, double* %7
%32 = fmul double %30, %31
%33 = call double @llvm.fmuladd.f64(double %28, double %29, double %32)
%34 = call double @sqrt(double %33)
store double %34, double* %12
%35 = load double, double* %11
%36 = load double, double* %12
%37 = fdiv double %35, %36
store double %37, double* %13
%38 = load double, double* %13
ret double %38
}

LLVM IR (-O2):
define double @dist_to_line(double %0, double %1, double %2, double %3, double %4) {
%6 = fmul double %1, %4
%7 = tail call double @llvm.fmuladd.f64(double %0, double %3, double %6)
%8 = fadd double %7, %2
%9 = fcmp olt double %8, 0.000000e+00
%10 = fneg double %8
%11 = select i1 %9, double %10, double %8
%12 = fmul double %1, %1
%13 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %12)
%14 = tail call double @sqrt(double %13)
%15 = fdiv double %11, %14
ret double %15
}