// File: /workspace/github_c_makefile_star2_O2/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
movq %r9, 0x10(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %r13
movq %rdi, 0x20(%rsp)
movl 0x130(%rsp), %ebp
leaq 0x3e72b(%rip), %rax     # 0x640fc
cmpl $0x0, (%rax)
je 0x25b48
movq %r8, %r15
leaq 0x2d7d6(%rip), %rsi     # 0x531ba
xorl %r12d, %r12d
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq 0x168(%rsp), %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x2b74b(%rip), %rsi     # 0x51150
movq %r14, %rdi
callq 0x2210
movq %rax, %rbx
leaq 0x26290(%rip), %rdi     # 0x4bca7
movq %r14, %rsi
xorl %eax, %eax
callq 0x20f0
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x10033
cvtss2sd %xmm0, %xmm0
leaq 0x2d78d(%rip), %rsi     # 0x531c8
movq %rbx, %rdi
movb $0x1, %al
callq 0x2190
leaq 0x2d7ae(%rip), %rdi     # 0x531fa
pushq $0x33
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x2280
testq %r15, %r15
je 0x25a74
leaq 0x2d7c8(%rip), %rdi     # 0x5322e
pushq $0xc
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x2280
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x2140
movq 0x10(%rsp), %rax
testl %eax, %eax
movl $0x0, %r14d
cmovgl %eax, %r14d
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
cmpq %r12, %r14
je 0x25b40
movq 0x20(%rsp), %rax
movss (%rax,%r12,4), %xmm2
leaq 0x3e640(%rip), %rax     # 0x640f4
movss (%rax), %xmm0
ucomiss %xmm2, %xmm0
jbe 0x25ad3
pushq $0x23
popq %rdi
movq %rbx, %rsi
callq 0x2140
movq 0x20(%rsp), %rax
movss (%rax,%r12,4), %xmm2
movq 0x18(%rsp), %rax
cvtss2sd (%rax,%r12,4), %xmm0
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
cvtss2sd %xmm2, %xmm2
movq 0x28(%rsp), %rax
cvtss2sd (%rax,%r12,4), %xmm3
movq %rbx, %rdi
leaq 0x2d73a(%rip), %rsi     # 0x5323b
movl %r12d, %edx
movsd %xmm1, 0x8(%rsp)
movb $0x4, %al
callq 0x2190
testq %r15, %r15
je 0x25b2d
cvtss2sd (%r15,%r12,4), %xmm0
movq %rbx, %rdi
leaq 0x31bf9(%rip), %rsi     # 0x5771f
movb $0x1, %al
callq 0x2190
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x2140
incq %r12
jmp 0x25a99
movq %rbx, %rdi
callq 0x20c0
testl %ebp, %ebp
movq 0x168(%rsp), %rdx
je 0x25dca
movq 0x10(%rsp), %r12
cmpl %r12d, %ebp
cmovgel %r12d, %ebp
leaq 0x31229(%rip), %rsi     # 0x56d94
xorl %r14d, %r14d
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2260
leaq 0x2b5cc(%rip), %rsi     # 0x51150
movq %rbx, %rdi
callq 0x2210
movq %rax, %r15
leaq 0x2d6be(%rip), %rdi     # 0x53254
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x2d6ce(%rip), %rsi     # 0x53275
movq %r15, %rdi
movl %r12d, %edx
movq 0x170(%rsp), %r12
movq %r12, %rcx
xorl %eax, %eax
callq 0x2190
leaq 0x2d6cc(%rip), %rdi     # 0x53292
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x2280
testl %ebp, %ebp
cmovlel %r14d, %ebp
leaq 0x2bc03(%rip), %rbx     # 0x517e4
cmpq %r14, %rbp
je 0x25c03
movq 0x18(%rsp), %rax
cvtss2sd (%rax,%r14,4), %xmm0
movq %r15, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x2190
incq %r14
jmp 0x25be1
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x2140
leaq 0x2d69c(%rip), %rdi     # 0x532b1
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x2280
xorl %r14d, %r14d
leaq 0x2bbb7(%rip), %rbx     # 0x517e4
cmpq %r14, %rbp
je 0x25c4f
movq 0x20(%rsp), %rax
cvtss2sd (%rax,%r14,4), %xmm0
movq %r15, %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x2190
incq %r14
jmp 0x25c2d
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x2140
xorl %eax, %eax
cmpb $0x54, (%r12)
movl $0x0, %ecx
movq %rcx, 0x8(%rsp)
jne 0x25c8e
cmpb $0x4e, 0x1(%r12)
jne 0x25c85
cmpb $0x4d, 0x2(%r12)
sete %cl
movq %rcx, 0x8(%rsp)
jmp 0x25c8e
movq $0x0, 0x8(%rsp)
movq 0x10(%rsp), %rcx
testl %ecx, %ecx
cmovlel %eax, %ecx
movq %rcx, 0x10(%rsp)
leaq 0x2d631(%rip), %r12     # 0x532d5
xorl %ebx, %ebx
cmpq 0x10(%rsp), %rbx
je 0x25d45
movq %r15, %rdi
leaq 0x2d616(%rip), %rsi     # 0x532d1
movl %ebx, %edx
xorl %eax, %eax
callq 0x2190
xorl %r14d, %r14d
cmpq %r14, %rbp
je 0x25ce8
movq (%r13,%r14,8), %rax
cvtss2sd (%rax,%rbx,4), %xmm0
movq %r15, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x2190
incq %r14
jmp 0x25cc7
cmpb $0x0, 0x8(%rsp)
je 0x25d32
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 %r15, %rdi
leaq 0x2d5b0(%rip), %rsi     # 0x532db
xorl %eax, %eax
callq 0x2190
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x2140
incq %rbx
jmp 0x25ca6
movq %r15, %rdi
callq 0x20c0
cmpb $0x0, 0x8(%rsp)
movq 0x168(%rsp), %r15
movl 0x188(%rsp), %r12d
movq 0x180(%rsp), %r13
je 0x25dca
xorl %ebx, %ebx
leaq 0x3e37f(%rip), %r14     # 0x640f4
cmpq %rbx, %rbp
je 0x25dca
movq 0x20(%rsp), %rax
movss (%rax,%rbx,4), %xmm0
movss (%r14), %xmm1
ucomiss %xmm0, %xmm1
ja 0x25dc5
movq 0x178(%rsp), %rax
movq (%rax,%rbx,8), %rdi
movq 0x18(%rsp), %rax
movss (%rax,%rbx,4), %xmm1
movl %ebx, (%rsp)
movq 0x138(%rsp), %rsi
movl %r12d, %edx
movq %r13, %rcx
movq 0x150(%rsp), %r8
movq %r15, %r9
callq 0x26511
incq %rbx
jmp 0x25d75
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq