// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/Fit_B_factors.c
// Function: Fit_fluctuations
float Fit_fluctuations(int FIT_B, float *B_TNM,
		       float *RMSD_NM, char *out,
		       float *Temp_comp, float Temp,
		       int anharmonic, struct Normal_Mode NM,
		       struct Reference Ref_kin, char *REF,
		       struct residue *seq1, int nres1, int nmr1,
		       atom *atoms1, char *nameout1,
		       float *factor_B, int *outlier_B)
{

  float *sigma2; char nameout[100];
  if(anharmonic==0){
    sigma2=NM.sigma2;
    sprintf(nameout, "%s", nameout1);
  }else{
    sigma2=NM.sigma2_anhar;
    sprintf(nameout, "%s.anharmonic", nameout1);
  }

  int i, k, N_ref=Ref_kin.N_ref;


  double bsum=0, bsum2=0; // mass_CA=0; 
  double pi=3.1415, norm_B=8.0*pi*pi/3;
  char BSEL[4]="CA";
  if(strcmp(REF, "CB")==0)strcpy(BSEL, "CB");
  int Na=0, j=0, Bref[nres1];
  float Xref[(3*nres1)];
  float *B_exp=malloc(N_ref*sizeof(float)), *B_pred_all=NULL;
  for(i=0; i<N_ref; i++){
    atom *atm=atoms1+Ref_kin.atom_num[i];
    if((strncmp(atm->name, BSEL, 2)!=0)&&
       ((seq1[atm->res].amm!='G')||(strncmp(atm->name, "CA", 2)!=0)))continue;
    Bref[Na]=Ref_kin.atom_num[i];
    B_TNM[Na]=Compute_correlation(NM.Cart,sigma2,NM.N,i,i);
    //if(ANM)B_TNM[Na]/=Ref_kin.mass_atom[i];
    //mass_CA+=Ref_kin.mass_atom[i];
    B_exp[Na]=atm->B_factor/norm_B; //
    bsum+=B_exp[Na]; bsum2+=B_exp[Na]*B_exp[Na];
    for(k=0; k<3; k++){Xref[j]=atm->r[k]; j++;}
    Na++;
  }
  bsum/=Na; bsum2=(bsum2/Na-bsum*bsum);
  float RMSD_crys=sqrt(bsum), RMSD_crys_int=-1;
  printf("%d %s atoms selected in %d residues\n", Na, BSEL, nres1);
  printf("RMSD of fluctuations (B fact tot)= %.3f\n", RMSD_crys);

  char ridge='C'; //'M'
  float bsmall=0.01, r_B=0, slope_B=0, slope_NoRot=0, f_dof[3]; 
  f_dof[0]=0; f_dof[1]=0; f_dof[2]=0;
  for(i=0; i<nres1; i++)outlier_B[i]=0; //modyves
  if((bsum < bsmall)||(bsum2<bsmall)||(nmr1)){
    //YYY this is a weird contstraint... ditches many cases..
    printf("WARNING, no Bfact fit bsum= %.2g var= %.2g nmr=%d\n",
	   bsum,bsum2,nmr1);
    free(B_exp);
    B_exp=NULL;
    RMSD_crys=0;
    // FIT_B=-1; // YYY this is probably necessary ?? Ugo: This is wrong
  }else{
    // Fit B factors
    // Fit without rotations
    float offset=0, r=Corr_coeff(B_TNM, B_exp, Na, &slope_NoRot, &offset);
    printf("r(B_pred,B_exp)= %.3f offset= %.3f force const factor=%.4g",
	   r, offset, 1./slope_NoRot);
    printf(" (2 var fit)\n");
    // Fit with rotations
    B_pred_all=malloc(nres1*sizeof(float));
    slope_B=Bfactors_fit(&r_B, outlier_B, f_dof, B_pred_all, B_exp, B_TNM,
			 Xref, Na, nameout1, ridge);
    printf("B-factor fit with rotations, force const factor= %.3g\n", slope_B);
    RMSD_crys_int=sqrt(RMSD_crys*RMSD_crys*f_dof[0]);
    if((r_B<R_MIN)||(slope_B<SLOPE_MIN)){
      printf("WARNING, r_B= %.2f or Bfact slope= %.2g too small\n",
	     r_B,slope_B); 
      if(FIT_B>0)FIT_B=0;
    }
  }

  /*if(FIT_B && ANISOU){
    float **aniso_pred=malloc(N_ref*sizeof(float **));
    Compute_anisou(aniso_pred, N_modes, N_ref, eigen_B, Cart_mode);
    int weight[N_ref];
    float dot_aniso=0, ov_aniso=0, delta_aniso=2.;
    float **aniso_exp=malloc(N_ref*sizeof(float **));
    int 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, " %3d %.3f %6.3f %.4f",
    n_aniso, ov_aniso, dot_aniso, delta_aniso);
    }*/

  // factor for simulating ensemble
  if(slope_B){*factor_B=sqrt(slope_NoRot/slope_B);}
  else{*factor_B=-1;}

  double sum_sigma2=0;
  for(i=0; i<NM.N; i++)if(sigma2[i]>0)sum_sigma2+=sigma2[i];
  float kappa=1;
  if((FIT_B>0)&&(slope_B>0)){
    kappa=1./slope_B;
    printf("Force constant: %.4g x %.4g = %.4g    -> K0 = %.4g"
	   "  (Bfactor fit)\n", kappa,KAPPA,kappa*KAPPA,kappa*K0);
  }else if(FIT_B<0){
    kappa= sum_sigma2/(Ref_kin.mass_sum*RMSD_EXP*RMSD_EXP);
    printf("Force constant: %.4g x %.4g = %.4g     -> K0 = %.4g"
	   "   (<RMSD>= %.2f)\n", kappa,KAPPA,kappa*KAPPA,kappa*K0,RMSD_EXP);
  }else { //(FIT_B==0)||(slope_B<=0)
    kappa=1;
    printf("Force constant: %.4g x %.4g = %.4g    -> K0 = %.4g"
	   "    (Default value)\n", kappa,KAPPA,kappa*KAPPA,K0);
  }
  *RMSD_NM=sqrt(sum_sigma2/(Ref_kin.mass_sum*kappa));
  printf("RMSD of normal modes= %.3f (pred)\n", *RMSD_NM);
  if(FIT_B>0 && Temp>0){
    *Temp_comp=Temp;
  }else{
    //*Temp_comp=TEMP_DEF*kappa*KAPPA/KAPPA_DEF;
    *Temp_comp=TEMP_DEF;
  }

  if(anharmonic){sprintf(out,   "#B-factors, anharmonic analysis\n");}
  else{sprintf(out,   "#B-factors, harmonic analysis\n");}

  char tmp[60];
  sprintf(tmp, "r(B_pred,B_exp)       %.3f\n", r_B); strcat(out, tmp);
  sprintf(tmp, "Force constant factor %.3f\n", kappa); strcat(out, tmp);
  sprintf(tmp, "RMSD_crystal          %.3f (all)\n", RMSD_crys);
  strcat(out, tmp);
  sprintf(tmp, "RMSD_crystal          %.3f (internal)\n", RMSD_crys_int);
  strcat(out, tmp);
  sprintf(tmp, "RMSD_Norm.Modes       %.3f\n", *RMSD_NM); strcat(out, tmp);
  /*sprintf(tmp, "Estimated temperature %.1f (kappa= %.3g)\n",
   *Temp_comp, kappa*KAPPA); strcat(out, tmp);*/
  sprintf(tmp, "Internal_fluct        %.3f\n", f_dof[0]); strcat(out, tmp);
  sprintf(tmp, "Translation_fluct     %.3f\n", f_dof[1]); strcat(out, tmp);
  sprintf(tmp, "Rotation_fluct        %.3f\n", f_dof[2]); strcat(out, tmp);

  //  Print B factors
  // Rescale predicted B factors
  for(i=0; i<nres1; i++)B_TNM[i]/=kappa;
  Print_B_fact(B_TNM, B_pred_all, B_exp, Na, atoms1, Bref,
	      seq1, nameout, "Bfact", r_B, slope_B, f_dof, ridge);
  if(B_exp)free(B_exp);
  if(B_pred_all)free(B_pred_all);
  printf("FIT_B= %d kappa= %.3g\n", FIT_B, kappa);

  return(kappa);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movss %xmm0, -0xd4(%rbp)
movq %r8, -0x100(%rbp)
movq %rcx, -0xe0(%rbp)
movq %rdx, -0xf0(%rbp)
movq %rsi, %r15
movl %edi, %r14d
movq 0x138(%rbp), %rdx
movq 0x110(%rbp), %rbx
leaq 0xe0(%rbp), %r12
leaq 0x10(%rbp), %r13
movl %r9d, -0xd8(%rbp)
testl %r9d, %r9d
je 0x2989d
movq 0x88(%r13), %rax
movq %rax, -0xa8(%rbp)
leaq 0x2fcbf(%rip), %rsi     # 0x5954c
leaq -0x1c0(%rbp), %rdi
xorl %eax, %eax
callq 0x2270
jmp 0x298b7
movq 0x28(%r13), %rax
movq %rax, -0xa8(%rbp)
leaq -0x1c0(%rbp), %rdi
movq %rdx, %rsi
callq 0x2080
movslq (%r12), %rax
movq %rax, -0xa0(%rbp)
movl $0x4143, -0x4c(%rbp)    # imm = 0x4143
cmpb $0x43, (%rbx)
jne 0x298e4
cmpb $0x42, 0x1(%rbx)
jne 0x298e4
cmpb $0x0, 0x2(%rbx)
jne 0x298e4
movb $0x0, -0x4a(%rbp)
movw $0x4243, -0x4c(%rbp)    # imm = 0x4243
movq %r15, -0x48(%rbp)
movl %r14d, -0x78(%rbp)
movq %rsp, -0x108(%rbp)
movl 0x120(%rbp), %eax
movq %rax, %rcx
movl %ecx, %eax
movq %rsp, %rdx
movq %rax, -0xe8(%rbp)
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rdx
movq %rdx, -0xf8(%rbp)
movq %rdx, %rsp
leal (%rcx,%rcx,2), %eax
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x58(%rbp)
movq %rcx, %rsp
movq -0xa0(%rbp), %rbx
leaq (,%rbx,4), %rdi
callq 0x21e0
movq %rax, -0x80(%rbp)
testl %ebx, %ebx
jle 0x29aa6
movq 0x28(%r12), %rax
movq %rax, -0x70(%rbp)
movq 0x38(%r13), %rax
movq %rax, -0x68(%rbp)
movl (%r13), %eax
movl %eax, -0xc0(%rbp)
xorpd %xmm1, %xmm1
xorl %r15d, %r15d
movq $0x0, -0x60(%rbp)
xorl %r13d, %r13d
movapd %xmm1, -0x40(%rbp)
movq -0x70(%rbp), %rax
movslq (%rax,%r15,4), %r12
imulq $0x70, %r12, %rax
movq 0x130(%rbp), %rcx
leaq (%rcx,%rax), %rbx
leaq (%rcx,%rax), %r14
addq $0x18, %r14
movl $0x2, %edx
movq %r14, %rdi
leaq -0x4c(%rbp), %rsi
callq 0x2070
testl %eax, %eax
je 0x299f1
movslq 0x64(%rbx), %rax
shlq $0x5, %rax
movq 0x118(%rbp), %rcx
cmpb $0x47, 0x13(%rcx,%rax)
jne 0x29a8f
cmpb $0x43, (%r14)
jne 0x29a8f
cmpb $0x41, 0x19(%rbx)
jne 0x29a8f
movslq -0x60(%rbp), %r14
movq -0xf8(%rbp), %rax
movl %r12d, (%rax,%r14,4)
movq -0x68(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movl -0xc0(%rbp), %edx
movl %r15d, %ecx
movl %r15d, %r8d
callq 0x2a28b
movq -0x48(%rbp), %rax
movss %xmm0, (%rax,%r14,4)
xorps %xmm0, %xmm0
cvtss2sd 0x1c(%rbx), %xmm0
divsd 0x2fb0a(%rip), %xmm0    # 0x59540
xorps %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm1
movaps %xmm1, %xmm0
mulss %xmm1, %xmm0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtps2pd %xmm0, %xmm0
movq -0x80(%rbp), %rax
movss %xmm1, (%rax,%r14,4)
movslq %r13d, %rax
movq -0x58(%rbp), %rcx
leaq (%rcx,%rax,4), %rcx
xorl %eax, %eax
xorps %xmm1, %xmm1
cvtsd2ss (%rbx,%rax,8), %xmm1
movss %xmm1, (%rcx,%rax,4)
incq %rax
cmpq $0x3, %rax
jne 0x29a61
movapd -0x40(%rbp), %xmm1
addpd %xmm0, %xmm1
addl %eax, %r13d
movq -0x60(%rbp), %rax
incl %eax
movq %rax, -0x60(%rbp)
jmp 0x29a94
movapd -0x40(%rbp), %xmm1
incq %r15
cmpq -0xa0(%rbp), %r15
jne 0x2998a
jmp 0x29ab2
xorpd %xmm1, %xmm1
movq $0x0, -0x60(%rbp)
cvtsi2sdl -0x60(%rbp), %xmm3
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
divsd %xmm3, %xmm2
movapd 0x275c5(%rip), %xmm0    # 0x51090
xorpd %xmm2, %xmm0
ucomisd %xmm0, %xmm2
movapd %xmm2, -0xa0(%rbp)
jb 0x29ae6
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x29b0b
movapd %xmm2, %xmm0
movapd %xmm1, -0x40(%rbp)
movsd %xmm3, -0x70(%rbp)
callq 0x22a0
movsd -0x70(%rbp), %xmm3
movapd -0xa0(%rbp), %xmm2
movapd -0x40(%rbp), %xmm1
movl -0x78(%rbp), %ebx
movq -0x48(%rbp), %r15
divsd %xmm3, %xmm1
movapd %xmm1, -0x40(%rbp)
mulsd %xmm2, %xmm2
movapd %xmm2, -0xc0(%rbp)
movq 0x148(%rbp), %r13
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x68(%rbp)
leaq 0x2fa1c(%rip), %rdi     # 0x5955a
xorl %r14d, %r14d
leaq -0x4c(%rbp), %rdx
movq -0x60(%rbp), %rsi
movl 0x120(%rbp), %r12d
movl %r12d, %ecx
xorl %eax, %eax
callq 0x20f0
xorps %xmm0, %xmm0
cvtss2sd -0x68(%rbp), %xmm0
leaq 0x2fa16(%rip), %rdi     # 0x5957f
movsd %xmm0, -0x70(%rbp)
movb $0x1, %al
callq 0x20f0
movl %r14d, -0x88(%rbp)
movl %r14d, -0x84(%rbp)
movq $0x0, -0xd0(%rbp)
movl %r14d, -0xc8(%rbp)
testl %r12d, %r12d
jle 0x29bb3
movq -0xe8(%rbp), %rax
leaq (,%rax,4), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x2110
movl 0x128(%rbp), %esi
movapd -0x40(%rbp), %xmm1
subsd -0xc0(%rbp), %xmm1
movsd 0x2d7ba(%rip), %xmm2    # 0x57388
movapd -0xa0(%rbp), %xmm0
ucomisd %xmm0, %xmm2
movq -0xe0(%rbp), %r14
jbe 0x29d40
leaq 0x2f9ba(%rip), %rdi     # 0x595a8
movb $0x2, %al
callq 0x20f0
movq -0x80(%rbp), %rdi
callq 0x2050
movss 0x2750a(%rip), %xmm0    # 0x51110
xorpd %xmm1, %xmm1
movsd %xmm1, -0x70(%rbp)
movsd 0x2c4e1(%rip), %xmm1    # 0x560f8
movsd %xmm1, -0x78(%rbp)
xorps %xmm1, %xmm1
movss %xmm1, -0x68(%rbp)
movq $0x0, -0xc0(%rbp)
movss %xmm1, -0xa0(%rbp)
xorpd %xmm2, %xmm2
movq $0x0, -0x80(%rbp)
movl %ebx, %r12d
movq -0xa8(%rbp), %rbx
leaq 0xe0(%rbp), %r13
movq 0x140(%rbp), %rax
movss %xmm0, (%rax)
leaq 0x10(%rbp), %rax
movslq (%rax), %rax
xorps %xmm3, %xmm3
testq %rax, %rax
jle 0x29c8d
xorl %ecx, %ecx
xorps %xmm0, %xmm0
movss (%rbx,%rcx,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x29c85
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm3
incq %rcx
cmpq %rcx, %rax
jne 0x29c73
testl %r12d, %r12d
movss %xmm2, -0x58(%rbp)
movsd %xmm3, -0x48(%rbp)
jle 0x29cf8
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
jbe 0x29cf8
movss 0x27470(%rip), %xmm3    # 0x5111c
divss %xmm2, %xmm3
movss %xmm3, -0x40(%rbp)
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
leaq 0x3f3b5(%rip), %rax     # 0x69078
movss (%rax), %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
mulss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x3f3a3(%rip), %rax     # 0x69080
movsd (%rax), %xmm3
mulsd %xmm0, %xmm3
leaq 0x2f994(%rip), %rdi     # 0x59680
movb $0x4, %al
callq 0x20f0
jmp 0x29ed0
testl %r12d, %r12d
js 0x29e5d
leaq 0x3f370(%rip), %rax     # 0x69078
xorps %xmm1, %xmm1
cvtss2sd (%rax), %xmm1
leaq 0x3f36a(%rip), %rax     # 0x69080
movsd (%rax), %xmm3
leaq 0x2f9e8(%rip), %rdi     # 0x59709
movsd 0x2741f(%rip), %xmm0    # 0x51148
movaps %xmm1, %xmm2
movb $0x4, %al
callq 0x20f0
movss 0x273e1(%rip), %xmm1    # 0x5111c
jmp 0x29ed5
testl %esi, %esi
jne 0x29be7
ucomisd %xmm1, %xmm2
ja 0x29be7
leaq -0x150(%rbp), %r14
movl $0x0, (%r14)
leaq -0x84(%rbp), %r15
movq -0x48(%rbp), %rdi
movq -0x80(%rbp), %r12
movq %r12, %rsi
movq -0x60(%rbp), %r13
movl %r13d, %edx
movq %r15, %rcx
movq %r14, %r8
callq 0x108db
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd (%r14), %xmm1
xorps %xmm3, %xmm3
cvtss2sd (%r15), %xmm3
movq -0x48(%rbp), %r15
movsd 0x273a4(%rip), %xmm2    # 0x51148
divsd %xmm3, %xmm2
leaq 0x2f82c(%rip), %rdi     # 0x595db
movb $0x3, %al
callq 0x20f0
leaq 0x2fc4e(%rip), %rdi     # 0x59a0b
callq 0x2090
movl 0x120(%rbp), %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x21e0
leaq -0x88(%rbp), %rdi
leaq -0xd0(%rbp), %r14
movq 0x148(%rbp), %rsi
movq %r14, %rdx
movq %rax, %rcx
movq %rax, -0xc0(%rbp)
movq %r12, %r8
movq %r15, %r9
pushq $0x43
pushq 0x138(%rbp)
pushq %r13
pushq -0x58(%rbp)
callq 0x2a309
addq $0x20, %rsp
movss %xmm0, -0x58(%rbp)
cvtss2sd %xmm0, %xmm0
leaq 0x2f7f4(%rip), %rdi     # 0x59616
movsd %xmm0, -0x40(%rbp)
movb $0x1, %al
callq 0x20f0
movss -0x68(%rbp), %xmm0
mulss %xmm0, %xmm0
movss (%r14), %xmm1
movss %xmm1, -0x68(%rbp)
mulss %xmm1, %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x2a1b4
xorps %xmm3, %xmm3
sqrtss %xmm0, %xmm3
jmp 0x2a1bc
leaq 0x3f26c(%rip), %rax     # 0x690d0
movss (%rax), %xmm4
movss 0x8(%r13), %xmm0
mulss %xmm4, %xmm0
mulss %xmm4, %xmm0
cvtss2sd %xmm0, %xmm0
movapd %xmm3, %xmm1
divsd %xmm0, %xmm1
xorps %xmm3, %xmm3
cvtsd2ss %xmm1, %xmm3
movss %xmm3, -0x40(%rbp)
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
leaq 0x3f1dc(%rip), %rax     # 0x69078
movss (%rax), %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
mulss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x3f1ca(%rip), %rax     # 0x69080
movsd (%rax), %xmm3
mulsd %xmm0, %xmm3
cvtss2sd %xmm4, %xmm4
leaq 0x2f7fa(%rip), %rdi     # 0x596c3
movb $0x5, %al
callq 0x20f0
movss -0x40(%rbp), %xmm1
movss %xmm1, -0x40(%rbp)
movss 0x8(%r13), %xmm0
mulss %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd -0x48(%rbp), %xmm0
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x29f04
sqrtsd %xmm0, %xmm0
jmp 0x29f09
callq 0x22a0
movq -0xc0(%rbp), %r13
cvtsd2ss %xmm0, %xmm0
movq -0xf0(%rbp), %rax
movss %xmm0, (%rax)
cvtss2sd %xmm0, %xmm0
leaq 0x2f826(%rip), %rdi     # 0x59750
movb $0x1, %al
callq 0x20f0
leaq 0x3d260(%rip), %rax     # 0x67198
movss (%rax), %xmm0
movss -0xd4(%rbp), %xmm3
movaps %xmm3, %xmm1
testl %r12d, %r12d
jg 0x29f4f
movaps %xmm0, %xmm1
xorps %xmm2, %xmm2
cmpltss %xmm3, %xmm2
andps %xmm2, %xmm1
andnps %xmm0, %xmm2
orps %xmm1, %xmm2
movq -0x100(%rbp), %rax
movss %xmm2, (%rax)
cmpl $0x0, -0xd8(%rbp)
je 0x29f92
movups 0x2f808(%rip), %xmm0    # 0x59783
movups %xmm0, 0x10(%r14)
movups 0x2f7ec(%rip), %xmm0    # 0x59773
movups %xmm0, (%r14)
movb $0x0, 0x20(%r14)
jmp 0x29fa9
movups 0x2f80a(%rip), %xmm0    # 0x597a3
movups %xmm0, 0xf(%r14)
movups 0x2f7ef(%rip), %xmm0    # 0x59794
movups %xmm0, (%r14)
xorps %xmm0, %xmm0
cvtss2sd -0xa0(%rbp), %xmm0
leaq 0x2f7f8(%rip), %rsi     # 0x597b3
leaq -0x150(%rbp), %rbx
movq %rbx, %rdi
movb $0x1, %al
callq 0x2270
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2250
xorps %xmm0, %xmm0
cvtss2sd -0x40(%rbp), %xmm0
leaq 0x2f7e9(%rip), %rsi     # 0x597cf
movq %rbx, %rdi
movsd %xmm0, -0x48(%rbp)
movb $0x1, %al
callq 0x2270
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2250
leaq 0x2f7e4(%rip), %rsi     # 0x597eb
movq %rbx, %rdi
movsd -0x70(%rbp), %xmm0
movb $0x1, %al
callq 0x2270
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2250
leaq 0x2f7e5(%rip), %rsi     # 0x5980d
movq %rbx, %rdi
movsd -0x78(%rbp), %xmm0
movb $0x1, %al
callq 0x2270
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2250
movq -0xf0(%rbp), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax), %xmm0
leaq 0x2f7dd(%rip), %rsi     # 0x59834
movq %rbx, %rdi
movb $0x1, %al
callq 0x2270
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2250
xorps %xmm0, %xmm0
cvtss2sd -0x68(%rbp), %xmm0
leaq 0x2f7d5(%rip), %rsi     # 0x59850
movq %rbx, %rdi
movb $0x1, %al
callq 0x2270
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2250
xorps %xmm0, %xmm0
cvtss2sd -0xcc(%rbp), %xmm0
leaq 0x2f7ca(%rip), %rsi     # 0x5986c
movq %rbx, %rdi
movb $0x1, %al
callq 0x2270
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2250
xorps %xmm0, %xmm0
cvtss2sd -0xc8(%rbp), %xmm0
leaq 0x2f7bf(%rip), %rsi     # 0x59888
movq %rbx, %rdi
movb $0x1, %al
callq 0x2270
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2250
movss -0x40(%rbp), %xmm1
movl 0x120(%rbp), %eax
testl %eax, %eax
movq -0xe8(%rbp), %rcx
jle 0x2a10e
xorl %eax, %eax
movss (%r15,%rax,4), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%r15,%rax,4)
incq %rax
cmpq %rax, %rcx
jne 0x2a0f6
subq $0x8, %rsp
leaq -0xd0(%rbp), %rax
leaq 0x2f784(%rip), %r10     # 0x598a4
leaq -0x1c0(%rbp), %r11
movq %r15, %rdi
movq %r13, %rsi
movq -0x80(%rbp), %rbx
movq %rbx, %rdx
movq -0x60(%rbp), %rcx
movq 0x130(%rbp), %r8
movq -0xf8(%rbp), %r9
movss -0xa0(%rbp), %xmm0
movss -0x58(%rbp), %xmm1
pushq $0x43
pushq %rax
pushq %r10
pushq %r11
pushq 0x118(%rbp)
callq 0x28d75
addq $0x30, %rsp
testq %rbx, %rbx
je 0x2a176
movq %rbx, %rdi
callq 0x2050
testq %r13, %r13
je 0x2a183
movq %r13, %rdi
callq 0x2050
leaq 0x2f720(%rip), %rdi     # 0x598aa
movl %r12d, %esi
movsd -0x48(%rbp), %xmm0
movb $0x1, %al
callq 0x20f0
movq -0x108(%rbp), %rsp
movss -0x40(%rbp), %xmm0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x21d0
movaps %xmm0, %xmm3
movl %ebx, %r12d
movss -0x88(%rbp), %xmm1
leaq 0x3eefa(%rip), %rax     # 0x690c8
movss (%rax), %xmm0
movss %xmm1, -0xa0(%rbp)
ucomiss %xmm1, %xmm0
movq -0xe0(%rbp), %r14
leaq 0xe0(%rbp), %r13
movq -0xa8(%rbp), %rbx
movss -0x58(%rbp), %xmm2
ja 0x2a209
leaq 0x3eecc(%rip), %rax     # 0x690cc
movss (%rax), %xmm0
ucomiss %xmm2, %xmm0
jbe 0x2a23f
xorps %xmm0, %xmm0
cvtss2sd -0xa0(%rbp), %xmm0
leaq 0x2f432(%rip), %rdi     # 0x5964d
movsd -0x40(%rbp), %xmm1
movb $0x2, %al
movss %xmm3, -0x40(%rbp)
callq 0x20f0
movss -0x40(%rbp), %xmm3
movss -0x58(%rbp), %xmm2
movl %r12d, %eax
sarl $0x1f, %eax
andl %eax, %r12d
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
movsd %xmm0, -0x78(%rbp)
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm2
jne 0x2a255
jnp 0x2a26f
movss -0x84(%rbp), %xmm0
divss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jb 0x2a27c
sqrtss %xmm0, %xmm0
jmp 0x29c54
movss 0x26e99(%rip), %xmm0    # 0x51110
jmp 0x29c54
callq 0x21d0
movss -0x58(%rbp), %xmm2
jmp 0x29c54