#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*/ UnitVectorVV(float *, float *, float *, float, float, float,
                                float, float, float);
void Project(float *vX, float *vY, float *vZ, float rX, float rY, float rZ,
             float sX, float sY, float sZ) {
  float nrsX, nrsY, nrsZ;
  float vrsX, vrsY, vrsZ;
  float prsX, prsY, prsZ;
  float prod;
  UnitVectorVV(&nrsX, &nrsY, &nrsZ, rX, rY, rZ, sX, sY, sZ);
  UnitVectorVV(&vrsX, &vrsY, &vrsZ, *vX, *vY, *vZ, nrsX, nrsY, nrsZ);
  UnitVectorVV(&prsX, &prsY, &prsZ, vrsX, vrsY, vrsZ, nrsX, nrsY, nrsZ);
  prod = *vX * prsX + *vY * prsY + *vZ * prsZ;
  if (prod < 0.0f) {
    *vX = -prsX;
    *vY = -prsY;
    *vZ = -prsZ;
  } else {
    *vX = prsX;
    *vY = prsY;
    *vZ = prsZ;
  }
}


x86 assembly (clang, -O0):
<Project>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
movss  %xmm1,-0x20(%rbp)
movss  %xmm2,-0x24(%rbp)
movss  %xmm3,-0x28(%rbp)
movss  %xmm4,-0x2c(%rbp)
movss  %xmm5,-0x30(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  -0x24(%rbp),%xmm2
movss  -0x28(%rbp),%xmm3
movss  -0x2c(%rbp),%xmm4
movss  -0x30(%rbp),%xmm5
lea    -0x34(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   1030 <UnitVectorVV@plt>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm2
movss  -0x34(%rbp),%xmm3
movss  -0x38(%rbp),%xmm4
movss  -0x3c(%rbp),%xmm5
lea    -0x40(%rbp),%rdi
lea    -0x44(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1030 <UnitVectorVV@plt>
movss  -0x40(%rbp),%xmm0
movss  -0x44(%rbp),%xmm1
movss  -0x48(%rbp),%xmm2
movss  -0x34(%rbp),%xmm3
movss  -0x38(%rbp),%xmm4
movss  -0x3c(%rbp),%xmm5
lea    -0x4c(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x54(%rbp),%rdx
call   1030 <UnitVectorVV@plt>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
movss  -0x4c(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x50(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
movss  -0x54(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x58(%rbp),%xmm0
jbe    1274 <Project+0x164>
movss  -0x4c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x50(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x54(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    129b <Project+0x18b>
movss  -0x4c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x54(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Project>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1030 <UnitVectorVV@plt>
movss  (%rbx),%xmm0
movss  (%r15),%xmm1
movss  (%r14),%xmm2
movss  0x14(%rsp),%xmm3
movss  0x10(%rsp),%xmm4
movss  0xc(%rsp),%xmm5
lea    0x2c(%rsp),%rdi
lea    0x28(%rsp),%rsi
lea    0x24(%rsp),%rdx
call   1030 <UnitVectorVV@plt>
movss  0x2c(%rsp),%xmm0
movss  0x28(%rsp),%xmm1
movss  0x24(%rsp),%xmm2
movss  0x14(%rsp),%xmm3
movss  0x10(%rsp),%xmm4
movss  0xc(%rsp),%xmm5
lea    0x20(%rsp),%rdi
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
call   1030 <UnitVectorVV@plt>
movss  0x20(%rsp),%xmm2
movss  0x1c(%rsp),%xmm1
movss  (%r15),%xmm0
mulss  %xmm1,%xmm0
movss  (%rbx),%xmm3
mulss  %xmm2,%xmm3
addss  %xmm0,%xmm3
movss  0x18(%rsp),%xmm0
movss  (%r14),%xmm4
mulss  %xmm0,%xmm4
addss  %xmm3,%xmm4
xorps  %xmm3,%xmm3
ucomiss %xmm4,%xmm3
jbe    11f9 <Project+0xe9>
movaps 0xe1b(%rip),%xmm3
xorps  %xmm3,%xmm2
movss  %xmm2,(%rbx)
xorps  %xmm3,%xmm1
movss  %xmm1,(%r15)
xorps  %xmm3,%xmm0
jmp    1202 <Project+0xf2>
movss  %xmm2,(%rbx)
movss  %xmm1,(%r15)
movss  %xmm0,(%r14)
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @Project(float* %0, float* %1, float* %2, float %3, float %4, float %5, float %6, float %7, float %8) {
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca float
%23 = alloca float
%24 = alloca float
%25 = alloca float
%26 = alloca float
%27 = alloca float
%28 = alloca float
store float* %0, float** %10
store float* %1, float** %11
store float* %2, float** %12
store float %3, float* %13
store float %4, float* %14
store float %5, float* %15
store float %6, float* %16
store float %7, float* %17
store float %8, float* %18
%29 = load float, float* %13
%30 = load float, float* %14
%31 = load float, float* %15
%32 = load float, float* %16
%33 = load float, float* %17
%34 = load float, float* %18
%35 = call i32 @UnitVectorVV(float* %19, float* %20, float* %21, float %29, float %30, float %31, float %32, float %33, float %34)
%36 = load float*, float** %10
%37 = load float, float* %36
%38 = load float*, float** %11
%39 = load float, float* %38
%40 = load float*, float** %12
%41 = load float, float* %40
%42 = load float, float* %19
%43 = load float, float* %20
%44 = load float, float* %21
%45 = call i32 @UnitVectorVV(float* %22, float* %23, float* %24, float %37, float %39, float %41, float %42, float %43, float %44)
%46 = load float, float* %22
%47 = load float, float* %23
%48 = load float, float* %24
%49 = load float, float* %19
%50 = load float, float* %20
%51 = load float, float* %21
%52 = call i32 @UnitVectorVV(float* %25, float* %26, float* %27, float %46, float %47, float %48, float %49, float %50, float %51)
%53 = load float*, float** %10
%54 = load float, float* %53
%55 = load float, float* %25
%56 = load float*, float** %11
%57 = load float, float* %56
%58 = load float, float* %26
%59 = fmul float %57, %58
%60 = call float @llvm.fmuladd.f32(float %54, float %55, float %59)
%61 = load float*, float** %12
%62 = load float, float* %61
%63 = load float, float* %27
%64 = call float @llvm.fmuladd.f32(float %62, float %63, float %60)
store float %64, float* %28
%65 = load float, float* %28
%66 = fcmp olt float %65, 0.000000e+00
br i1 %66, label %67, label %77
67: ; preds = %9
%68 = load float, float* %25
%69 = fneg float %68
%70 = load float*, float** %10
store float %69, float* %70
%71 = load float, float* %26
%72 = fneg float %71
%73 = load float*, float** %11
store float %72, float* %73
%74 = load float, float* %27
%75 = fneg float %74
%76 = load float*, float** %12
store float %75, float* %76
br label %84
77: ; preds = %9
%78 = load float, float* %25
%79 = load float*, float** %10
store float %78, float* %79
%80 = load float, float* %26
%81 = load float*, float** %11
store float %80, float* %81
%82 = load float, float* %27
%83 = load float*, float** %12
store float %82, float* %83
br label %84
84: ; preds = %77, %67
ret void
}

LLVM IR (-O2):
define void @Project(float* nocapture %0, float* nocapture %1, float* nocapture %2, float %3, float %4, float %5, float %6, float %7, float %8) {
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = bitcast float* %10 to i8*
%20 = bitcast float* %11 to i8*
%21 = bitcast float* %12 to i8*
%22 = bitcast float* %13 to i8*
%23 = bitcast float* %14 to i8*
%24 = bitcast float* %15 to i8*
%25 = bitcast float* %16 to i8*
%26 = bitcast float* %17 to i8*
%27 = bitcast float* %18 to i8*
%28 = call i32 @UnitVectorVV(float* %10, float* %11, float* %12, float %3, float %4, float %5, float %6, float %7, float %8)
%29 = load float, float* %0
%30 = load float, float* %1
%31 = load float, float* %2
%32 = load float, float* %10
%33 = load float, float* %11
%34 = load float, float* %12
%35 = call i32 @UnitVectorVV(float* %13, float* %14, float* %15, float %29, float %30, float %31, float %32, float %33, float %34)
%36 = load float, float* %13
%37 = load float, float* %14
%38 = load float, float* %15
%39 = load float, float* %10
%40 = load float, float* %11
%41 = load float, float* %12
%42 = call i32 @UnitVectorVV(float* %16, float* %17, float* %18, float %36, float %37, float %38, float %39, float %40, float %41)
%43 = load float, float* %0
%44 = load float, float* %16
%45 = load float, float* %1
%46 = load float, float* %17
%47 = fmul float %45, %46
%48 = call float @llvm.fmuladd.f32(float %43, float %44, float %47)
%49 = load float, float* %2
%50 = load float, float* %18
%51 = call float @llvm.fmuladd.f32(float %49, float %50, float %48)
%52 = fcmp olt float %51, 0.000000e+00
br i1 %52, label %53, label %57
53: ; preds = %9
%54 = fneg float %44
store float %54, float* %0
%55 = fneg float %46
store float %55, float* %1
%56 = fneg float %50
br label %58
57: ; preds = %9
store float %44, float* %0
store float %46, float* %1
br label %58
58: ; preds = %57, %53
%59 = phi float [ %50, %57 ], [ %56, %53 ]
store float %59, float* %2
ret void
}