#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 projectPoint_double(const double *point, const double *v0,
                         const double *v1, const double *v2,
                         double *projected_point) {
  double v0v1[3], v0v2[3], norm[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):
<projectPoint_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1050 <crossVectorsNorm_double@plt>
lea    -0x80(%rbp),%rdi
call   1060 <magnitudeVector_double@plt>
cmp    $0x0,%rax
jne    123b <projectPoint_double+0xfb>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
lea    -0x80(%rbp),%rdi
call   1040 <normalizeVector_double@plt>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1030 <dotVectors_double@plt>
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x8(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1030 <dotVectors_double@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x88(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x88(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<projectPoint_double>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r8,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movupd (%rdx),%xmm0
movupd (%rsi),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x50(%rsp)
movsd  0x10(%rdx),%xmm0
movsd  0x10(%rsi),%xmm2
subsd  %xmm2,%xmm0
movsd  %xmm0,0x60(%rsp)
movupd (%rcx),%xmm0
subpd  %xmm1,%xmm0
movapd %xmm0,0x30(%rsp)
movsd  0x10(%rcx),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x40(%rsp)
lea    0x50(%rsp),%rdi
lea    0x30(%rsp),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdx
call   1050 <crossVectorsNorm_double@plt>
mov    %r12,%rdi
call   1060 <magnitudeVector_double@plt>
test   %rax,%rax
jne    11d8 <projectPoint_double+0x98>
movups (%rbx),%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0x10(%rsp),%rdi
call   1040 <normalizeVector_double@plt>
lea    0x10(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <dotVectors_double@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %r12,%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    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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