// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/nma.c
// Function: Print_modes_old
void Print_modes_old(float *eigen_value, float **eigen_vector, float *eigen_B,
		     float *Cart_collectivity, float *Tors_collectivity,
		     int N, int N_MODES, atom *atoms, int N_atoms, int nca,
		     struct residue *seq, struct axe *axes, int N_axes,
		     char *file_name, char *deg_of_freedom,
		     float **Cart_mode, int *atom_ref, int N_ref)
{
  // Notice that eigenvectors are defined between 0 and N-1 !!

  FILE *file_out; int ia, i, n_max=N_MODES, tnm=0;
  char outfile[200];

  if(PRINT_LAMBDA){
    double sum=0; float kappa;
    sprintf(outfile, "%s_lambda.dat", file_name);
    file_out=fopen(outfile, "w");
    printf("Writing %s\n", outfile);
    kappa=Collectivity_norm1(eigen_B, N);
    fprintf(file_out, "# Reciprocal collectivity of fluctuations=  %.1f\n",
	    kappa);
    fprintf(file_out, "# mode Contr_to_fluct Cumulative lambda Coll.(cart)");
    if(Tors_collectivity)fprintf(file_out, " Coll.(tors)");
    fprintf(file_out, "\n");

    for(i=0; i<N; i++){
      if(eigen_value[i] < E_MIN)fprintf(file_out, "#");
      sum+=eigen_B[i];
      fprintf(file_out, "%3d\t%.4f\t%.3f\t%7.4g\t%.3f",
	      i, eigen_B[i], sum, eigen_value[i], Cart_collectivity[i]);
      if(Tors_collectivity)fprintf(file_out, "\t%.3f", Tors_collectivity[i]);
      fprintf(file_out, "\n");
    }
    fclose(file_out);
  }


  if(n_max==0)return;
  if(n_max > N)n_max=N;

  sprintf(outfile, "%s.dat", file_name);
  file_out=fopen(outfile, "w");
  printf("Writing normal modes to file %s\n", outfile);
  fprintf(file_out, "# %d degrees of freedom: %s\n", N, deg_of_freedom);
  fprintf(file_out, "# Contribution to fluctuation:");
  for(ia=0; ia<n_max; ia++)fprintf(file_out, "\t%.3g", eigen_B[ia]);
  fprintf(file_out, "\n");
  fprintf(file_out, "# e_values:                    ");
  for(ia=0; ia<n_max; ia++)fprintf(file_out, "\t%.3g", eigen_value[ia]);
  fprintf(file_out, "\n");

  if(strncmp(deg_of_freedom, "TNM", 3)==0)tnm=1;
  for(i=0; i<N; i++){
    fprintf(file_out, "%4d", i);
    for(ia=0; ia<n_max; ia++)fprintf(file_out, "\t%.6g", eigen_vector[ia][i]);
    if(tnm){
      fprintf(file_out, "\t%c%s", axes[i].type,
	      seq[(axes[i].bond)->atom->res].pdbres);
    }
    fprintf(file_out, "\n");
  }

  /* // Check global rotation eigenvector (only ANM)
  if(N==nca*3){
    float *ev, *r, sum; int ica;
    for(n=1; n<=n_max; n++){
      // scalar product sum_i vi*ri
      sum=0; ica=0; ev=eigen_vector[N-n];
      for(i=0; i<N_atoms; i++){
	if(strncmp(atoms[i].name, "CA", 2)!=0)continue; r=atoms[i].r;
	sum += ev[ica]*r[0]+ev[ica+1]*r[1]+ev[ica+2]*r[2];
	ica+=3;
      }
      fprintf(file_out, "# ev %d, lambda= %.4f sum(ri*vi)= %6.3f\n",
	      n, eigen_value[N-n], sum);
    }
    }*/

  fclose(file_out);

  if(tnm){
    for(ia=0; ia<n_max; ia++){
      if(eigen_value[ia] < E_MIN)continue;
      Print_PDB_3(Cart_mode[ia], eigen_value[ia], eigen_B[ia], atoms,
		  N_ref, atom_ref, seq, file_name, ia);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movl %r9d, %ebp
movq %rcx, %r15
movq %rsi, %r12
movq %rdi, 0x28(%rsp)
movl 0x130(%rsp), %ecx
leaq 0x40e81(%rip), %rax     # 0x690fc
cmpl $0x0, (%rax)
movq %rdx, 0x20(%rsp)
movl %r9d, 0x8(%rsp)
je 0x2840e
movq %r8, %r13
leaq 0x30fc2(%rip), %rsi     # 0x5925a
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %rdx, %r14
movq 0x168(%rsp), %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x2ef47(%rip), %rsi     # 0x57200
movq %rbx, %rdi
callq 0x2220
movq %rax, %rbp
leaq 0x29a84(%rip), %rdi     # 0x51d4f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
movq %r14, %rdi
movl 0x8(%rsp), %ebx
movl %ebx, %esi
callq 0x10b2f
cvtss2sd %xmm0, %xmm0
leaq 0x30f7a(%rip), %rsi     # 0x59268
movq %rbp, %rdi
movb $0x1, %al
callq 0x21a0
leaq 0x30f9b(%rip), %rdi     # 0x5929a
movl $0x33, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2290
testq %r13, %r13
je 0x2832f
leaq 0x30fb1(%rip), %rdi     # 0x592ce
movl $0xc, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2290
movl $0xa, %edi
movq %rbp, %rsi
callq 0x2140
testl %ebx, %ebx
jle 0x283fb
movl 0x8(%rsp), %r14d
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
xorl %ebx, %ebx
movq 0x28(%rsp), %rax
movss (%rax,%rbx,4), %xmm2
leaq 0x40d8f(%rip), %rax     # 0x690f4
movss (%rax), %xmm0
ucomiss %xmm2, %xmm0
jbe 0x28385
movl $0x23, %edi
movq %rbp, %rsi
callq 0x2140
movq 0x28(%rsp), %rax
movss (%rax,%rbx,4), %xmm2
movq 0x20(%rsp), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rbx,4), %xmm0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
cvtss2sd %xmm2, %xmm2
xorps %xmm3, %xmm3
cvtss2sd (%r15,%rbx,4), %xmm3
movq %rbp, %rdi
leaq 0x30f28(%rip), %rsi     # 0x592db
movl %ebx, %edx
movsd %xmm1, 0x10(%rsp)
movb $0x4, %al
callq 0x21a0
testq %r13, %r13
je 0x283e2
xorps %xmm0, %xmm0
cvtss2sd (%r13,%rbx,4), %xmm0
movq %rbp, %rdi
leaq 0x353d4(%rip), %rsi     # 0x5d7af
movb $0x1, %al
callq 0x21a0
movl $0xa, %edi
movq %rbp, %rsi
callq 0x2140
incq %rbx
cmpq %rbx, %r14
jne 0x28354
movq %rbp, %rdi
callq 0x20c0
movl 0x130(%rsp), %ecx
movl 0x8(%rsp), %ebp
testl %ecx, %ecx
je 0x286f5
movq 0x170(%rsp), %r15
cmpl %ebp, %ecx
movl %ebp, %r14d
cmovll %ecx, %r14d
leaq 0x349f6(%rip), %rsi     # 0x5ce24
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq 0x168(%rsp), %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x2edb4(%rip), %rsi     # 0x57200
movq %rbx, %rdi
callq 0x2220
movq %rax, %r13
leaq 0x30e96(%rip), %rdi     # 0x592f4
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x30ea6(%rip), %rsi     # 0x59315
movq %r13, %rdi
movl %ebp, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x21a0
leaq 0x30ead(%rip), %rdi     # 0x59332
movl $0x1e, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2290
movl %r14d, %ebp
movl %r14d, 0x1c(%rsp)
testl %r14d, %r14d
jle 0x28531
xorl %r14d, %r14d
leaq 0x2f3d2(%rip), %rbx     # 0x57884
movq 0x20(%rsp), %r15
xorps %xmm0, %xmm0
cvtss2sd (%r15,%r14,4), %xmm0
movq %r13, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x21a0
incq %r14
cmpq %r14, %rbp
jne 0x284b7
movl $0xa, %edi
movq %r13, %rsi
callq 0x2140
leaq 0x30e68(%rip), %rdi     # 0x59351
movl $0x1f, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2290
cmpl $0x0, 0x1c(%rsp)
movq 0x28(%rsp), %r15
jle 0x28557
xorl %r14d, %r14d
leaq 0x2f373(%rip), %rbx     # 0x57884
xorps %xmm0, %xmm0
cvtss2sd (%r15,%r14,4), %xmm0
movq %r13, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x21a0
incq %r14
cmpq %r14, %rbp
jne 0x28511
jmp 0x28557
movl $0xa, %edi
movq %r13, %rsi
callq 0x2140
leaq 0x30e0c(%rip), %rdi     # 0x59351
movl $0x1f, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2290
movl $0xa, %edi
movq %r13, %rsi
callq 0x2140
movq 0x170(%rsp), %rcx
cmpb $0x54, (%rcx)
jne 0x28588
cmpb $0x4e, 0x1(%rcx)
movl 0x8(%rsp), %eax
jne 0x28596
cmpb $0x4d, 0x2(%rcx)
sete %cl
movl %ecx, 0x10(%rsp)
jmp 0x2859e
movl $0x0, 0x10(%rsp)
movl 0x8(%rsp), %eax
jmp 0x2859e
movl $0x0, 0x10(%rsp)
testl %eax, %eax
jle 0x2865f
movl %eax, %eax
movq %rax, 0x8(%rsp)
leaq 0x30dc1(%rip), %rbx     # 0x59375
xorl %r15d, %r15d
movq %r13, %rdi
leaq 0x30db0(%rip), %rsi     # 0x59371
movl %r15d, %edx
xorl %eax, %eax
callq 0x21a0
cmpl $0x0, 0x130(%rsp)
jle 0x285fa
xorl %r14d, %r14d
movq (%r12,%r14,8), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%r15,4), %xmm0
movq %r13, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x21a0
incq %r14
cmpq %r14, %rbp
jne 0x285d8
cmpb $0x0, 0x10(%rsp)
je 0x28644
imulq $0x158, %r15, %rax      # imm = 0x158
movq 0x158(%rsp), %rcx
movsbl (%rcx,%rax), %edx
movq 0x8(%rcx,%rax), %rax
movq (%rax), %rax
movslq 0x64(%rax), %rax
shlq $0x5, %rax
movq 0x150(%rsp), %rcx
addq %rax, %rcx
addq $0xd, %rcx
movq %r13, %rdi
leaq 0x30d3e(%rip), %rsi     # 0x5937b
xorl %eax, %eax
callq 0x21a0
movl $0xa, %edi
movq %r13, %rsi
callq 0x2140
incq %r15
cmpq 0x8(%rsp), %r15
jne 0x285b7
cmpl $0x0, 0x1c(%rsp)
setle %bl
movq %r13, %rdi
callq 0x20c0
movl 0x10(%rsp), %eax
xorb $0x1, %al
orb %bl, %al
movq 0x20(%rsp), %rax
jne 0x286f5
movq 0x180(%rsp), %r15
movq 0x178(%rsp), %r14
movq 0x138(%rsp), %r12
leaq 0x40a57(%rip), %r13     # 0x690f4
movss (%r13), %xmm1
xorl %ebx, %ebx
movq 0x28(%rsp), %rcx
movss (%rcx,%rbx,4), %xmm0
ucomiss %xmm0, %xmm1
ja 0x286ed
movq (%r14,%rbx,8), %rdi
movss (%rax,%rbx,4), %xmm1
movl %ebx, (%rsp)
movq %r12, %rsi
movl 0x188(%rsp), %edx
movq %r15, %rcx
movq 0x150(%rsp), %r8
movq 0x168(%rsp), %r9
callq 0x28fe1
movq 0x20(%rsp), %rax
movss (%r13), %xmm1
incq %rbx
cmpq %rbx, %rbp
jne 0x286a5
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq