#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 */
float glmComputeDistance3f(float const *, float *);
float glmDotProduct3f(float const *, float *);
int /*<<< orphan*/ glmMakeVector3f(float *, float const *, float const *);
float glmComputeDistanceToLine3f(const float lineOrigin[3],
                                 const float lineDirection[3],
                                 const float p[3]) {
  float c[3], temp[3];
  float t;
  glmMakeVector3f(c, lineOrigin, p);
  t = glmDotProduct3f(lineDirection, c);
  temp[0] = lineOrigin[0] + t * lineDirection[0];
  temp[1] = lineOrigin[1] + t * lineDirection[1];
  temp[2] = lineOrigin[2] + t * lineDirection[2];
  return glmComputeDistance3f(p, temp);
}


x86 assembly (clang, -O0):
<glmComputeDistanceToLine3f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x24(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <glmMakeVector3f@plt>
mov    -0x10(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <glmDotProduct3f@plt>
movss  %xmm0,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
movss  -0x34(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
movss  -0x34(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm1
movss  -0x34(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <glmComputeDistance3f@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmComputeDistanceToLine3f>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xc(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <glmMakeVector3f@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <glmDotProduct3f@plt>
movss  (%rbx),%xmm1
mulss  %xmm0,%xmm1
addss  (%r15),%xmm1
movss  %xmm1,(%rsp)
movss  0x4(%rbx),%xmm1
mulss  %xmm0,%xmm1
addss  0x4(%r15),%xmm1
movss  %xmm1,0x4(%rsp)
mulss  0x8(%rbx),%xmm0
addss  0x8(%r15),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1040 <glmComputeDistance3f@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @glmComputeDistanceToLine3f(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca [3 x float]
%8 = alloca [3 x float]
%9 = alloca float
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%10 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%11 = load float*, float** %4
%12 = load float*, float** %6
%13 = call i32 @glmMakeVector3f(float* %10, float* %11, float* %12)
%14 = load float*, float** %5
%15 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%16 = call float @glmDotProduct3f(float* %14, float* %15)
store float %16, float* %9
%17 = load float*, float** %4
%18 = getelementptr inbounds float, float* %17, i64 0
%19 = load float, float* %18
%20 = load float, float* %9
%21 = load float*, float** %5
%22 = getelementptr inbounds float, float* %21, i64 0
%23 = load float, float* %22
%24 = call float @llvm.fmuladd.f32(float %20, float %23, float %19)
%25 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
store float %24, float* %25
%26 = load float*, float** %4
%27 = getelementptr inbounds float, float* %26, i64 1
%28 = load float, float* %27
%29 = load float, float* %9
%30 = load float*, float** %5
%31 = getelementptr inbounds float, float* %30, i64 1
%32 = load float, float* %31
%33 = call float @llvm.fmuladd.f32(float %29, float %32, float %28)
%34 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 1
store float %33, float* %34
%35 = load float*, float** %4
%36 = getelementptr inbounds float, float* %35, i64 2
%37 = load float, float* %36
%38 = load float, float* %9
%39 = load float*, float** %5
%40 = getelementptr inbounds float, float* %39, i64 2
%41 = load float, float* %40
%42 = call float @llvm.fmuladd.f32(float %38, float %41, float %37)
%43 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 2
store float %42, float* %43
%44 = load float*, float** %6
%45 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%46 = call float @glmComputeDistance3f(float* %44, float* %45)
ret float %46
}

LLVM IR (-O2):
define float @glmComputeDistanceToLine3f(float* %0, float* %1, float* %2) {
%4 = alloca [3 x float]
%5 = alloca [3 x float]
%6 = bitcast [3 x float]* %4 to i8*
%7 = bitcast [3 x float]* %5 to i8*
%8 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
%9 = call i32 @glmMakeVector3f(float* %8, float* %0, float* %2)
%10 = call float @glmDotProduct3f(float* %1, float* %8)
%11 = load float, float* %0
%12 = load float, float* %1
%13 = call float @llvm.fmuladd.f32(float %10, float %12, float %11)
%14 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
store float %13, float* %14
%15 = getelementptr inbounds float, float* %0, i64 1
%16 = load float, float* %15
%17 = getelementptr inbounds float, float* %1, i64 1
%18 = load float, float* %17
%19 = call float @llvm.fmuladd.f32(float %10, float %18, float %16)
%20 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
store float %19, float* %20
%21 = getelementptr inbounds float, float* %0, i64 2
%22 = load float, float* %21
%23 = getelementptr inbounds float, float* %1, i64 2
%24 = load float, float* %23
%25 = call float @llvm.fmuladd.f32(float %10, float %24, float %22)
%26 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
store float %25, float* %26
%27 = call float @glmComputeDistance3f(float* %2, float* %14)
ret float %27
}