#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 /*<<< orphan*/ crossVectorsNorm_double(double *, double *, double *);
double dotVectors_double(double const *, double *);
scalar_t__ magnitudeVector_double(double *);
int /*<<< orphan*/ normalizeVector_double(double *);
void projectPointReturnNorm_double(const double *point, const double *v0,
                                   const double *v1, const double *v2,
                                   double *projected_point, double *norm) {
  double v0v1[3], v0v2[3];
  double s;
  v0v1[0] = v1[0] - v0[0];
  v0v1[1] = v1[1] - v0[1];
  v0v1[2] = v1[2] - v0[2];
  v0v2[0] = v2[0] - v0[0];
  v0v2[1] = v2[1] - v0[1];
  v0v2[2] = v2[2] - v0[2];
  crossVectorsNorm_double(v0v1, v0v2, norm);
  if (magnitudeVector_double(norm) == 0) {
    norm[0] = v0[0];
    norm[1] = v0[1];
    norm[2] = v0[2];
    normalizeVector_double(norm);
  }
  s = dotVectors_double(v0, norm) / dotVectors_double(point, norm);
  projected_point[0] = s * point[0];
  projected_point[1] = s * point[1];
  projected_point[2] = s * point[2];
  return;
}


x86 assembly (clang, -O0):
<projectPointReturnNorm_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <crossVectorsNorm_double@plt>
mov    -0x30(%rbp),%rdi
call   1060 <magnitudeVector_double@plt>
cmp    $0x0,%rax
jne    124a <projectPointReturnNorm_double+0x10a>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x30(%rbp),%rdi
call   1040 <normalizeVector_double@plt>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <dotVectors_double@plt>
movsd  %xmm0,-0x80(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <dotVectors_double@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x78(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x78(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<projectPointReturnNorm_double>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,%rbx
mov    %r8,%r14
mov    %rsi,%r12
mov    %rdi,%r15
movupd (%rdx),%xmm0
movupd (%rsi),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x30(%rsp)
movsd  0x10(%rdx),%xmm0
movsd  0x10(%rsi),%xmm2
subsd  %xmm2,%xmm0
movsd  %xmm0,0x40(%rsp)
movupd (%rcx),%xmm0
subpd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x10(%rcx),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0x30(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %r9,%rdx
call   1050 <crossVectorsNorm_double@plt>
mov    %rbx,%rdi
call   1060 <magnitudeVector_double@plt>
test   %rax,%rax
jne    11e3 <projectPointReturnNorm_double+0xa3>
movsd  (%r12),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%r12),%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x10(%r12),%xmm0
movsd  %xmm0,0x10(%rbx)
mov    %rbx,%rdi
call   1040 <normalizeVector_double@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <dotVectors_double@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <dotVectors_double@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%r15),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%r15),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%r14)
mulsd  0x10(%r15),%xmm1
movsd  %xmm1,0x10(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @projectPointReturnNorm_double(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 [3 x double]
%14 = alloca [3 x 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** %9
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
%19 = load double*, double** %8
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = fsub double %18, %21
%23 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
store double %22, double* %23
%24 = load double*, double** %9
%25 = getelementptr inbounds double, double* %24, i64 1
%26 = load double, double* %25
%27 = load double*, double** %8
%28 = getelementptr inbounds double, double* %27, i64 1
%29 = load double, double* %28
%30 = fsub double %26, %29
%31 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 1
store double %30, double* %31
%32 = load double*, double** %9
%33 = getelementptr inbounds double, double* %32, i64 2
%34 = load double, double* %33
%35 = load double*, double** %8
%36 = getelementptr inbounds double, double* %35, i64 2
%37 = load double, double* %36
%38 = fsub double %34, %37
%39 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 2
store double %38, double* %39
%40 = load double*, double** %10
%41 = getelementptr inbounds double, double* %40, i64 0
%42 = load double, double* %41
%43 = load double*, double** %8
%44 = getelementptr inbounds double, double* %43, i64 0
%45 = load double, double* %44
%46 = fsub double %42, %45
%47 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
store double %46, double* %47
%48 = load double*, double** %10
%49 = getelementptr inbounds double, double* %48, i64 1
%50 = load double, double* %49
%51 = load double*, double** %8
%52 = getelementptr inbounds double, double* %51, i64 1
%53 = load double, double* %52
%54 = fsub double %50, %53
%55 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 1
store double %54, double* %55
%56 = load double*, double** %10
%57 = getelementptr inbounds double, double* %56, i64 2
%58 = load double, double* %57
%59 = load double*, double** %8
%60 = getelementptr inbounds double, double* %59, i64 2
%61 = load double, double* %60
%62 = fsub double %58, %61
%63 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 2
store double %62, double* %63
%64 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%65 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%66 = load double*, double** %12
%67 = call i32 @crossVectorsNorm_double(double* %64, double* %65, double* %66)
%68 = load double*, double** %12
%69 = call i64 @magnitudeVector_double(double* %68)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %89
71: ; preds = %6
%72 = load double*, double** %8
%73 = getelementptr inbounds double, double* %72, i64 0
%74 = load double, double* %73
%75 = load double*, double** %12
%76 = getelementptr inbounds double, double* %75, i64 0
store double %74, double* %76
%77 = load double*, double** %8
%78 = getelementptr inbounds double, double* %77, i64 1
%79 = load double, double* %78
%80 = load double*, double** %12
%81 = getelementptr inbounds double, double* %80, i64 1
store double %79, double* %81
%82 = load double*, double** %8
%83 = getelementptr inbounds double, double* %82, i64 2
%84 = load double, double* %83
%85 = load double*, double** %12
%86 = getelementptr inbounds double, double* %85, i64 2
store double %84, double* %86
%87 = load double*, double** %12
%88 = call i32 @normalizeVector_double(double* %87)
br label %89
89: ; preds = %71, %6
%90 = load double*, double** %8
%91 = load double*, double** %12
%92 = call double @dotVectors_double(double* %90, double* %91)
%93 = load double*, double** %7
%94 = load double*, double** %12
%95 = call double @dotVectors_double(double* %93, double* %94)
%96 = fdiv double %92, %95
store double %96, double* %15
%97 = load double, double* %15
%98 = load double*, double** %7
%99 = getelementptr inbounds double, double* %98, i64 0
%100 = load double, double* %99
%101 = fmul double %97, %100
%102 = load double*, double** %11
%103 = getelementptr inbounds double, double* %102, i64 0
store double %101, double* %103
%104 = load double, double* %15
%105 = load double*, double** %7
%106 = getelementptr inbounds double, double* %105, i64 1
%107 = load double, double* %106
%108 = fmul double %104, %107
%109 = load double*, double** %11
%110 = getelementptr inbounds double, double* %109, i64 1
store double %108, double* %110
%111 = load double, double* %15
%112 = load double*, double** %7
%113 = getelementptr inbounds double, double* %112, i64 2
%114 = load double, double* %113
%115 = fmul double %111, %114
%116 = load double*, double** %11
%117 = getelementptr inbounds double, double* %116, i64 2
store double %115, double* %117
ret void
}

LLVM IR (-O2):
define void @projectPointReturnNorm_double(double* %0, double* %1, double* nocapture %2, double* nocapture %3, double* nocapture writeonly %4, double* %5) {
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = bitcast [3 x double]* %7 to i8*
%10 = bitcast [3 x double]* %8 to i8*
%11 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%12 = bitcast double* %2 to <2 x double>*
%13 = load <2 x double>, <2 x double>* %12
%14 = bitcast double* %1 to <2 x double>*
%15 = load <2 x double>, <2 x double>* %14
%16 = fsub <2 x double> %13, %15
%17 = bitcast [3 x double]* %7 to <2 x double>*
store <2 x double> %16, <2 x double>* %17
%18 = getelementptr inbounds double, double* %2, i64 2
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %1, i64 2
%21 = load double, double* %20
%22 = fsub double %19, %21
%23 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
store double %22, double* %23
%24 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%25 = bitcast double* %3 to <2 x double>*
%26 = load <2 x double>, <2 x double>* %25
%27 = fsub <2 x double> %26, %15
%28 = bitcast [3 x double]* %8 to <2 x double>*
store <2 x double> %27, <2 x double>* %28
%29 = getelementptr inbounds double, double* %3, i64 2
%30 = load double, double* %29
%31 = fsub double %30, %21
%32 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
store double %31, double* %32
%33 = call i32 @crossVectorsNorm_double(double* %11, double* %24, double* %5)
%34 = call i64 @magnitudeVector_double(double* %5)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %6
%37 = getelementptr inbounds double, double* %1, i64 1
%38 = load double, double* %1
store double %38, double* %5
%39 = load double, double* %37
%40 = getelementptr inbounds double, double* %5, i64 1
store double %39, double* %40
%41 = load double, double* %20
%42 = getelementptr inbounds double, double* %5, i64 2
store double %41, double* %42
%43 = call i32 @normalizeVector_double(double* %5)
br label %44
44: ; preds = %36, %6
%45 = call double @dotVectors_double(double* %1, double* %5)
%46 = call double @dotVectors_double(double* %0, double* %5)
%47 = fdiv double %45, %46
%48 = load double, double* %0
%49 = fmul double %47, %48
store double %49, double* %4
%50 = getelementptr inbounds double, double* %0, i64 1
%51 = load double, double* %50
%52 = fmul double %47, %51
%53 = getelementptr inbounds double, double* %4, i64 1
store double %52, double* %53
%54 = getelementptr inbounds double, double* %0, i64 2
%55 = load double, double* %54
%56 = fmul double %47, %55
%57 = getelementptr inbounds double, double* %4, i64 2
store double %56, double* %57
ret void
}