// File: /workspace/github_c_makefile_star2_O1/josch[P]stride/geometry.c
// Function: Project4_123
void Project4_123(float *Coord1, float *Coord2, float *Coord3, float *Coord4, 
		 float *Coord_Proj4_123)
{

/*
                          Atom4
   Atom3                  .
   \                     .
    \                   .    
     \                 .  .Proj4_123
      \               .. 
      Atom2-------Atom1

*/


  float Vector21[3], Vector23[3], Vector14[3], VectorNormal_123[3];
  float Length_21 = 0.0, Length_23 = 0.0, Length_14 = 0.0, NormalLength;
  float COS_Norm_14, Proj_14_Norm;
  int i;

  for( i=0; i<3; i++ ) {
    Vector21[i] = Coord1[i] - Coord2[i];
    Vector23[i] = Coord3[i] - Coord2[i];
    Vector14[i] = Coord4[i] - Coord1[i];
    Length_21 += Vector21[i]*Vector21[i];
    Length_23 += Vector23[i]*Vector23[i];
    Length_14 += Vector14[i]*Vector14[i];
  }
  
  Length_21 = sqrt(Length_21);
  Length_23 = sqrt(Length_23);
  Length_14 = sqrt(Length_14);

  NormalLength = VectorProduct(Vector21,Vector23,VectorNormal_123);

  for( i=0; i<3; i++ ) 
    VectorNormal_123[i] /= NormalLength;

  COS_Norm_14 = 0.0;

  for( i=0; i<3; i++ ) 
    COS_Norm_14 += VectorNormal_123[i]*Vector14[i];

  COS_Norm_14 /= (Length_14*NormalLength);

  if( COS_Norm_14 < 0.0 ) {
    COS_Norm_14 = fabs(COS_Norm_14);
    for( i=0; i<3; i++ ) 
      VectorNormal_123[i] = -VectorNormal_123[i];
  }

  Proj_14_Norm = Length_14*COS_Norm_14;

  for( i=0; i<3; i++ ) {
    VectorNormal_123[i] *= Proj_14_Norm;
    Coord_Proj4_123[i] = (Vector14[i] - VectorNormal_123[i]) + Coord1[i];
  }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %r8, %rbx
movq %rdi, %r14
xorps %xmm6, %xmm6
xorps %xmm0, %xmm0
xorl %eax, %eax
movss (%r14,%rax), %xmm1
movss (%rsi,%rax), %xmm2
movaps %xmm1, %xmm3
subss %xmm2, %xmm3
movss %xmm3, 0x3c(%rsp,%rax)
movss (%rcx,%rax), %xmm4
movss (%rdx,%rax), %xmm5
unpcklps %xmm4, %xmm5            # xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1]
unpcklps %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
subps %xmm2, %xmm5
movss %xmm5, 0x30(%rsp,%rax)
movaps %xmm5, %xmm1
shufps $0x55, %xmm5, %xmm1     # xmm1 = xmm1[1,1],xmm5[1,1]
movss %xmm1, 0x24(%rsp,%rax)
mulss %xmm3, %xmm3
addss %xmm3, %xmm0
mulps %xmm5, %xmm5
addps %xmm5, %xmm6
addq $0x4, %rax
cmpq $0xc, %rax
jne 0x4947
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
movaps %xmm6, 0x10(%rsp)
jae 0x49b7
callq 0x2170
xorps %xmm1, %xmm1
movaps 0x10(%rsp), %xmm6
ucomiss %xmm1, %xmm6
jae 0x49c9
movaps %xmm6, %xmm0
callq 0x2170
movaps 0x10(%rsp), %xmm6
shufps $0x55, %xmm6, %xmm6     # xmm6 = xmm6[1,1,1,1]
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm6
jb 0x49de
xorps %xmm3, %xmm3
sqrtss %xmm6, %xmm3
jmp 0x49ec
movaps %xmm6, %xmm0
callq 0x2170
xorps %xmm2, %xmm2
movaps %xmm0, %xmm3
xorl %eax, %eax
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
xorl %edx, %edx
leaq 0x1(%rdx), %rsi
cmpq $0x2, %rdx
movl %esi, %edi
cmovel %eax, %edi
leal 0x1(%rdi), %r8d
imulq %rcx, %r8
shrq $0x21, %r8
leal (%r8,%r8,2), %r8d
negl %r8d
addl %edi, %r8d
incl %r8d
movss 0x3c(%rsp,%rdi,4), %xmm0
shll $0x2, %r8d
movss 0x30(%rsp,%rdi,4), %xmm1
mulss 0x3c(%rsp,%r8), %xmm1
mulss 0x30(%rsp,%r8), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x4(%rsp,%rdx,4)
mulss %xmm0, %xmm0
addss %xmm0, %xmm2
movq %rsi, %rdx
cmpq $0x3, %rsi
jne 0x49f5
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
jb 0x4a65
xorps %xmm0, %xmm0
sqrtss %xmm2, %xmm0
jmp 0x4a79
movaps %xmm2, %xmm0
movss %xmm3, 0x10(%rsp)
callq 0x2170
movss 0x10(%rsp), %xmm3
xorl %eax, %eax
movss 0x4(%rsp,%rax,4), %xmm1
divss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp,%rax,4)
incq %rax
cmpq $0x3, %rax
jne 0x4a7b
xorps %xmm1, %xmm1
xorl %eax, %eax
movss 0x4(%rsp,%rax,4), %xmm2
mulss 0x24(%rsp,%rax,4), %xmm2
addss %xmm2, %xmm1
incq %rax
cmpq $0x3, %rax
jne 0x4a99
mulss %xmm3, %xmm0
divss %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x4aea
xorl %eax, %eax
movaps 0x14df5(%rip), %xmm0    # 0x198c0
movss 0x4(%rsp,%rax,4), %xmm2
xorps %xmm0, %xmm2
movss %xmm2, 0x4(%rsp,%rax,4)
incq %rax
cmpq $0x3, %rax
jne 0x4acb
andps 0x14de6(%rip), %xmm1    # 0x198d0
mulss %xmm1, %xmm3
xorl %eax, %eax
movss 0x4(%rsp,%rax,4), %xmm0
mulss %xmm3, %xmm0
movss %xmm0, 0x4(%rsp,%rax,4)
movss 0x24(%rsp,%rax,4), %xmm1
subss %xmm0, %xmm1
addss (%r14,%rax,4), %xmm1
movss %xmm1, (%rbx,%rax,4)
incq %rax
cmpq $0x3, %rax
jne 0x4af0
addq $0x48, %rsp
popq %rbx
popq %r14
retq