// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/nma.c
// Function: Output_modes
float Output_modes(int N,           //degrees of freedom
		   char *model,     // INM, ANM or TNM
		   char *REF_ATM,   // Reference atoms
		   atom *atoms, int N_atoms,
		   struct residue *seq, int N_res,
		   struct axe *axes, int N_axes,
		   float *B_CA, float *B_CA_exp,
		   int *weight, float *dist_CA,
		   float ***aniso_pred, float ***aniso_exp,
		   int N_MODES, float cutoff,
		   char *inter, char *prot_name,
		   FILE *file_B, FILE *file_sum,
		   float **eigen_vector, float *eigen_value, float *eigen_B,
		   float *Cart_collectivity, float *Tors_collectivity,
		   float **Cart_mode, int *atom_ref, int N_ref)
{
  char outfile[200], string[100]; int n_aniso=0;
  float r, slope, offset, dot_aniso=0, ov_aniso=0, delta_aniso=2.;
  float slope_calc, slope_dist, offset2, r2, chi;
  int neg=0, i;
  int nca=N_res;

  // B factors comparison
  // Model 1: B_exp = slope*B_calc + offset
  // r=Corr_coeff(B_CA, B_CA_exp, weight, nca, &slope, &offset, &newnorm);
  r=Corr_coeff(B_CA, B_CA_exp, nca, &slope, &offset);
  printf("cc(B, %s %s)=  %6.3f   ref: %s\n", model, inter, r, REF_ATM);

  fprintf(file_sum, "%3s\t%3s\t%4.1f", model, inter, cutoff);
  fprintf(file_sum, "\t%6.3f\t%8.5f\t%5.3f", r, slope, offset);
  if(FIT_ROT){
    // Model 2: B_exp = slope*B_calc + offset
    Bivariate_fit(nca, B_CA_exp, B_CA, dist_CA, weight,
		  &slope_calc, &slope_dist, &offset2, &r2, &chi);
    fprintf(file_sum, "\t%6.3f\t%8.5f\t%8.5f\t%5.3f ",
	    r2, slope_calc, slope_dist, offset2);
  }
  //fprintf(file_sum, "%8s  %3d  %4.1f", prot_name, N, cutoff);
  // Anisotropic B factors
  if(ANISOU){
    if(strncmp(model, "INM", 3)!=0){
      n_aniso=Compare_anisou(aniso_pred, aniso_exp, nca, model, inter,
			     file_aniso, prot_name, N, weight,
			     &dot_aniso, &ov_aniso, &delta_aniso);
    }
    fprintf(file_sum, "\t%3d\t%.3f\t%6.3f\t%.4f",
	    n_aniso, ov_aniso, dot_aniso, delta_aniso);
  }
  fprintf(file_sum, "\t%s\n", REF_ATM);
  fflush(file_sum);

  // Print isotropic B factors
  sprintf(string, "%s_%s", model, inter);
  Rescale(B_CA, nca, slope, offset);
  Print_B(B_CA, nca, file_B, string, r);

  // Normalize eigenvalues
  if(slope>0)for(i=0; i<N; i++)eigen_value[i]/=slope;
  // for(i=0; i<N; i++)eigen_value[i]*=100;
  // Print negative eigenvalues, if any
  for(i=0; i<N; i++){
    if(eigen_value[i]<-0.001){
      if(neg==0){printf("Negative eigenvalues:\n"); neg=1;}
      printf("%.4f\n", eigen_value[i]);
    }
  }

  // Print normal modes
  sprintf(outfile, "%s_%s_%s", prot_name, inter, model);
  Print_modes_old(eigen_value, eigen_vector, eigen_B,
		  Cart_collectivity, Tors_collectivity, N, N_MODES,
		  atoms, N_atoms, nca, seq, axes, N_axes, outfile, model,
		  Cart_mode, atom_ref, N_ref);

  return(r);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movl 0xb8(%rbp), %eax
movq 0xb0(%rbp), %rax
movq 0xa8(%rbp), %rax
movq 0xa0(%rbp), %rax
movq 0x98(%rbp), %rax
movq 0x90(%rbp), %rax
movq 0x88(%rbp), %rax
movq 0x80(%rbp), %rax
movq 0x78(%rbp), %rax
movq 0x70(%rbp), %rax
movq 0x68(%rbp), %rax
movq 0x60(%rbp), %rax
movl 0x58(%rbp), %eax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movl %edi, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movl %r8d, -0x4c(%rbp)
movq %r9, -0x58(%rbp)
movss %xmm0, -0x5c(%rbp)
movl $0x0, -0x1a4(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1b4(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1b8(%rbp)
movss 0x3cee0(%rip), %xmm0    # 0x76094
movss %xmm0, -0x1bc(%rbp)
movl $0x0, -0x1d4(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0x1dc(%rbp)
movq 0x28(%rbp), %rdi
movq 0x30(%rbp), %rsi
movl -0x1dc(%rbp), %edx
leaq -0x1ac(%rbp), %rcx
leaq -0x1b0(%rbp), %r8
callq 0x15750
movss %xmm0, -0x1a8(%rbp)
movq -0x38(%rbp), %rsi
movq 0x60(%rbp), %rdx
movss -0x1a8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x40(%rbp), %rcx
leaq 0x44eca(%rip), %rdi     # 0x7e0e1
movb $0x1, %al
callq 0x10d0
movq 0x78(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq 0x60(%rbp), %rcx
movss -0x5c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x44ec7(%rip), %rsi     # 0x7e101
movb $0x1, %al
callq 0x1150
movq 0x78(%rbp), %rdi
movss -0x1a8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x1ac(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movss -0x1b0(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x44e9f(%rip), %rsi     # 0x7e10f
movb $0x3, %al
callq 0x1150
leaq 0x52e42(%rip), %rax     # 0x8c0c0
cmpl $0x0, (%rax)
je 0x39343
movq -0x38(%rbp), %rdi
leaq 0x44e90(%rip), %rsi     # 0x7e122
movl $0x3, %edx
callq 0x1050
cmpl $0x0, %eax
je 0x39307
movq 0x48(%rbp), %rdi
movq 0x50(%rbp), %rsi
movl -0x1dc(%rbp), %edx
movq -0x38(%rbp), %rcx
movq 0x60(%rbp), %r8
movq 0x68(%rbp), %r15
movl -0x2c(%rbp), %r14d
movq 0x38(%rbp), %rbx
leaq 0x63016(%rip), %r9      # 0x9c2e0
leaq -0x1b4(%rbp), %r11
leaq -0x1b8(%rbp), %r10
leaq -0x1bc(%rbp), %rax
movq %r15, (%rsp)
movl %r14d, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %rax, 0x28(%rsp)
callq 0x38890
movl %eax, -0x1a4(%rbp)
movq 0x78(%rbp), %rdi
movl -0x1a4(%rbp), %edx
movss -0x1b8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x1b4(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movss -0x1bc(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x44dea(%rip), %rsi     # 0x7e126
movb $0x3, %al
callq 0x1150
movq 0x78(%rbp), %rdi
movq -0x40(%rbp), %rdx
leaq 0x49705(%rip), %rsi     # 0x82a57
movb $0x0, %al
callq 0x1150
movq 0x78(%rbp), %rdi
callq 0x1190
leaq -0x1a0(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq 0x60(%rbp), %rcx
leaq 0x44ddd(%rip), %rsi     # 0x7e155
movb $0x0, %al
callq 0x1200
movq 0x28(%rbp), %rdi
movl -0x1dc(%rbp), %esi
movss -0x1ac(%rbp), %xmm0
movss -0x1b0(%rbp), %xmm1
callq 0x38f50
movq 0x28(%rbp), %rdi
movl -0x1dc(%rbp), %esi
movq 0x70(%rbp), %rdx
leaq -0x1a0(%rbp), %rcx
movss -0x1a8(%rbp), %xmm0
callq 0x395d0
movss -0x1ac(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3941c
movl $0x0, -0x1d8(%rbp)
movl -0x1d8(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x3941a
movss -0x1ac(%rbp), %xmm1
movq 0x88(%rbp), %rax
movslq -0x1d8(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x1d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d8(%rbp)
jmp 0x393da
jmp 0x3941c
movl $0x0, -0x1d8(%rbp)
movl -0x1d8(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x394b6
movq 0x88(%rbp), %rax
movslq -0x1d8(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x4490c(%rip), %xmm0    # 0x7dd60
ucomisd %xmm1, %xmm0
jbe 0x394a0
cmpl $0x0, -0x1d4(%rbp)
jne 0x3947b
leaq 0x44cd1(%rip), %rdi     # 0x7e13b
movb $0x0, %al
callq 0x10d0
movl $0x1, -0x1d4(%rbp)
movq 0x88(%rbp), %rax
movslq -0x1d8(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x46811(%rip), %rdi     # 0x7fcaa
movb $0x1, %al
callq 0x10d0
jmp 0x394a2
movl -0x1d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d8(%rbp)
jmp 0x39426
leaq -0x130(%rbp), %rdi
movq 0x68(%rbp), %rdx
movq 0x60(%rbp), %rcx
movq -0x38(%rbp), %r8
leaq 0x44c82(%rip), %rsi     # 0x7e152
movb $0x0, %al
callq 0x1200
movq 0x88(%rbp), %rdi
movq 0x80(%rbp), %rsi
movq 0x90(%rbp), %rdx
movq 0x98(%rbp), %rcx
movq 0xa0(%rbp), %r8
movl -0x2c(%rbp), %r9d
movl 0x58(%rbp), %eax
movl %eax, -0x1f4(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x1e8(%rbp)
movl -0x1dc(%rbp), %eax
movl %eax, -0x1e4(%rbp)
movq -0x58(%rbp), %r13
movq 0x18(%rbp), %r12
movl 0x20(%rbp), %r15d
leaq -0x130(%rbp), %r14
movq -0x38(%rbp), %rbx
movq 0xa8(%rbp), %r11
movq 0xb0(%rbp), %r10
movl 0xb8(%rbp), %eax
movl %eax, -0x1e0(%rbp)
movl -0x1f4(%rbp), %eax
movl %eax, (%rsp)
movq -0x1f0(%rbp), %rax
movq %rax, 0x8(%rsp)
movl -0x1e8(%rbp), %eax
movl %eax, 0x10(%rsp)
movl -0x1e4(%rbp), %eax
movl %eax, 0x18(%rsp)
movl -0x1e0(%rbp), %eax
movq %r13, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movl %r15d, 0x30(%rsp)
movq %r14, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
movq %r11, 0x48(%rsp)
movq %r10, 0x50(%rsp)
movl %eax, 0x58(%rsp)
callq 0x39670
movss -0x1a8(%rbp), %xmm0
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)