#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);
double pt_dist(double, double, double, double);
int pt_lies_seg(double ln_x0, double ln_y0, double ln_x1, double ln_y1,
                double pt_x, double pt_y) {
  double ln = pt_dist(ln_x0, ln_y0, ln_x1, ln_y1);
  double seg1 = pt_dist(ln_x0, ln_y0, pt_x, pt_y);
  double seg2 = pt_dist(pt_x, pt_y, ln_x1, ln_y1);
  return fabs(ln - seg1 - seg2) < 1e-9;
}


x86 assembly (clang, -O0):
<pt_lies_seg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
call   1030 <pt_dist@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
call   1030 <pt_dist@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
call   1030 <pt_dist@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe40(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pt_lies_seg>:
sub    $0x38,%rsp
movsd  %xmm5,0x10(%rsp)
movsd  %xmm4,0x8(%rsp)
movsd  %xmm3,0x28(%rsp)
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x18(%rsp)
call   1030 <pt_dist@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
call   1030 <pt_dist@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x28(%rsp),%xmm3
call   1030 <pt_dist@plt>
movsd  0x30(%rsp),%xmm1
subsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1040 <fabs@plt>
xor    %ecx,%ecx
test   %eax,%eax
setle  %cl
mov    %ecx,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
define i32 @pt_lies_seg(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
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%16 = load double, double* %7
%17 = load double, double* %8
%18 = load double, double* %9
%19 = load double, double* %10
%20 = call double @pt_dist(double %16, double %17, double %18, double %19)
store double %20, double* %13
%21 = load double, double* %7
%22 = load double, double* %8
%23 = load double, double* %11
%24 = load double, double* %12
%25 = call double @pt_dist(double %21, double %22, double %23, double %24)
store double %25, double* %14
%26 = load double, double* %11
%27 = load double, double* %12
%28 = load double, double* %9
%29 = load double, double* %10
%30 = call double @pt_dist(double %26, double %27, double %28, double %29)
store double %30, double* %15
%31 = load double, double* %13
%32 = load double, double* %14
%33 = fsub double %31, %32
%34 = load double, double* %15
%35 = fsub double %33, %34
%36 = call i32 @fabs(double %35)
%37 = sitofp i32 %36 to double
%38 = fcmp olt double %37, 1.000000e-09
%39 = zext i1 %38 to i32
ret i32 %39
}

LLVM IR (-O2):
define i32 @pt_lies_seg(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = tail call double @pt_dist(double %0, double %1, double %2, double %3)
%8 = tail call double @pt_dist(double %0, double %1, double %4, double %5)
%9 = tail call double @pt_dist(double %4, double %5, double %2, double %3)
%10 = fsub double %7, %8
%11 = fsub double %10, %9
%12 = tail call i32 @fabs(double %11)
%13 = icmp slt i32 %12, 1
%14 = zext i1 %13 to i32
ret i32 %14
}