#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 _dot(double *, double *, int);
int /*<<< orphan*/ _vect(double *, double *, double *);
double sqrt(int);
double c_distance_to_line(double *point, double *a, double *b) {
  double ab[3];
  double ap[3];
  double vect_prod[3];
  int i;
  for (i = 0; i < 3; i++) {
    ab[i] = b[i] - a[i];
    ap[i] = point[i] - a[i];
  }
  _vect(ab, ap, vect_prod);
  return sqrt(_dot(vect_prod, vect_prod, 3) / _dot(ab, ab, 3));
}


x86 assembly (clang, -O0):
<c_distance_to_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x74(%rbp)
cmpl   $0x3,-0x74(%rbp)
jge    11ae <c_distance_to_line+0x7e>
mov    -0x18(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x74(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0x74(%rbp),%rax
movsd  %xmm0,-0x30(%rbp,%rax,8)
mov    -0x8(%rbp),%rax
movslq -0x74(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x74(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0x74(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    114e <c_distance_to_line+0x1e>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1040 <_vect@plt>
lea    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x3,%edx
call   1030 <_dot@plt>
mov    %eax,-0x78(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x3,%edx
call   1030 <_dot@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1050 <sqrt@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_distance_to_line>:
push   %r14
push   %rbx
sub    $0x58,%rsp
movupd (%rsi),%xmm0
movupd (%rdx),%xmm1
subpd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movupd (%rdi),%xmm1
subpd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movsd  0x10(%rdx),%xmm0
movsd  0x10(%rsi),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rdi),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0x20(%rsp),%r14
mov    %rsp,%rsi
lea    0x40(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <_vect@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <_dot@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <_dot@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %eax,%edi
call   1050 <sqrt@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @c_distance_to_line(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = alloca [3 x double]
%10 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
store i32 0, i32* %10
br label %11
11: ; preds = %43, %3
%12 = load i32, i32* %10
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %46
14: ; preds = %11
%15 = load double*, double** %6
%16 = load i32, i32* %10
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = load double*, double** %5
%21 = load i32, i32* %10
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = fsub double %19, %24
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 %27
store double %25, double* %28
%29 = load double*, double** %4
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %5
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = fsub double %33, %38
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %41
store double %39, double* %42
br label %43
43: ; preds = %14
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %11
46: ; preds = %11
%47 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%48 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%49 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%50 = call i32 @_vect(double* %47, double* %48, double* %49)
%51 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%52 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%53 = call i32 @_dot(double* %51, double* %52, i32 3)
%54 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%55 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%56 = call i32 @_dot(double* %54, double* %55, i32 3)
%57 = sdiv i32 %53, %56
%58 = call double @sqrt(i32 %57)
ret double %58
}

LLVM IR (-O2):
define double @c_distance_to_line(double* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = bitcast [3 x double]* %4 to i8*
%8 = bitcast [3 x double]* %5 to i8*
%9 = bitcast [3 x double]* %6 to i8*
%10 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%11 = bitcast double* %1 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%14 = bitcast double* %2 to <2 x double>*
%15 = load <2 x double>, <2 x double>* %14
%16 = fsub <2 x double> %15, %12
%17 = bitcast [3 x double]* %4 to <2 x double>*
store <2 x double> %16, <2 x double>* %17
%18 = bitcast double* %0 to <2 x double>*
%19 = load <2 x double>, <2 x double>* %18
%20 = fsub <2 x double> %19, %12
%21 = bitcast [3 x double]* %5 to <2 x double>*
store <2 x double> %20, <2 x double>* %21
%22 = getelementptr inbounds double, double* %2, i64 2
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %1, i64 2
%25 = load double, double* %24
%26 = fsub double %23, %25
%27 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
store double %26, double* %27
%28 = getelementptr inbounds double, double* %0, i64 2
%29 = load double, double* %28
%30 = fsub double %29, %25
%31 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double %30, double* %31
%32 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%33 = call i32 @_vect(double* %10, double* %13, double* %32)
%34 = call i32 @_dot(double* %32, double* %32, i32 3)
%35 = call i32 @_dot(double* %10, double* %10, i32 3)
%36 = sdiv i32 %34, %35
%37 = call double @sqrt(i32 %36)
ret double %37
}