#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 CalcInProduct(float *, float *);
void CalcNearPosOnLine(float pnt[3], float pos[3], float vec[3],
                       float pos_x[3]) {
  float vec_wk[3];
  vec_wk[0] = pnt[0] - pos[0];
  vec_wk[1] = pnt[1] - pos[1];
  vec_wk[2] = pnt[2] - pos[2];
  float dist_wk = CalcInProduct(vec, vec_wk);
  pos_x[0] = pos[0] + vec[0] * dist_wk;
  pos_x[1] = pos[1] + vec[1] * dist_wk;
  pos_x[2] = pos[2] + vec[2] * dist_wk;
}


x86 assembly (clang, -O0):
<CalcNearPosOnLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subss  (%rax),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
subss  0x4(%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subss  0x8(%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1030 <CalcInProduct@plt>
movss  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
movss  -0x30(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm1
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  -0x30(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  -0x30(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalcNearPosOnLine>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
movss  (%rdi),%xmm0
subss  (%rsi),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x4(%rdi),%xmm0
subss  0x4(%rsi),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x8(%rdi),%xmm0
subss  0x8(%rsi),%xmm0
movss  %xmm0,0xc(%rsp)
lea    0x4(%rsp),%rsi
mov    %rdx,%rdi
call   1030 <CalcInProduct@plt>
movss  (%r15),%xmm1
mulss  %xmm0,%xmm1
addss  (%rbx),%xmm1
movss  %xmm1,(%r14)
movss  0x4(%r15),%xmm1
mulss  %xmm0,%xmm1
addss  0x4(%rbx),%xmm1
movss  %xmm1,0x4(%r14)
mulss  0x8(%r15),%xmm0
addss  0x8(%rbx),%xmm0
movss  %xmm0,0x8(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @CalcNearPosOnLine(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca [3 x float]
%10 = alloca float
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%11 = load float*, float** %5
%12 = getelementptr inbounds float, float* %11, i64 0
%13 = load float, float* %12
%14 = load float*, float** %6
%15 = getelementptr inbounds float, float* %14, i64 0
%16 = load float, float* %15
%17 = fsub float %13, %16
%18 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
store float %17, float* %18
%19 = load float*, float** %5
%20 = getelementptr inbounds float, float* %19, i64 1
%21 = load float, float* %20
%22 = load float*, float** %6
%23 = getelementptr inbounds float, float* %22, i64 1
%24 = load float, float* %23
%25 = fsub float %21, %24
%26 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
store float %25, float* %26
%27 = load float*, float** %5
%28 = getelementptr inbounds float, float* %27, i64 2
%29 = load float, float* %28
%30 = load float*, float** %6
%31 = getelementptr inbounds float, float* %30, i64 2
%32 = load float, float* %31
%33 = fsub float %29, %32
%34 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
store float %33, float* %34
%35 = load float*, float** %7
%36 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%37 = call float @CalcInProduct(float* %35, float* %36)
store float %37, float* %10
%38 = load float*, float** %6
%39 = getelementptr inbounds float, float* %38, i64 0
%40 = load float, float* %39
%41 = load float*, float** %7
%42 = getelementptr inbounds float, float* %41, i64 0
%43 = load float, float* %42
%44 = load float, float* %10
%45 = call float @llvm.fmuladd.f32(float %43, float %44, float %40)
%46 = load float*, float** %8
%47 = getelementptr inbounds float, float* %46, i64 0
store float %45, float* %47
%48 = load float*, float** %6
%49 = getelementptr inbounds float, float* %48, i64 1
%50 = load float, float* %49
%51 = load float*, float** %7
%52 = getelementptr inbounds float, float* %51, i64 1
%53 = load float, float* %52
%54 = load float, float* %10
%55 = call float @llvm.fmuladd.f32(float %53, float %54, float %50)
%56 = load float*, float** %8
%57 = getelementptr inbounds float, float* %56, i64 1
store float %55, float* %57
%58 = load float*, float** %6
%59 = getelementptr inbounds float, float* %58, i64 2
%60 = load float, float* %59
%61 = load float*, float** %7
%62 = getelementptr inbounds float, float* %61, i64 2
%63 = load float, float* %62
%64 = load float, float* %10
%65 = call float @llvm.fmuladd.f32(float %63, float %64, float %60)
%66 = load float*, float** %8
%67 = getelementptr inbounds float, float* %66, i64 2
store float %65, float* %67
ret void
}

LLVM IR (-O2):
define void @CalcNearPosOnLine(float* nocapture %0, float* nocapture %1, float* %2, float* nocapture writeonly %3) {
%5 = alloca [3 x float]
%6 = bitcast [3 x float]* %5 to i8*
%7 = load float, float* %0
%8 = load float, float* %1
%9 = fsub float %7, %8
%10 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
store float %9, float* %10
%11 = getelementptr inbounds float, float* %0, i64 1
%12 = load float, float* %11
%13 = getelementptr inbounds float, float* %1, i64 1
%14 = load float, float* %13
%15 = fsub float %12, %14
%16 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
store float %15, float* %16
%17 = getelementptr inbounds float, float* %0, i64 2
%18 = load float, float* %17
%19 = getelementptr inbounds float, float* %1, i64 2
%20 = load float, float* %19
%21 = fsub float %18, %20
%22 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
store float %21, float* %22
%23 = call float @CalcInProduct(float* %2, float* %10)
%24 = load float, float* %1
%25 = load float, float* %2
%26 = call float @llvm.fmuladd.f32(float %25, float %23, float %24)
store float %26, float* %3
%27 = load float, float* %13
%28 = getelementptr inbounds float, float* %2, i64 1
%29 = load float, float* %28
%30 = call float @llvm.fmuladd.f32(float %29, float %23, float %27)
%31 = getelementptr inbounds float, float* %3, i64 1
store float %30, float* %31
%32 = load float, float* %19
%33 = getelementptr inbounds float, float* %2, i64 2
%34 = load float, float* %33
%35 = call float @llvm.fmuladd.f32(float %34, float %23, float %32)
%36 = getelementptr inbounds float, float* %3, i64 2
store float %35, float* %36
ret void
}