// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/site_dynamics.c
// Function: Eigen_directions
void Eigen_directions(float *d2, float *lambda, float **v,
		      int *site_res, int nres, char *chain_res,
		      struct Normal_Mode NM, int *atomres, int *iref)
{
  /* Compute the matrix M_kl=sum_a 1/w^2_a x^a_ik x^a_jl
     Returns the eigenvalues lambda and eigenvectors v */

  double **matrix=Allocate_mat2_d(3,3);
  int atom_ref[nres], i, j, a, k, l;
  for(i=0; i<nres; i++){
    if(atomres[site_res[i]]>=0){
      atom_ref[i]=iref[atomres[site_res[i]]];
    }else{
      atom_ref[i]=-1;
    }
  }

  for(a=0; a<NM.N_relevant; a++){
    // For each normal mode
    if((NM.select[a]==0)||(NM.sigma2[a]==0))continue;
    float *Mode=NM.Cart[a];
    float w=1./(NM.omega2[a]);

    for(i=0; i<nres; i++){
      if(atom_ref[i]<0)continue;
      float *Mode_i=Mode+3*atom_ref[i];
      for(k=0; k<3; k++){
	float wx=w*Mode_i[k];
	for(j=0; j<nres; j++){
	  if(atom_ref[j]<0)continue;
	  float *Mode_j=Mode+3*atom_ref[j];
	  for(l=0; l<=k; l++){
	    matrix[k][l]+=wx*Mode_j[l];
	  }
	}
      }
    }
  }
  float norm=nres*nres;
  for(k=0; k<3; k++){
    d2[k]=matrix[k][k]/norm;
    for(l=k+1; l<3; l++)matrix[k][l]=matrix[l][k];
  }
  d_Diagonalize(3, matrix, lambda, v, 1);
  for(k=0; k<3; k++)lambda[k]/=norm;
  Empty_matrix_d(matrix, 3);
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0xe8(%rbp), %rax
movq 0xe0(%rbp), %rax
leaq 0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movl $0x3, %esi
movl %esi, %edi
callq 0x694a0
movq %rax, -0x38(%rbp)
movl -0x24(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x40(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x98(%rbp)
movq %rcx, %rsp
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x6832e
movq 0xe0(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x6830f
movq -0x98(%rbp), %rax
movq 0xe8(%rbp), %rcx
movq 0xe0(%rbp), %rdx
movq -0x20(%rbp), %rsi
movslq -0x4c(%rbp), %rdi
movslq (%rsi,%rdi,4), %rsi
movslq (%rdx,%rsi,4), %rdx
movl (%rcx,%rdx,4), %edx
movslq -0x4c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x68321
movq -0x98(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x68323
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x682bd
movl $0x0, -0x54(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x54(%rbp), %eax
cmpl 0x10(%rcx), %eax
jge 0x68509
movq -0xa0(%rbp), %rax
movq 0xc0(%rax), %rax
movslq -0x54(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x6837e
movq -0xa0(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x54(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x68383
jp 0x68383
jmp 0x684fb
movq -0xa0(%rbp), %rax
movq 0x38(%rax), %rcx
movslq -0x54(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0x68(%rbp)
movq 0x20(%rax), %rax
movslq -0x54(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0xdc95(%rip), %xmm0     # 0x76048
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x6c(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x684f9
movq -0x98(%rbp), %rax
movslq -0x4c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x683e9
jmp 0x684eb
movq -0x98(%rbp), %rcx
movq -0x68(%rbp), %rax
movslq -0x4c(%rbp), %rdx
imull $0x3, (%rcx,%rdx,4), %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x58(%rbp)
cmpl $0x3, -0x58(%rbp)
jge 0x684e9
movss -0x6c(%rbp), %xmm0
movq -0x78(%rbp), %rax
movslq -0x58(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x7c(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x684d9
movq -0x98(%rbp), %rax
movslq -0x50(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x68458
jmp 0x684cb
movq -0x98(%rbp), %rcx
movq -0x68(%rbp), %rax
movslq -0x50(%rbp), %rdx
imull $0x3, (%rcx,%rdx,4), %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x58(%rbp), %eax
jg 0x684c9
movss -0x7c(%rbp), %xmm0
movq -0x88(%rbp), %rax
movslq -0x5c(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x38(%rbp), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x5c(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x68483
jmp 0x684cb
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x68439
jmp 0x684db
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x68411
jmp 0x684eb
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x683c7
jmp 0x684fb
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x68335
movl -0x24(%rbp), %eax
imull -0x24(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x8c(%rbp)
movl $0x0, -0x58(%rbp)
cmpl $0x3, -0x58(%rbp)
jge 0x685b7
movq -0x38(%rbp), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x58(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movss -0x8c(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movslq -0x58(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
cmpl $0x3, -0x5c(%rbp)
jge 0x685a7
movq -0x38(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x58(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x38(%rbp), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x5c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x6856c
jmp 0x685a9
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x68523
movq -0x38(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl $0x3, %edi
movl $0x1, %r8d
callq 0x6ac30
movl $0x0, -0x58(%rbp)
cmpl $0x3, -0x58(%rbp)
jge 0x68609
movss -0x8c(%rbp), %xmm1
movq -0x10(%rbp), %rax
movslq -0x58(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x685da
movq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x692a0
movq -0x40(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)