// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movq %r8, %rbx
movq %rdi, %r14
xorps %xmm4, %xmm4
xorps %xmm3, %xmm3
xorl %eax, %eax
cmpq $0xc, %rax
je 0x421f
movss (%r14,%rax), %xmm0
movss (%rdx,%rax), %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movss (%rsi,%rax), %xmm2
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
subps %xmm2, %xmm1
movaps %xmm1, %xmm2
shufps $0x55, %xmm1, %xmm2     # xmm2 = xmm2[1,1],xmm1[1,1]
movss %xmm2, 0x34(%rsp,%rax)
movss %xmm1, 0x28(%rsp,%rax)
movss (%rcx,%rax), %xmm2
subss %xmm0, %xmm2
movss %xmm2, 0x1c(%rsp,%rax)
mulps %xmm1, %xmm1
addps %xmm1, %xmm4
mulss %xmm2, %xmm2
addss %xmm2, %xmm3
addq $0x4, %rax
jmp 0x41c9
movaps %xmm4, %xmm0
shufps $0x55, %xmm4, %xmm0     # xmm0 = xmm0[1,1],xmm4[1,1]
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
movss %xmm3, 0xc(%rsp)
jae 0x424c
movaps %xmm4, 0x40(%rsp)
callq 0x2170
xorps %xmm1, %xmm1
movaps 0x40(%rsp), %xmm4
movss 0xc(%rsp), %xmm3
ucomiss %xmm1, %xmm4
jae 0x425f
movaps %xmm4, %xmm0
callq 0x2170
movss 0xc(%rsp), %xmm3
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm3
jb 0x426d
sqrtss %xmm3, %xmm0
jmp 0x4275
movaps %xmm3, %xmm0
callq 0x2170
movss %xmm0, 0xc(%rsp)
leaq 0x34(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x4146
xorl %eax, %eax
cmpq $0x3, %rax
je 0x42ac
movss 0x10(%rsp,%rax,4), %xmm1
divss %xmm0, %xmm1
movss %xmm1, 0x10(%rsp,%rax,4)
incq %rax
jmp 0x4291
xorps %xmm1, %xmm1
xorl %eax, %eax
movss 0xc(%rsp), %xmm3
cmpq $0x3, %rax
je 0x42d2
movss 0x10(%rsp,%rax,4), %xmm2
mulss 0x1c(%rsp,%rax,4), %xmm2
addss %xmm2, %xmm1
incq %rax
jmp 0x42b7
mulss %xmm3, %xmm0
divss %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x430c
xorl %eax, %eax
movaps 0x145e5(%rip), %xmm0    # 0x188d0
cmpq $0x3, %rax
je 0x4305
movss 0x10(%rsp,%rax,4), %xmm2
xorps %xmm0, %xmm2
movss %xmm2, 0x10(%rsp,%rax,4)
incq %rax
jmp 0x42eb
andps 0x145d4(%rip), %xmm1    # 0x188e0
mulss %xmm1, %xmm3
xorl %eax, %eax
cmpq $0x3, %rax
je 0x4342
movss 0x10(%rsp,%rax,4), %xmm0
mulss %xmm3, %xmm0
movss %xmm0, 0x10(%rsp,%rax,4)
movss 0x1c(%rsp,%rax,4), %xmm1
subss %xmm0, %xmm1
addss (%r14,%rax,4), %xmm1
movss %xmm1, (%rbx,%rax,4)
incq %rax
jmp 0x4312
addq $0x58, %rsp
popq %rbx
popq %r14
retq