// File: /workspace/github_c_makefile_star2_O1/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, -0xb0(%rbp)
movq %r8, -0x100(%rbp)
movq %rcx, -0xd8(%rbp)
movq %rdx, -0xe8(%rbp)
movq %rsi, %r15
movl %edi, %ebx
movq 0x138(%rbp), %rdx
movq 0x110(%rbp), %r14
leaq 0xe0(%rbp), %r13
leaq 0x10(%rbp), %rax
movl %r9d, -0xb4(%rbp)
testl %r9d, %r9d
je 0x29c09
movq 0x88(%rax), %rax
movq %rax, -0x60(%rbp)
leaq 0x2f9ab(%rip), %rsi     # 0x595a4
leaq -0x1c0(%rbp), %rdi
xorl %eax, %eax
callq 0x2260
jmp 0x29c20
movq 0x28(%rax), %rax
movq %rax, -0x60(%rbp)
leaq -0x1c0(%rbp), %rdi
movq %rdx, %rsi
callq 0x2080
movl 0x120(%rbp), %r12d
movslq (%r13), %r13
movl $0x4143, -0x48(%rbp)    # imm = 0x4143
leaq 0x2758b(%rip), %rsi     # 0x511c4
movq %r14, %rdi
callq 0x2180
testl %eax, %eax
jne 0x29c4f
movb $0x0, -0x46(%rbp)
movw $0x4243, -0x48(%rbp)    # imm = 0x4243
movq %r15, -0xf8(%rbp)
movl %ebx, -0x44(%rbp)
movq %rsp, -0x108(%rbp)
movl %r12d, %eax
movq %rsp, %rcx
movq %rax, -0xe0(%rbp)
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xf0(%rbp)
movq %rcx, %rsp
leal (%r12,%r12,2), %eax
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xa0(%rbp)
movq %rcx, %rsp
leaq (,%r13,4), %rdi
callq 0x21d0
movq %rax, -0x90(%rbp)
testl %r13d, %r13d
jle 0x29e41
leaq 0xe0(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x88(%rbp)
leaq 0x10(%rbp), %rax
movq 0x38(%rax), %rcx
movq %rcx, -0xd0(%rbp)
movl (%rax), %eax
movl %eax, -0xb8(%rbp)
xorl %r15d, %r15d
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
xorpd %xmm2, %xmm2
movq $0x0, -0x58(%rbp)
movl $0x0, -0x50(%rbp)
movapd %xmm2, -0x40(%rbp)
movq -0x88(%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 -0x48(%rbp), %rsi
callq 0x2070
testl %eax, %eax
je 0x29d7d
movslq 0x64(%rbx), %rax
shlq $0x5, %rax
movq 0x118(%rbp), %rcx
cmpb $0x47, 0x13(%rcx,%rax)
jne 0x29d73
movl $0x2, %edx
movq %r14, %rdi
leaq 0x2b400(%rip), %rsi     # 0x5516a
callq 0x2070
testl %eax, %eax
je 0x29d7d
movapd -0x40(%rbp), %xmm2
jmp 0x29e33
movslq -0x58(%rbp), %r14
movq -0xf0(%rbp), %rax
movl %r12d, (%rax,%r14,4)
movq -0xd0(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0xb8(%rbp), %edx
movl %r15d, %ecx
movl %r15d, %r8d
callq 0x2a5eb
movq -0xf8(%rbp), %rax
movss %xmm0, (%rax,%r14,4)
xorps %xmm0, %xmm0
cvtss2sd 0x1c(%rbx), %xmm0
divsd 0x2f7d3(%rip), %xmm0    # 0x59598
xorps %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm1
movq -0x90(%rbp), %rax
movss %xmm1, (%rax,%r14,4)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
mulss %xmm1, %xmm1
cvtss2sd %xmm1, %xmm1
movslq -0x50(%rbp), %rax
movq -0xa0(%rbp), %rcx
leaq (%rcx,%rax,4), %rcx
xorl %eax, %eax
xorps %xmm2, %xmm2
cvtsd2ss (%rbx,%rax,8), %xmm2
movss %xmm2, (%rcx,%rax,4)
incq %rax
cmpq $0x3, %rax
jne 0x29df9
movapd -0x80(%rbp), %xmm2
addsd %xmm0, %xmm2
movapd %xmm2, -0x80(%rbp)
movapd -0x40(%rbp), %xmm2
addsd %xmm1, %xmm2
addl %eax, -0x50(%rbp)
movq -0x58(%rbp), %rax
incl %eax
movq %rax, -0x58(%rbp)
incq %r15
cmpq %r13, %r15
jne 0x29d09
jmp 0x29e54
xorpd %xmm2, %xmm2
movq $0x0, -0x58(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
cvtsi2sdl -0x58(%rbp), %xmm3
movapd -0x80(%rbp), %xmm1
divsd %xmm3, %xmm1
movapd 0x27226(%rip), %xmm0    # 0x51090
xorpd %xmm1, %xmm0
ucomisd %xmm0, %xmm1
movq -0xf8(%rbp), %r13
movapd %xmm1, -0x80(%rbp)
jb 0x29e89
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
jmp 0x29eb1
movapd %xmm1, %xmm0
movapd %xmm2, -0x40(%rbp)
movsd %xmm3, -0x88(%rbp)
callq 0x2290
movsd -0x88(%rbp), %xmm3
movapd -0x40(%rbp), %xmm2
movapd -0x80(%rbp), %xmm1
movl -0x44(%rbp), %r12d
movl 0x120(%rbp), %r15d
divsd %xmm3, %xmm2
movapd %xmm2, -0x40(%rbp)
mulsd %xmm1, %xmm1
movapd %xmm1, -0xd0(%rbp)
movq 0x148(%rbp), %rbx
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
leaq 0x2f6ca(%rip), %rdi     # 0x595b2
xorl %r14d, %r14d
leaq -0x48(%rbp), %rdx
movq -0x58(%rbp), %rsi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x20f0
xorps %xmm0, %xmm0
cvtss2sd -0x50(%rbp), %xmm0
leaq 0x2f6cb(%rip), %rdi     # 0x595d7
movsd %xmm0, -0x88(%rbp)
movb $0x1, %al
callq 0x20f0
movl %r14d, -0x64(%rbp)
movl %r14d, -0x94(%rbp)
movq $0x0, -0xac(%rbp)
movl %r14d, -0xa4(%rbp)
testl %r15d, %r15d
jle 0x29f56
movq -0xe0(%rbp), %rax
leaq (,%rax,4), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2110
movl 0x128(%rbp), %esi
movapd -0x40(%rbp), %xmm1
subsd -0xd0(%rbp), %xmm1
movsd 0x2d44f(%rip), %xmm2    # 0x573c0
movapd -0x80(%rbp), %xmm0
ucomisd %xmm0, %xmm2
movq -0xd8(%rbp), %r14
jbe 0x29fd8
leaq 0x2f676(%rip), %rdi     # 0x59600
movb $0x2, %al
callq 0x20f0
movq -0x90(%rbp), %rdi
callq 0x2050
xorpd %xmm2, %xmm2
movsd 0x2c147(%rip), %xmm0    # 0x560f0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq $0x0, -0xd0(%rbp)
leaq 0x10(%rbp), %rax
jmp 0x2a156
testl %esi, %esi
jne 0x29f83
ucomisd %xmm1, %xmm2
ja 0x29f83
leaq -0x150(%rbp), %r14
movl $0x0, (%r14)
leaq -0x94(%rbp), %r15
movq %r13, %rdi
movq -0x90(%rbp), %r12
movq %r12, %rsi
movq -0x58(%rbp), %rbx
movl %ebx, %edx
movq %r15, %rcx
movq %r14, %r8
callq 0x10d91
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd (%r14), %xmm1
xorps %xmm3, %xmm3
cvtss2sd (%r15), %xmm3
movl 0x120(%rbp), %r15d
movsd 0x27008(%rip), %xmm2    # 0x51040
divsd %xmm3, %xmm2
leaq 0x2f5f0(%rip), %rdi     # 0x59633
movb $0x3, %al
callq 0x20f0
leaq 0x2fa12(%rip), %rdi     # 0x59a63
callq 0x2090
movslq %r15d, %rdi
shlq $0x2, %rdi
callq 0x21d0
leaq -0x64(%rbp), %rdi
leaq -0xac(%rbp), %r14
movq 0x148(%rbp), %rsi
movq %r14, %rdx
movq %rax, %rcx
movq %rax, -0xd0(%rbp)
movq %r12, %r8
movq %r13, %r9
pushq $0x43
pushq 0x138(%rbp)
pushq %rbx
pushq -0xa0(%rbp)
callq 0x2a669
addq $0x20, %rsp
movss %xmm0, -0x80(%rbp)
cvtss2sd %xmm0, %xmm0
leaq 0x2f5bf(%rip), %rdi     # 0x5966e
movsd %xmm0, -0x40(%rbp)
movb $0x1, %al
callq 0x20f0
movss -0x50(%rbp), %xmm0
mulss %xmm0, %xmm0
mulss (%r14), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x2a0da
xorps %xmm3, %xmm3
sqrtss %xmm0, %xmm3
jmp 0x2a0e2
callq 0x21c0
movaps %xmm0, %xmm3
movl -0x44(%rbp), %r12d
movss -0x64(%rbp), %xmm0
leaq 0x3efd6(%rip), %rax     # 0x690c8
movss (%rax), %xmm1
ucomiss %xmm0, %xmm1
movq -0xd8(%rbp), %r14
movss -0x80(%rbp), %xmm2
ja 0x2a117
leaq 0x3efbe(%rip), %rax     # 0x690cc
movss (%rax), %xmm1
ucomiss %xmm2, %xmm1
jbe 0x2a146
cvtss2sd %xmm0, %xmm0
leaq 0x2f583(%rip), %rdi     # 0x596a5
movsd -0x40(%rbp), %xmm1
movb $0x2, %al
movss %xmm3, -0x40(%rbp)
callq 0x20f0
movss -0x40(%rbp), %xmm3
movss -0x80(%rbp), %xmm2
movl %r12d, %eax
sarl $0x1f, %eax
andl %eax, %r12d
leaq 0x10(%rbp), %rax
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
movsd %xmm0, -0x50(%rbp)
movq 0x140(%rbp), %rbx
xorpd %xmm1, %xmm1
ucomiss %xmm1, %xmm2
movss %xmm2, -0x80(%rbp)
jne 0x2a16d
jnp 0x2a184
movss -0x94(%rbp), %xmm0
divss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jb 0x2a18e
sqrtss %xmm0, %xmm0
jmp 0x2a19c
movss 0x26e78(%rip), %xmm0    # 0x51004
jmp 0x2a19c
callq 0x21c0
movss -0x80(%rbp), %xmm2
leaq 0x10(%rbp), %rax
movss %xmm0, (%rbx)
movslq (%rax), %rax
xorpd %xmm3, %xmm3
testq %rax, %rax
jle 0x2a1cf
xorl %ecx, %ecx
xorps %xmm0, %xmm0
movq -0x60(%rbp), %rdx
movss (%rdx,%rcx,4), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x2a1c7
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm3
incq %rcx
cmpq %rcx, %rax
jne 0x2a1b5
testl %r12d, %r12d
setle %al
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
setbe %cl
orb %al, %cl
movsd %xmm3, -0x60(%rbp)
jne 0x2a23b
movss 0x26e21(%rip), %xmm3    # 0x51010
divss %xmm2, %xmm3
movss %xmm3, -0x40(%rbp)
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
leaq 0x3ee72(%rip), %rax     # 0x69078
movss (%rax), %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
mulss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x3ee60(%rip), %rax     # 0x69080
movsd (%rax), %xmm3
mulsd %xmm0, %xmm3
leaq 0x2f4a9(%rip), %rdi     # 0x596d8
movb $0x4, %al
callq 0x20f0
jmp 0x2a2f5
testl %r12d, %r12d
js 0x2a27c
leaq 0x3ee31(%rip), %rax     # 0x69078
xorps %xmm1, %xmm1
cvtss2sd (%rax), %xmm1
leaq 0x3ee2b(%rip), %rax     # 0x69080
movsd (%rax), %xmm3
leaq 0x2f501(%rip), %rdi     # 0x59761
movsd 0x26dd8(%rip), %xmm0    # 0x51040
movaps %xmm1, %xmm2
movb $0x4, %al
callq 0x20f0
movss 0x26d96(%rip), %xmm1    # 0x51010
jmp 0x2a2fa
leaq 0x3ee4d(%rip), %rax     # 0x690d0
movss (%rax), %xmm4
leaq 0xe0(%rbp), %rax
movss 0x8(%rax), %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 0x3edb7(%rip), %rax     # 0x69078
movss (%rax), %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
mulss %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x3eda5(%rip), %rax     # 0x69080
movsd (%rax), %xmm3
mulsd %xmm0, %xmm3
cvtss2sd %xmm4, %xmm4
leaq 0x2f42d(%rip), %rdi     # 0x5971b
movb $0x5, %al
callq 0x20f0
movss -0x40(%rbp), %xmm1
movss %xmm1, -0x40(%rbp)
leaq 0xe0(%rbp), %rax
movss 0x8(%rax), %xmm0
mulss %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd -0x60(%rbp), %xmm0
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2a32f
sqrtsd %xmm0, %xmm0
jmp 0x2a334
callq 0x2290
cvtsd2ss %xmm0, %xmm0
movq -0xe8(%rbp), %rax
movss %xmm0, (%rax)
cvtss2sd %xmm0, %xmm0
leaq 0x2f45a(%rip), %rdi     # 0x597a8
movb $0x1, %al
callq 0x20f0
leaq 0x3ce3c(%rip), %rax     # 0x67198
movss (%rax), %xmm0
movss -0xb0(%rbp), %xmm3
movaps %xmm3, %xmm1
testl %r12d, %r12d
jg 0x2a373
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, -0xb4(%rbp)
je 0x2a3b6
movups 0x2f43c(%rip), %xmm0    # 0x597db
movups %xmm0, 0x10(%r14)
movups 0x2f420(%rip), %xmm0    # 0x597cb
movups %xmm0, (%r14)
movb $0x0, 0x20(%r14)
jmp 0x2a3cd
movups 0x2f43e(%rip), %xmm0    # 0x597fb
movups %xmm0, 0xf(%r14)
movups 0x2f423(%rip), %xmm0    # 0x597ec
movups %xmm0, (%r14)
movss -0x64(%rbp), %xmm0
movss %xmm0, -0xa0(%rbp)
cvtss2sd %xmm0, %xmm0
leaq 0x2f426(%rip), %rsi     # 0x5980b
leaq -0x150(%rbp), %rbx
movq %rbx, %rdi
movb $0x1, %al
callq 0x2260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2240
xorps %xmm0, %xmm0
cvtss2sd -0x40(%rbp), %xmm0
leaq 0x2f417(%rip), %rsi     # 0x59827
movq %rbx, %rdi
movsd %xmm0, -0x60(%rbp)
movb $0x1, %al
callq 0x2260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2240
leaq 0x2f412(%rip), %rsi     # 0x59843
movq %rbx, %rdi
movsd -0x88(%rbp), %xmm0
movb $0x1, %al
callq 0x2260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2240
leaq 0x2f410(%rip), %rsi     # 0x59865
movq %rbx, %rdi
movsd -0x50(%rbp), %xmm0
movb $0x1, %al
callq 0x2260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2240
movq -0xe8(%rbp), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax), %xmm0
leaq 0x2f408(%rip), %rsi     # 0x5988c
movq %rbx, %rdi
movb $0x1, %al
callq 0x2260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2240
xorps %xmm0, %xmm0
cvtss2sd -0xac(%rbp), %xmm0
leaq 0x2f3fd(%rip), %rsi     # 0x598a8
movq %rbx, %rdi
movb $0x1, %al
callq 0x2260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2240
xorps %xmm0, %xmm0
cvtss2sd -0xa8(%rbp), %xmm0
leaq 0x2f3f2(%rip), %rsi     # 0x598c4
movq %rbx, %rdi
movb $0x1, %al
callq 0x2260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2240
xorps %xmm0, %xmm0
cvtss2sd -0xa4(%rbp), %xmm0
leaq 0x2f3e7(%rip), %rsi     # 0x598e0
movq %rbx, %rdi
movb $0x1, %al
callq 0x2260
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2240
movss -0x40(%rbp), %xmm1
testl %r15d, %r15d
movq -0xe0(%rbp), %rcx
jle 0x2a53b
xorl %eax, %eax
movss (%r13,%rax,4), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%r13,%rax,4)
incq %rax
cmpq %rax, %rcx
jne 0x2a521
subq $0x8, %rsp
leaq -0xac(%rbp), %rax
leaq 0x2f3af(%rip), %r10     # 0x598fc
leaq -0x1c0(%rbp), %r11
movq %r13, %rdi
movq -0xd0(%rbp), %r14
movq %r14, %rsi
movq -0x90(%rbp), %rbx
movq %rbx, %rdx
movq -0x58(%rbp), %rcx
movq 0x130(%rbp), %r8
movq -0xf0(%rbp), %r9
movss -0xa0(%rbp), %xmm0
movss -0x80(%rbp), %xmm1
pushq $0x43
pushq %rax
pushq %r10
pushq %r11
pushq 0x118(%rbp)
callq 0x290c8
addq $0x30, %rsp
testq %rbx, %rbx
je 0x2a5ad
movq %rbx, %rdi
callq 0x2050
testq %r14, %r14
je 0x2a5ba
movq %r14, %rdi
callq 0x2050
leaq 0x2f341(%rip), %rdi     # 0x59902
movl %r12d, %esi
movsd -0x60(%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