// File: /workspace/github_c_makefile_star2_O1/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, %r14d
movq %rcx, %r15
movq %rdx, 0x20(%rsp)
movq %rsi, %r12
movq %rdi, 0x28(%rsp)
movl 0x130(%rsp), %ecx
leaq 0x409d0(%rip), %rax     # 0x690fc
cmpl $0x0, (%rax)
movl %r9d, 0x8(%rsp)
je 0x288b3
movq %r8, %r13
leaq 0x30b69(%rip), %rsi     # 0x592ad
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq 0x168(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x2eade(%rip), %rsi     # 0x57240
movq %rbx, %rdi
callq 0x2210
movq %rax, %rbp
leaq 0x29567(%rip), %rdi     # 0x51cdb
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
movq 0x20(%rsp), %rdi
movl %r14d, %esi
callq 0x10ffa
cvtss2sd %xmm0, %xmm0
leaq 0x30b25(%rip), %rsi     # 0x592bb
movq %rbp, %rdi
movb $0x1, %al
callq 0x2190
leaq 0x30b46(%rip), %rdi     # 0x592ed
movl $0x33, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2280
testq %r13, %r13
je 0x287d7
leaq 0x30b5c(%rip), %rdi     # 0x59321
movl $0xc, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x2280
movl $0xa, %edi
movq %rbp, %rsi
callq 0x2140
testl %r14d, %r14d
jle 0x2889f
movl 0x8(%rsp), %r14d
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
xorl %ebx, %ebx
leaq 0x408f0(%rip), %rax     # 0x690f4
movss (%rax), %xmm0
movq 0x28(%rsp), %rax
ucomiss (%rax,%rbx,4), %xmm0
jbe 0x28820
movl $0x23, %edi
movq %rbp, %rsi
callq 0x2140
movq 0x20(%rsp), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rbx,4), %xmm0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movq 0x28(%rsp), %rax
xorps %xmm2, %xmm2
cvtss2sd (%rax,%rbx,4), %xmm2
xorps %xmm3, %xmm3
cvtss2sd (%r15,%rbx,4), %xmm3
movq %rbp, %rdi
leaq 0x30ad7(%rip), %rsi     # 0x5932e
movl %ebx, %edx
movsd %xmm1, 0x10(%rsp)
movb $0x4, %al
callq 0x2190
testq %r13, %r13
je 0x28886
xorps %xmm0, %xmm0
cvtss2sd (%r13,%rbx,4), %xmm0
movq %rbp, %rdi
leaq 0x34f60(%rip), %rsi     # 0x5d7df
movb $0x1, %al
callq 0x2190
movl $0xa, %edi
movq %rbp, %rsi
callq 0x2140
incq %rbx
cmpq %rbx, %r14
jne 0x287fd
movq %rbp, %rdi
callq 0x20c0
movl 0x130(%rsp), %ecx
movl 0x8(%rsp), %r14d
testl %ecx, %ecx
je 0x28b48
movq 0x170(%rsp), %r15
cmpl %r14d, %ecx
movl %r14d, %ebp
cmovll %ecx, %ebp
leaq 0x34591(%rip), %rsi     # 0x5ce64
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq 0x168(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x2e94f(%rip), %rsi     # 0x57240
movq %rbx, %rdi
callq 0x2210
movq %rax, %r13
leaq 0x30a44(%rip), %rdi     # 0x59347
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x30a54(%rip), %rsi     # 0x59368
movq %r13, %rdi
movl %r14d, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x2190
leaq 0x30a5a(%rip), %rdi     # 0x59385
movl $0x1e, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2280
movl %ebp, %r14d
movl %ebp, 0x1c(%rsp)
testl %ebp, %ebp
movq 0x20(%rsp), %rbp
jle 0x28976
xorl %r15d, %r15d
leaq 0x2ef6d(%rip), %rbx     # 0x578c4
xorps %xmm0, %xmm0
cvtss2sd (%rbp,%r15,4), %xmm0
movq %r13, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x2190
incq %r15
cmpq %r15, %r14
jne 0x28957
movl $0xa, %edi
movq %r13, %rsi
callq 0x2140
leaq 0x30a1a(%rip), %rdi     # 0x593a4
movl $0x1f, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2280
cmpl $0x0, 0x1c(%rsp)
movq 0x28(%rsp), %rbp
jle 0x289d1
xorl %r15d, %r15d
leaq 0x2ef12(%rip), %rbx     # 0x578c4
xorps %xmm0, %xmm0
cvtss2sd (%rbp,%r15,4), %xmm0
movq %r13, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x2190
incq %r15
cmpq %r15, %r14
jne 0x289b2
movl $0xa, %edi
movq %r13, %rsi
callq 0x2140
leaq 0x309df(%rip), %rsi     # 0x593c4
movl $0x3, %edx
movq 0x170(%rsp), %rdi
callq 0x2070
movl %eax, 0x10(%rsp)
movl 0x8(%rsp), %eax
testl %eax, %eax
jle 0x28abc
movl %eax, %eax
movq %rax, 0x8(%rsp)
leaq 0x309b7(%rip), %r15     # 0x593cc
xorl %ebx, %ebx
movq %r13, %rdi
leaq 0x309a7(%rip), %rsi     # 0x593c8
movl %ebx, %edx
xorl %eax, %eax
callq 0x2190
cmpl $0x0, 0x130(%rsp)
jle 0x28a57
xorl %ebp, %ebp
movq (%r12,%rbp,8), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rbx,4), %xmm0
movq %r13, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x2190
incq %rbp
cmpq %rbp, %r14
jne 0x28a36
cmpl $0x0, 0x10(%rsp)
jne 0x28aa1
imulq $0x158, %rbx, %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 0x30938(%rip), %rsi     # 0x593d2
xorl %eax, %eax
callq 0x2190
movl $0xa, %edi
movq %r13, %rsi
callq 0x2140
incq %rbx
cmpq 0x8(%rsp), %rbx
jne 0x28a17
cmpl $0x0, 0x10(%rsp)
setne %bl
movq %r13, %rdi
callq 0x20c0
cmpl $0x0, 0x1c(%rsp)
setle %al
orb %bl, %al
jne 0x28b48
movq 0x180(%rsp), %r15
movq 0x178(%rsp), %r13
movq 0x138(%rsp), %r12
xorl %ebp, %ebp
leaq 0x405fb(%rip), %rbx     # 0x690f4
movq 0x28(%rsp), %rax
movss (%rax,%rbp,4), %xmm0
movss (%rbx), %xmm1
ucomiss %xmm0, %xmm1
ja 0x28b40
movq (%r13,%rbp,8), %rdi
movq 0x20(%rsp), %rax
movss (%rax,%rbp,4), %xmm1
movl %ebp, (%rsp)
movq %r12, %rsi
movl 0x188(%rsp), %edx
movq %r15, %rcx
movq 0x150(%rsp), %r8
movq 0x168(%rsp), %r9
callq 0x29332
incq %rbp
cmpq %rbp, %r14
jne 0x28af9
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq