#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(float *, float *, float *);
float dotVectors(float const *, float *);
scalar_t__ magnitudeVector(float *);
int /*<<< orphan*/ normalizeVector(float *);
void projectPoint(const float *point, const float *v0, const float *v1,
                  const float *v2, float *projected_point) {
  float v0v1[3], v0v2[3], norm[3];
  float 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(v0v1, v0v2, norm);
  if (magnitudeVector(norm) == 0) {
    norm[0] = v0[0];
    norm[1] = v0[1];
    norm[2] = v0[2];
    normalizeVector(norm);
  }
  s = dotVectors(v0, norm) / dotVectors(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>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subss  (%rax),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
subss  0x4(%rax),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subss  0x8(%rax),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subss  (%rax),%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
subss  0x4(%rax),%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subss  0x8(%rax),%xmm0
movss  %xmm0,-0x38(%rbp)
lea    -0x34(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   1050 <crossVectorsNorm@plt>
lea    -0x4c(%rbp),%rdi
call   1060 <magnitudeVector@plt>
cmp    $0x0,%rax
jne    1238 <projectPoint+0xf8>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x44(%rbp)
lea    -0x4c(%rbp),%rdi
call   1040 <normalizeVector@plt>
mov    -0x10(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
call   1030 <dotVectors@plt>
movss  %xmm0,-0x54(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
call   1030 <dotVectors@plt>
movaps %xmm0,%xmm1
movss  -0x54(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulss  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulss  0x4(%rax),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulss  0x8(%rax),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<projectPoint>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movss  (%rdx),%xmm0
movss  (%rsi),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,0x1c(%rsp)
movss  0x4(%rdx),%xmm0
movss  0x4(%rsi),%xmm2
subss  %xmm2,%xmm0
movss  %xmm0,0x20(%rsp)
movss  0x8(%rdx),%xmm0
movss  0x8(%rsi),%xmm3
subss  %xmm3,%xmm0
movss  %xmm0,0x24(%rsp)
movss  (%rcx),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x4(%rcx),%xmm0
subss  %xmm2,%xmm0
movss  %xmm0,0x14(%rsp)
movss  0x8(%rcx),%xmm0
subss  %xmm3,%xmm0
movss  %xmm0,0x18(%rsp)
lea    0x1c(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x4(%rsp),%r12
mov    %r12,%rdx
call   1050 <crossVectorsNorm@plt>
mov    %r12,%rdi
call   1060 <magnitudeVector@plt>
test   %rax,%rax
jne    1208 <projectPoint+0xc8>
movss  (%rbx),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x4(%rbx),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x8(%rbx),%xmm0
movss  %xmm0,0xc(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <normalizeVector@plt>
lea    0x4(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <dotVectors@plt>
movss  %xmm0,(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <dotVectors@plt>
movss  (%rsp),%xmm1
divss  %xmm0,%xmm1
movss  (%r15),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,(%r14)
movss  0x4(%r15),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x4(%r14)
mulss  0x8(%r15),%xmm1
movss  %xmm1,0x8(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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