// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/confchange.c
// Function: Print_modes_confchange
void Print_modes_confchange(char *name2, char *nameout2,
			    struct Normal_Mode NM, struct Tors Diff,
			    int ANM, float M_sqrt, float rmsd,
			    int anharmonic,float xkappa)
{
  /***************** Normal modes confchange ********************/

  char nameout[400];
  sprintf(nameout, "%s.Modes.dat", nameout2);
  FILE *file_out=fopen(nameout, "w");
  printf("Writing %s\n", nameout);
  fprintf(file_out, "# Conf.change %s\n", name2);
  fprintf(file_out, "# kappa=  %.3f\n",xkappa);

  /*float *sigma2;
  if(anharmonic){
    fprintf(file_out, "# Omega2 corrected for anharmonicity\n");
    sigma2=NM.sigma2_anhar;
  }else{
    sigma2=NM.sigma2;
    }*/


  // Compute confchange and copy on normal modes

  // Sort on c2
  int sorted [NM.N], i, k;
  for(i=0;i<NM.N; i++)sorted[i]=0;
  float *c2=NM.confchange2;
  for(k=0; k<NM.N; k++){
    int ik=-1; float cmax=-1; 
    for (i=0;i<NM.N; i++){
      if((sorted[i]==0)&&(c2[i]>=cmax)&&(NM.select[i])){
	cmax=c2[i]; ik=i;
      }
    }
    if(ik>=0){
      NM.sort[k]=ik; sorted[ik]=1;
    }else{ // nothing found
      ik=k;
      for (i=0;i<NM.N; i++){
	if(NM.select[i]==0){NM.sort[ik]=i; ik++; if(ik==NM.N)break;}
      }
      break;
    }
  }

  // Print lines
  fprintf(file_out, "# Frequency reported in internal units: %.3f ps^(-1),"
	  " kT/h/ is %.3g internal units (om-2)= %.3g\n",
	  Freq_unit, 0.385/Freq_unit, Freq_unit*Freq_unit/0.1482);
  fprintf(file_out,"# mode pc_confch cumul  ");
  fprintf(file_out,"om-2(harm) ");
  if(anharmonic)fprintf(file_out, "om-2(corr) om-2(anha) ");
  fprintf(file_out,"   RMSD  Coll_cart");
  if(NM.MW_Tors_coll)fprintf(file_out, "  Coll_MW");
  if(NM.Tors_coll)fprintf(file_out, "  Coll_tors");

  //fprintf(file_out, "# mode\tContr_to_confchange\tCumulative");
  //if(anharmonic)fprintf(file_out, "\tOmega^(-2)_anharm");
  //fprintf(file_out, "\tOmega^(-2) RMSD ");
  //fprintf(file_out, "\tColl.(cart)\tColl.(MWtors)\tColl.(tors)");
  if(ANM)fprintf(file_out, "\tTors_frac"); //force_coeff
  if(NM.Anharmonicity[0]){
    fprintf(file_out, "\tAnharm_Str Str_confchange");
    fprintf(file_out, "\tAnharm_Ene\tEne_confchange\tMax_RMSD");
  }
  fprintf(file_out, "\n");

  //float N_sqrt=sqrt(NM.N_Cart/3);
  double sum_coeff_C=0; //sum_B=0;
  for(k=0; k<NM.N; k++){
    int ik=NM.sort[k]; if(ik<0)continue;
    sum_coeff_C+=c2[ik];
    //sum_B+=NM.sigma2[ik];
    if(NM.select[ik]==0)fprintf(file_out,"#");

    fprintf(file_out, "%6d  %8.3g %5.3f     ",ik, c2[ik], sum_coeff_C);
    fprintf(file_out, "%7.4g  ",NM.sigma2[ik]);
    if(anharmonic)fprintf(file_out,"%7.4g  %7.4g  ",
			  xkappa*NM.sigma2_anhar[ik],NM.sigma2_anhar[ik]);
    fprintf(file_out, "  %8.3g", 1./(M_sqrt*NM.omega[ik]));
    fprintf(file_out, "  %5.3f", NM.Cart_coll[ik]);
    fprintf(file_out, "  %5.3f", NM.MW_Tors_coll[ik]);
    fprintf(file_out, "  %5.3f", NM.Tors_coll[ik]);
	    
    if(ANM)fprintf(file_out,"\t%.3f",NM.Tors_frac[ik]);
    if(NM.Anharmonicity[0]){
      int dir;
      if(((NM.Anharm_struct[ik]>0)&&(Diff.coeff[ik]>0))||
	 ((NM.Anharm_struct[ik]<0)&&(Diff.coeff[ik]<0))){dir=1;}
      else{dir=0;}
      fprintf(file_out,"\t%.3f\t%d",
	      fabs(NM.Anharm_struct[ik]),dir);
      if(((NM.Anharmonicity[ik]>0)&&(Diff.coeff[ik]>0))||
	 ((NM.Anharmonicity[ik]<0)&&(Diff.coeff[ik]<0))){dir=1;}
      else{dir=0;}
      fprintf(file_out,"\t%.3f\t%d\t%.2f",
	      fabs(NM.Anharmonicity[ik]),dir, NM.Max_RMSD[ik]);
    }
    fprintf(file_out, "\n");
  }
  //free(c2);
  fclose(file_out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
leaq 0xe0(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x210(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movss %xmm0, -0x18(%rbp)
movss %xmm1, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movss %xmm2, -0x24(%rbp)
movq -0x10(%rbp), %rdx
leaq 0x3b4f1(%rip), %rsi     # 0x7f99d
xorl %eax, %eax
movb %al, -0x211(%rbp)
leaq -0x1c0(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x1200
movq -0x220(%rbp), %rdi
leaq 0x37e9d(%rip), %rsi     # 0x7c372
callq 0x11b0
movq -0x220(%rbp), %rsi
movq %rax, %rcx
movb -0x211(%rbp), %al
movq %rcx, -0x1c8(%rbp)
leaq 0x32ff6(%rip), %rdi     # 0x774ee
callq 0x10d0
movb -0x211(%rbp), %al
movq -0x1c8(%rbp), %rdi
movq -0x8(%rbp), %rdx
leaq 0x3b495(%rip), %rsi     # 0x7f9aa
callq 0x1150
movq -0x1c8(%rbp), %rdi
movss -0x24(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3b48b(%rip), %rsi     # 0x7f9bc
movb $0x1, %al
callq 0x1150
movq -0x210(%rbp), %rax
movl (%rax), %eax
movq %rsp, %rcx
movq %rcx, -0x1d0(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x208(%rbp)
movq %rcx, %rsp
movq %rax, -0x1d8(%rbp)
movl $0x0, -0x1dc(%rbp)
movq -0x210(%rbp), %rcx
movl -0x1dc(%rbp), %eax
cmpl (%rcx), %eax
jge 0x445af
movq -0x208(%rbp), %rax
movslq -0x1dc(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x1dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1dc(%rbp)
jmp 0x44578
movq -0x210(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x1e8(%rbp)
movl $0x0, -0x1e0(%rbp)
movq -0x210(%rbp), %rcx
movl -0x1e0(%rbp), %eax
cmpl (%rcx), %eax
jge 0x4478a
movl $0xffffffff, -0x1ec(%rbp) # imm = 0xFFFFFFFF
movss 0x31a7e(%rip), %xmm0    # 0x76070
movss %xmm0, -0x1f0(%rbp)
movl $0x0, -0x1dc(%rbp)
movq -0x210(%rbp), %rcx
movl -0x1dc(%rbp), %eax
cmpl (%rcx), %eax
jge 0x446a1
movq -0x208(%rbp), %rax
movslq -0x1dc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x4468b
movq -0x1e8(%rbp), %rax
movslq -0x1dc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
ucomiss -0x1f0(%rbp), %xmm0
jb 0x4468b
movq -0x210(%rbp), %rax
movq 0xc0(%rax), %rax
movslq -0x1dc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x4468b
movq -0x1e8(%rbp), %rax
movslq -0x1dc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x1f0(%rbp)
movl -0x1dc(%rbp), %eax
movl %eax, -0x1ec(%rbp)
jmp 0x4468d
movl -0x1dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1dc(%rbp)
jmp 0x44604
cmpl $0x0, -0x1ec(%rbp)
jl 0x446e2
movq -0x208(%rbp), %rax
movq -0x210(%rbp), %rcx
movl -0x1ec(%rbp), %esi
movq 0xb8(%rcx), %rcx
movslq -0x1e0(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movslq -0x1ec(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x44774
movl -0x1e0(%rbp), %eax
movl %eax, -0x1ec(%rbp)
movl $0x0, -0x1dc(%rbp)
movq -0x210(%rbp), %rcx
movl -0x1dc(%rbp), %eax
cmpl (%rcx), %eax
jge 0x44772
movq -0x210(%rbp), %rax
movq 0xc0(%rax), %rax
movslq -0x1dc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x4475f
movq -0x210(%rbp), %rcx
movl -0x1dc(%rbp), %esi
movq 0xb8(%rcx), %rax
movslq -0x1ec(%rbp), %rdx
movl %esi, (%rax,%rdx,4)
movl -0x1ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ec(%rbp)
movl -0x1ec(%rbp), %eax
cmpl (%rcx), %eax
jne 0x4475d
jmp 0x44772
jmp 0x4475f
jmp 0x44761
movl -0x1dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1dc(%rbp)
jmp 0x446f8
jmp 0x4478a
jmp 0x44776
movl -0x1e0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e0(%rbp)
jmp 0x445cb
movq -0x1c8(%rbp), %rdi
leaq 0x459c4(%rip), %rax     # 0x8a15c
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x459b5(%rip), %rax     # 0x8a15c
movss (%rax), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x3a581(%rip), %xmm1    # 0x7ed38
divsd %xmm2, %xmm1
leaq 0x4599a(%rip), %rax     # 0x8a15c
movss (%rax), %xmm2
leaq 0x4598f(%rip), %rax     # 0x8a15c
mulss (%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movsd 0x3a553(%rip), %xmm3    # 0x7ed30
divsd %xmm3, %xmm2
leaq 0x3b1e4(%rip), %rsi     # 0x7f9cc
movb $0x3, %al
callq 0x1150
movq -0x1c8(%rbp), %rdi
leaq 0x3b230(%rip), %rsi     # 0x7fa2d
movb $0x0, %al
callq 0x1150
movq -0x1c8(%rbp), %rdi
leaq 0x3b234(%rip), %rsi     # 0x7fa46
movb $0x0, %al
callq 0x1150
cmpl $0x0, -0x20(%rbp)
je 0x44834
movq -0x1c8(%rbp), %rdi
leaq 0x3b225(%rip), %rsi     # 0x7fa52
movb $0x0, %al
callq 0x1150
movq -0x1c8(%rbp), %rdi
leaq 0x3b227(%rip), %rsi     # 0x7fa69
movb $0x0, %al
callq 0x1150
movq -0x210(%rbp), %rax
cmpq $0x0, 0x78(%rax)
je 0x4486c
movq -0x1c8(%rbp), %rdi
leaq 0x3b217(%rip), %rsi     # 0x7fa7c
movb $0x0, %al
callq 0x1150
movq -0x210(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0x4488f
movq -0x1c8(%rbp), %rdi
leaq 0x3b1fe(%rip), %rsi     # 0x7fa86
movb $0x0, %al
callq 0x1150
cmpl $0x0, -0x14(%rbp)
je 0x448aa
movq -0x1c8(%rbp), %rdi
leaq 0x3b1ef(%rip), %rsi     # 0x7fa92
movb $0x0, %al
callq 0x1150
movq -0x210(%rbp), %rax
movq 0x98(%rax), %rax
movss (%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x448c8
jp 0x448c8
jmp 0x448f2
movq -0x1c8(%rbp), %rdi
leaq 0x3b1c7(%rip), %rsi     # 0x7fa9d
movb $0x0, %al
callq 0x1150
movq -0x1c8(%rbp), %rdi
leaq 0x3b1cd(%rip), %rsi     # 0x7fab8
movb $0x0, %al
callq 0x1150
movq -0x1c8(%rbp), %rdi
leaq 0x39778(%rip), %rsi     # 0x7e078
movb $0x0, %al
callq 0x1150
xorps %xmm0, %xmm0
movsd %xmm0, -0x1f8(%rbp)
movl $0x0, -0x1e0(%rbp)
movq -0x210(%rbp), %rcx
movl -0x1e0(%rbp), %eax
cmpl (%rcx), %eax
jge 0x44d83
movq -0x210(%rbp), %rax
movq 0xb8(%rax), %rax
movslq -0x1e0(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x1fc(%rbp)
cmpl $0x0, -0x1fc(%rbp)
jge 0x4495d
jmp 0x44d6f
movq -0x210(%rbp), %rax
movq -0x1e8(%rbp), %rcx
movslq -0x1fc(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x1f8(%rbp), %xmm0
movsd %xmm0, -0x1f8(%rbp)
movq 0xc0(%rax), %rax
movslq -0x1fc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x449b4
movq -0x1c8(%rbp), %rdi
leaq 0x3cd6a(%rip), %rsi     # 0x81717
movb $0x0, %al
callq 0x1150
movq -0x1c8(%rbp), %rdi
movl -0x1fc(%rbp), %edx
movq -0x1e8(%rbp), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd -0x1f8(%rbp), %xmm1
leaq 0x3b0f5(%rip), %rsi     # 0x7fadc
movb $0x2, %al
callq 0x1150
movq -0x210(%rbp), %rax
movq -0x1c8(%rbp), %rdi
movq 0x28(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3b0e2(%rip), %rsi     # 0x7faf9
movb $0x1, %al
callq 0x1150
cmpl $0x0, -0x20(%rbp)
je 0x44a73
movq -0x210(%rbp), %rax
movq -0x1c8(%rbp), %rdi
movss -0x24(%rbp), %xmm0
movq 0x88(%rax), %rcx
movslq -0x1fc(%rbp), %rdx
mulss (%rcx,%rdx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0x88(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x3b086(%rip), %rsi     # 0x7faf2
movb $0x2, %al
callq 0x1150
movq -0x210(%rbp), %rax
movq -0x1c8(%rbp), %rdi
movss -0x18(%rbp), %xmm0
movq 0x18(%rax), %rax
movslq -0x1fc(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x315a6(%rip), %xmm0    # 0x76048
divsd %xmm1, %xmm0
leaq 0x3b054(%rip), %rsi     # 0x7fb01
movb $0x1, %al
callq 0x1150
movq -0x210(%rbp), %rax
movq -0x1c8(%rbp), %rdi
movq 0x68(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3b02c(%rip), %rsi     # 0x7fb09
movb $0x1, %al
callq 0x1150
movq -0x210(%rbp), %rax
movq -0x1c8(%rbp), %rdi
movq 0x78(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3affc(%rip), %rsi     # 0x7fb09
movb $0x1, %al
callq 0x1150
movq -0x210(%rbp), %rax
movq -0x1c8(%rbp), %rdi
movq 0x70(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3afcc(%rip), %rsi     # 0x7fb09
movb $0x1, %al
callq 0x1150
cmpl $0x0, -0x14(%rbp)
je 0x44b7a
movq -0x210(%rbp), %rax
movq -0x1c8(%rbp), %rdi
movq 0x60(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3e046(%rip), %rsi     # 0x82bb9
movb $0x1, %al
callq 0x1150
movq -0x210(%rbp), %rax
movq 0x98(%rax), %rax
movss (%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x44b9b
jp 0x44b9b
jmp 0x44d5a
movq -0x210(%rbp), %rax
movq 0xa0(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x44bdc
movq -0x228(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
ja 0x44c15
movq -0x210(%rbp), %rax
movq 0xa0(%rax), %rax
movslq -0x1fc(%rbp), %rcx
xorps %xmm0, %xmm0
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x44c21
movq -0x228(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x1fc(%rbp), %rcx
xorps %xmm0, %xmm0
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x44c21
movl $0x1, -0x200(%rbp)
jmp 0x44c2b
movl $0x0, -0x200(%rbp)
movq -0x210(%rbp), %rax
movq -0x1c8(%rbp), %rdi
movq 0xa0(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movaps 0x37839(%rip), %xmm1    # 0x7c490
pand %xmm1, %xmm0
movl -0x200(%rbp), %edx
leaq 0x3aea9(%rip), %rsi     # 0x7fb11
movb $0x1, %al
callq 0x1150
movq -0x210(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x44cb0
movq -0x228(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
ja 0x44ce9
movq -0x210(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x1fc(%rbp), %rcx
xorps %xmm0, %xmm0
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x44cf5
movq -0x228(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x1fc(%rbp), %rcx
xorps %xmm0, %xmm0
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x44cf5
movl $0x1, -0x200(%rbp)
jmp 0x44cff
movl $0x0, -0x200(%rbp)
movq -0x210(%rbp), %rax
movq -0x1c8(%rbp), %rdi
movq 0x98(%rax), %rcx
movslq -0x1fc(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movaps 0x37765(%rip), %xmm1    # 0x7c490
pand %xmm1, %xmm0
movl -0x200(%rbp), %edx
movq 0xb0(%rax), %rax
movslq -0x1fc(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x3adc7(%rip), %rsi     # 0x7fb1a
movb $0x2, %al
callq 0x1150
movq -0x1c8(%rbp), %rdi
leaq 0x39310(%rip), %rsi     # 0x7e078
movb $0x0, %al
callq 0x1150
movl -0x1e0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e0(%rbp)
jmp 0x4491c
movq -0x1c8(%rbp), %rdi
callq 0x10a0
movq -0x1d0(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nop