// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/confchange.c
// Function: Mode_confchange_fit
int Mode_confchange_fit(struct Tors *Diff, struct Normal_Mode *NM,
			struct bond *bonds, atom *atoms, int natoms,
			struct Reference Ref, struct residue *seq,
			float *coord_1, float *coord_2, float M_sqrt,
			char *nameout, char *name_pdb, int type, int NMODES)
{
  int nround=1, nreduce=0, itmax, i, j, k, num_mod=0;
  float STEP_MAX=0.15, STEP_MIN=0.001, TOL=0.1, TOL2=0.000;
  float c_max=STEP_MAX*M_sqrt, c_thr=STEP_MIN*M_sqrt;

  idum=randomgenerator();
  InitRandom((RANDOMTYPE)idum);
  float gasdev(long *idum);
  float rmsd_ini=rmsd_mclachlan_f(coord_1,coord_2,Ref.mass_atom,Ref.N_ref);

  char out[100]; sprintf(out, "%s.mode_confchange.dat", nameout);
  printf("Writing %s\n", out);
  FILE *file_out=fopen(out, "w");
  sprintf(out, "%s.mode_confchange.pdb", nameout);
  printf("Writing %s\n", out);
  FILE *file_pdb=fopen(out, "w");
  char what[100];
  sprintf(what, "Torsional conformations, norm. modes ranked by"); 
  if(type){strcat(what, " overlap");}
  else{strcat(what, " frequency");}
  fprintf(file_out, "# %s\n", what);
  fprintf(file_out,"#1=rmsd_min 2=rmsd_tar 3=mode 4=c_alpha\n");
  fprintf(file_out, "%.3g\t%.3g\t0\t0\n",rmsd_ini,rmsd_ini);

  int naxes=NM->N_axes, ncoord=NM->N_Cart;
  double d_phi_opt[naxes], d_phi[naxes], d_phi_best[naxes];
  float coord_new[ncoord], coord_step[ncoord], coord_all[3*natoms];
  float D_coord[ncoord];   
  float sigma[NM->N]; for(int i=0; i<NM->N; i++)sigma[i]=sqrt(NM->sigma2[i]);
  for(i=0; i<naxes; i++)d_phi_opt[i]=0;
  for(i=0; i<ncoord; i++){
    coord_step[i]=coord_1[i];
    D_coord[i]=coord_2[i]-coord_step[i];
  }
  
  int jmode[NM->N]; float c_lin[NM->N];
  if(type==0){
    for(k=0; k<NMODES; k++){
      jmode[k]=k;
      c_lin[k]=Scalar_product_weighted(D_coord, NM->Cart[k],
				       Ref.mass_coord, ncoord);
    }
  }else{
    for (i=0; i<NM->N; i++){
      c_lin[i]=Scalar_product_weighted(D_coord, NM->Cart[i],
				       Ref.mass_coord, ncoord);
    }
    // Rank the modes by the correlation with conf.change
    int done[NM->N]; for(k=0; k<NM->N; k++)done[k]=0;
    for(i=0; i<NMODES; i++)jmode[i]=-1;
    for(i=0; i<NMODES; i++){
      int kj=-1; float cmax=0;
      for(k=0; k<NM->N; k++){
	if(done[k])continue;
	if(kj<0 || fabs(c_lin[k])>fabs(cmax)){kj=k; cmax=c_lin[k];}
      }
      if(cmax==0 || kj<0)break;
      done[kj]=1;
      jmode[i]=kj;
    }
  }

  int NMOD1=NMODES-1, accept=1, random=0;
  float score_opt=-1000, score_old=-1000, score_best=-1000,
    tol, rfact=0.5, yy, cc=0;

  for(int round=0; round<nround; round++){

    int done[NMODES], kj;
    if(random){tol=TOL; itmax=NMODES*0.5;}
    else{tol=0; for(i=0; i<NMODES; i++)done[i]=0; itmax=10*NMODES;}

    for(int iter=0; iter<=itmax; iter++){

      // Full reconstruction, optimize the coefficient
      // Determine mode (kj) and coefficient (cc)
      if(random){
	int j=NMODES*RandomFloating(); if(j>NMOD1)j=NMOD1;
	kj=jmode[j]; if(kj<0)continue;
	cc=gasdev(&idum)*sigma[kj]*rfact;
      }else{ // Minimization
	kj=-1; cc=0;
	for(j=0; j<NMODES; j++){
	  k=jmode[j]; if(k<0 || done[k])continue;
	  if(kj<0 || fabs(c_lin[k])>fabs(cc)){kj=k; cc=c_lin[k];}
	}
	if(kj<0 || fabs(cc)<c_thr){
	  fprintf(file_out,"# Too small max. rmsd: %.2g mode=%d\n",
		  STEP_MIN, kj);
	  break;
	}
      }

      // Compute RMSD
      if(fabs(cc)>c_max){if(cc>0){cc=c_max;}else{cc=-c_max;}}
      for(int j=0; j<=nreduce; j++){
	yy=-RMSD_confchange(cc, NM->Tors[kj], d_phi, coord_all,
			    coord_new, d_phi_opt, naxes, bonds,atoms,
			    natoms,Ref,coord_2);
	fprintf(file_out, "%.3g\t%.3g\t%d\t%.3g\n",-score_opt,-yy,kj,cc);

	// Test if improvement
	if(yy>score_opt-tol){
	  accept=1; score_old=score_opt; score_opt=yy; 
	  for(i=0; i<naxes; i++)d_phi_opt[i]=d_phi[i];
	  break;
	}else{accept=0; cc/=2; done[kj]=1;}

      }

      if(accept==0)continue;
      
      // Update structure
      for(i=0; i<ncoord; i++){
	coord_step[i]=coord_new[i];
	D_coord[i]=coord_2[i]-coord_new[i];
      }
      for(i=0; i<NMODES; i++){
	k=jmode[i];
	c_lin[k]=Scalar_product_weighted(D_coord, NM->Cart[k],
					 Ref.mass_coord, ncoord);
      } 
      if(yy>score_best){
	score_best=yy; 
	for(i=0; i<naxes; i++)d_phi_best[i]=d_phi[i];
      }

      if(fabs(score_old-score_opt)<TOL2 && random==0){
	fprintf(file_out, "# RMSD does not improve, %.4g -> %.4g\n",
		score_old, score_opt);
	done[kj]=1;
      }
    } // end iter
    if(random){random=0; rfact/=2;}else{random=1;}
  } // end round


  yy=-RMSD_confchange(0, NM->Tors[0], d_phi, coord_all, coord_new,
		      d_phi_best, naxes, bonds,atoms, natoms,Ref,coord_2);
  fprintf(file_out, "&\n");
  fprintf(file_out, "# %d modes min. RMSD=%.3f\n", NMODES, -yy);
    
  fclose(file_out);

  num_mod++;
  fprintf(file_pdb, "MODEL %d\n", num_mod);
  fprintf(file_pdb, "REMARK %s\n", what);
  fprintf(file_pdb, "REMARK RMSD from target: %.2f\n", -score_opt);
  fprintf(file_pdb, "REMARK  The fitted conformation change is ");
  fprintf(file_pdb, "obtained with %d normal modes\n", NMODES);
  float coord_all_1[3*natoms], *c=coord_all_1, mass[natoms];
  for(i=0; i<natoms; i++){
    mass[i]=1;
    double *r=atoms[i].r; for(k=0; k<3; k++){*c=*r; c++; r++;}
  }
  float rmsd=rmsd_mclachlan_f(coord_all_1, coord_all, mass, natoms);
  rmsd=rmsd_mclachlan_f(coord_1,coord_new,Ref.mass_atom,Ref.N_ref);
  Print_PDB(file_pdb, atoms, natoms, coord_all, seq, num_mod, rmsd);
  fclose(file_pdb);

  return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movss %xmm0, -0x48(%rbp)
movq %r9, -0x140(%rbp)
movq %r8, -0x78(%rbp)
movq %rcx, -0x70(%rbp)
movq %rdx, -0xf8(%rbp)
movq %rsi, -0x30(%rbp)
movl 0x60(%rbp), %r13d
movq 0x48(%rbp), %r15
movq 0x40(%rbp), %r14
movq 0x50(%rbp), %rbx
callq 0x32a14
movq %rax, %rdi
callq 0x503ac
movq 0x20(%rbp), %rdx
movl 0x10(%rbp), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rdx, -0x138(%rbp)
movl %ecx, -0xb4(%rbp)
callq 0x4dfa0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x38(%rbp)
leaq 0x2a986(%rip), %rsi     # 0x5aaaa
leaq -0x250(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x21c10(%rip), %r15     # 0x51d4f
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x270ad(%rip), %r12     # 0x57200
movq %r14, %rdi
movq %r12, %rsi
callq 0x2220
movq %rax, -0x68(%rbp)
leaq 0x2a958(%rip), %rsi     # 0x5aac1
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2270
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x20f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x2220
movq %rax, %r15
movups 0x2a95f(%rip), %xmm0    # 0x5aaf7
leaq -0x1e0(%rbp), %rdi
movups %xmm0, 0x1f(%rdi)
movups 0x2a93e(%rip), %xmm0    # 0x5aae8
movaps %xmm0, 0x10(%rdi)
movups 0x2a923(%rip), %xmm0    # 0x5aad8
movaps %xmm0, (%rdi)
callq 0x20d0
addq %rbp, %rax
addq $-0x1e0, %rax           # imm = 0xFE20
testl %r13d, %r13d
je 0x301de
movabsq $0x70616c7265766f20, %rcx # imm = 0x70616C7265766F20
movq %rcx, (%rax)
movb $0x0, 0x8(%rax)
jmp 0x301f2
movabsq $0x6e65757165726620, %rcx # imm = 0x6E65757165726620
movq %rcx, (%rax)
movl $0x79636e, 0x7(%rax)    # imm = 0x79636E
leaq 0x29f65(%rip), %rsi     # 0x5a15e
leaq -0x1e0(%rbp), %rdx
movq -0x68(%rbp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21a0
leaq 0x2a8fd(%rip), %rdi     # 0x5ab12
movl $0x28, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2290
xorps %xmm0, %xmm0
cvtss2sd -0x38(%rbp), %xmm0
leaq 0x2a9f5(%rip), %rsi     # 0x5ac2b
movq %rbx, %rdi
movaps %xmm0, %xmm1
movb $0x2, %al
callq 0x21a0
movq %rsp, -0x128(%rbp)
movq -0x30(%rbp), %rsi
movl 0x8(%rsi), %eax
movl 0xc(%rsi), %r8d
movq %rsp, %rcx
movq %rax, -0x58(%rbp)
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xa0(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x80(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xe8(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
leaq 0xf(,%r8,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x88(%rbp)
movq %rcx, %rsp
movq -0x78(%rbp), %rcx
leal (%rcx,%rcx,2), %ecx
leaq 0xf(,%rcx,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
movq %rdx, -0x120(%rbp)
subq %rdx, %rcx
movq %rcx, -0x98(%rbp)
movq %rcx, %rsp
movq %rsp, %rdi
subq %rax, %rdi
movq %rdi, %rsp
movl (%rsi), %r12d
testl %r12d, %r12d
movq 0x48(%rbp), %rdx
movq %r8, -0x38(%rbp)
movq %rdi, -0x50(%rbp)
jle 0x3032b
xorl %ebx, %ebx
xorps %xmm1, %xmm1
movq 0x28(%rsi), %rax
movss (%rax,%rbx,4), %xmm0
ucomiss %xmm1, %xmm0
jae 0x30320
callq 0x21d0
xorps %xmm1, %xmm1
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %rsi
movq 0x48(%rbp), %rdx
incq %rbx
movslq (%rsi), %r12
cmpq %r12, %rbx
jl 0x302fa
movq -0x58(%rbp), %rax
testl %eax, %eax
jle 0x30359
leaq (,%rax,8), %rdx
movq -0xa0(%rbp), %rdi
xorl %esi, %esi
callq 0x2110
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %rsi
movq 0x48(%rbp), %rdx
movq %r15, -0x130(%rbp)
testl %r8d, %r8d
movq 0x40(%rbp), %rcx
jle 0x30382
xorl %eax, %eax
movss (%rdx,%rax,4), %xmm0
subss (%rcx,%rax,4), %xmm0
movss %xmm0, (%rdi,%rax,4)
incq %rax
cmpq %rax, %r8
jne 0x3036b
movl %r12d, %eax
movq %rsp, %rbx
leaq 0xf(,%rax,4), %rcx
andq $-0x10, %rcx
subq %rcx, %rbx
movq %rbx, %rsp
movq %rsp, %r9
subq %rcx, %r9
movq %r9, %rsp
movl 0x68(%rbp), %ecx
movl %ecx, %r15d
testl %r13d, %r13d
movq %r9, -0x40(%rbp)
je 0x304d5
testl %r12d, %r12d
jle 0x303fc
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %r12
xorl %r13d, %r13d
movq 0x38(%rsi), %rax
movq (%rax,%r13,8), %rsi
movq -0x50(%rbp), %rdi
movq %r12, %rdx
movl %r8d, %ecx
callq 0x107c4
movq -0x40(%rbp), %r9
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %rsi
movss %xmm0, (%r9,%r13,4)
incq %r13
movslq (%rsi), %rax
cmpq %rax, %r13
jl 0x303c6
movl %eax, %eax
movq %rsp, -0xe0(%rbp)
movq %rsp, %r12
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movl (%rsi), %r13d
testl %r13d, %r13d
jle 0x3043a
leaq (,%r13,4), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2110
movq -0x40(%rbp), %r9
movq -0x30(%rbp), %rsi
movl 0x68(%rbp), %eax
testl %eax, %eax
jle 0x304cc
leaq (,%r15,4), %rdx
movq %rbx, %rdi
movl $0xff, %esi
callq 0x2110
movq -0x40(%rbp), %r9
movq -0x30(%rbp), %rsi
xorl %eax, %eax
movaps 0x26e75(%rip), %xmm0    # 0x572e0
xorps %xmm1, %xmm1
testl %r13d, %r13d
jle 0x304cc
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorps %xmm2, %xmm2
xorl %edx, %edx
cmpl $0x0, (%r12,%rdx,4)
jne 0x304a4
movss (%r9,%rdx,4), %xmm3
testl %ecx, %ecx
js 0x3049f
movaps %xmm3, %xmm4
andps %xmm0, %xmm4
movaps %xmm2, %xmm5
andps %xmm0, %xmm5
ucomiss %xmm5, %xmm4
jbe 0x304a4
movl %edx, %ecx
movaps %xmm3, %xmm2
incq %rdx
cmpq %rdx, %r13
jne 0x3047d
ucomiss %xmm1, %xmm2
jne 0x304b3
jnp 0x304cc
testl %ecx, %ecx
js 0x304cc
movl %ecx, %edx
movl $0x1, (%r12,%rdx,4)
movl %ecx, (%rbx,%rax,4)
incq %rax
cmpq %r15, %rax
jne 0x3046e
movq -0xe0(%rbp), %rsp
jmp 0x30519
testl %ecx, %ecx
jle 0x30519
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %r12
xorl %r13d, %r13d
movl %r13d, (%rbx,%r13,4)
movq 0x38(%rsi), %rax
movq (%rax,%r13,8), %rsi
movq -0x50(%rbp), %rdi
movq %r12, %rdx
movl %r8d, %ecx
callq 0x107c4
movq -0x40(%rbp), %r9
movq -0x38(%rbp), %r8
movq -0x30(%rbp), %rsi
movss %xmm0, (%r9,%r13,4)
incq %r13
cmpq %r13, %r15
jne 0x304e4
movq %rsp, -0x118(%rbp)
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x148(%rbp)
movq %rsp, %rdi
leaq 0xf(,%r15,4), %rax
andq $-0x10, %rax
subq %rax, %rdi
movq %rdi, %rsp
movl 0x68(%rbp), %r12d
testl %r12d, %r12d
movq %rdi, -0x60(%rbp)
jle 0x30572
leaq (,%r15,4), %rdx
xorl %esi, %esi
callq 0x2110
movq -0x60(%rbp), %rdi
movq -0x40(%rbp), %r9
movq -0x30(%rbp), %rsi
movq -0x58(%rbp), %r13
jmp 0x3057c
movq -0x58(%rbp), %r13
js 0x30b28
movss 0x29758(%rip), %xmm3    # 0x59cdc
movss -0x48(%rbp), %xmm0
mulss %xmm0, %xmm3
mulss 0x2974b(%rip), %xmm0    # 0x59ce0
movss %xmm0, -0x48(%rbp)
leal (%r12,%r12), %eax
leal (%rax,%rax,4), %eax
movaps 0x20a88(%rip), %xmm0    # 0x51030
xorps %xmm3, %xmm0
movaps %xmm0, -0x160(%rbp)
leaq (,%r13,8), %rcx
movq %rcx, -0xf0(%rbp)
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
movl %eax, -0xb8(%rbp)
movss 0x29482(%rip), %xmm0    # 0x59a58
movaps 0x26d03(%rip), %xmm4    # 0x572e0
movss %xmm0, -0x44(%rbp)
movaps %xmm0, -0xd0(%rbp)
movaps %xmm3, -0x110(%rbp)
movq %rbx, -0x90(%rbp)
movq %r15, -0xb0(%rbp)
testl %r12d, %r12d
jle 0x308d6
xorps %xmm0, %xmm0
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %eax, %eax
movslq (%rbx,%rax,4), %rcx
testq %rcx, %rcx
js 0x30643
cmpl $0x0, (%rdi,%rcx,4)
jne 0x30643
movss (%r9,%rcx,4), %xmm5
testl %r12d, %r12d
js 0x3063d
movaps %xmm5, %xmm1
andps %xmm4, %xmm1
movaps %xmm0, %xmm2
andps %xmm4, %xmm2
ucomiss %xmm2, %xmm1
jbe 0x30643
movaps %xmm5, %xmm0
movl %ecx, %r12d
incq %rax
cmpq %rax, %r15
jne 0x30612
testl %r12d, %r12d
js 0x308dc
movaps %xmm0, %xmm2
andps %xmm4, %xmm2
movss -0x48(%rbp), %xmm1
ucomiss %xmm2, %xmm1
ja 0x308dc
ucomiss %xmm3, %xmm2
movq %rdx, -0xa8(%rbp)
jbe 0x30687
ucomiss 0x20a9d(%rip), %xmm0    # 0x51118
movaps %xmm3, %xmm0
ja 0x30687
movaps -0x160(%rbp), %xmm0
movaps %xmm0, -0x170(%rbp)
movl %r12d, %ecx
movaps -0xd0(%rbp), %xmm2
movaps 0x20991(%rip), %xmm1    # 0x51030
xorps %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
movsd %xmm1, -0x150(%rbp)
movq 0x40(%rsi), %rax
movq %rcx, %r14
movq (%rax,%rcx,8), %rdi
subq $0x50, %rsp
leaq 0x10(%rbp), %rax
movups (%rax), %xmm3
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x38(%rsp)
movups %xmm1, 0x28(%rsp)
movups %xmm3, 0x18(%rsp)
movq 0x48(%rbp), %rax
movq %rax, 0x48(%rsp)
movq -0x78(%rbp), %rax
movl %eax, 0x10(%rsp)
movq -0x70(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0xf8(%rbp), %rax
movq %rax, (%rsp)
movq -0x80(%rbp), %rsi
movq -0x98(%rbp), %rdx
movq -0x88(%rbp), %rcx
movq -0xa0(%rbp), %r8
movl %r13d, %r9d
callq 0x30b3c
addq $0x50, %rsp
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
xorps 0x208fa(%rip), %xmm0    # 0x51030
movaps %xmm0, -0xe0(%rbp)
xorps %xmm2, %xmm2
cvtss2sd -0x170(%rbp), %xmm2
movq -0x68(%rbp), %rdi
leaq 0x2a4ea(%rip), %rsi     # 0x5ac3d
movsd -0x150(%rbp), %xmm0
movl %r12d, %edx
movb $0x3, %al
callq 0x21a0
movaps -0xe0(%rbp), %xmm0
ucomiss -0xd0(%rbp), %xmm0
ja 0x30792
movq -0x60(%rbp), %rdi
movl $0x1, (%rdi,%r14,4)
movq -0x30(%rbp), %rsi
movl 0x68(%rbp), %r12d
movq -0x40(%rbp), %r9
jmp 0x308ae
testl %r13d, %r13d
movl 0x68(%rbp), %r14d
jle 0x307b2
movq -0xa0(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0xf0(%rbp), %rdx
callq 0x21b0
movq -0x38(%rbp), %r8
testl %r8d, %r8d
movq 0x48(%rbp), %rcx
movq -0x88(%rbp), %rdx
movq -0x50(%rbp), %rsi
jle 0x307e3
xorl %eax, %eax
movss (%rcx,%rax,4), %xmm0
subss (%rdx,%rax,4), %xmm0
movss %xmm0, (%rsi,%rax,4)
incq %rax
cmpq %rax, %r8
jne 0x307cc
testl %r14d, %r14d
movq -0x30(%rbp), %rbx
movq -0x90(%rbp), %r13
movq -0x148(%rbp), %r15
jle 0x30836
xorl %r12d, %r12d
movslq (%r13,%r12,4), %r14
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rsi
movq -0x50(%rbp), %rdi
movq %r15, %rdx
movl %r8d, %ecx
callq 0x107c4
movq -0xb0(%rbp), %rsi
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %r8
movss %xmm0, (%rax,%r14,4)
incq %r12
cmpq %r12, %rsi
jne 0x307fd
movq -0x58(%rbp), %r13
testl %r13d, %r13d
setle %al
movss -0x44(%rbp), %xmm1
movaps -0xe0(%rbp), %xmm2
ucomiss %xmm1, %xmm2
setbe %cl
orb %al, %cl
je 0x30866
movaps %xmm2, %xmm0
maxss %xmm1, %xmm0
movaps %xmm2, -0xd0(%rbp)
jmp 0x3088b
movq -0xe8(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0xf0(%rbp), %rdx
callq 0x21b0
movaps -0xe0(%rbp), %xmm0
movaps %xmm0, -0xd0(%rbp)
movss %xmm0, -0x44(%rbp)
movq -0x30(%rbp), %rsi
movl 0x68(%rbp), %r12d
movq -0x40(%rbp), %r9
movq -0x90(%rbp), %rbx
movq -0xb0(%rbp), %r15
movq -0x60(%rbp), %rdi
movaps -0x110(%rbp), %xmm3
movq -0xa8(%rbp), %rcx
movaps 0x26a1d(%rip), %xmm4    # 0x572e0
leal 0x1(%rcx), %eax
cmpl -0xb8(%rbp), %ecx
movl %eax, %edx
jne 0x305fe
jmp 0x30901
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
leaq 0x2a258(%rip), %rsi     # 0x5ab3b
movsd 0x293cd(%rip), %xmm0    # 0x59cb8
movq -0x68(%rbp), %rdi
movl %r12d, %edx
movb $0x1, %al
callq 0x21a0
movq -0x30(%rbp), %rsi
movl 0x68(%rbp), %r12d
movq -0x118(%rbp), %rsp
movq 0x40(%rsi), %rax
movq (%rax), %rdi
subq $0x50, %rsp
leaq 0x10(%rbp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x38(%rsp)
movups %xmm1, 0x28(%rsp)
movups %xmm0, 0x18(%rsp)
movq 0x48(%rbp), %rax
movq %rax, 0x48(%rsp)
movq -0x78(%rbp), %r14
movl %r14d, 0x10(%rsp)
movq -0x70(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0xf8(%rbp), %rax
movq %rax, (%rsp)
xorps %xmm0, %xmm0
movq -0x80(%rbp), %rsi
movq -0x98(%rbp), %rdx
movq -0x88(%rbp), %rcx
movq -0xe8(%rbp), %r8
movl %r13d, %r9d
callq 0x30b3c
addq $0x50, %rsp
movss %xmm0, -0x38(%rbp)
leaq 0x27760(%rip), %rdi     # 0x580eb
movl $0x2, %esi
movl $0x1, %edx
movq -0x68(%rbp), %rbx
movq %rbx, %rcx
callq 0x2290
xorps %xmm0, %xmm0
cvtss2sd -0x38(%rbp), %xmm0
leaq 0x2a1b0(%rip), %rsi     # 0x5ab60
movq %rbx, %rdi
movl %r12d, %edx
movb $0x1, %al
callq 0x21a0
movq %rbx, %rdi
callq 0x20c0
leaq 0x28847(%rip), %rsi     # 0x59213
movq -0x130(%rbp), %r15
movq %r15, %rdi
movl $0x1, %edx
xorl %eax, %eax
callq 0x21a0
leaq 0x2a192(%rip), %rsi     # 0x5ab7b
leaq -0x1e0(%rbp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x21a0
movaps -0xd0(%rbp), %xmm0
xorps 0x20628(%rip), %xmm0    # 0x51030
cvtss2sd %xmm0, %xmm0
leaq 0x2a173(%rip), %rsi     # 0x5ab86
movq %r15, %rdi
movb $0x1, %al
callq 0x21a0
leaq 0x2a181(%rip), %rdi     # 0x5aba5
movl $0x2a, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2290
leaq 0x2a193(%rip), %rsi     # 0x5abd0
movq %r15, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0x21a0
movq %rsp, %rdi
subq -0x120(%rbp), %rdi
movq %rdi, %rsp
movl %r14d, %eax
movq %rsp, %rdx
leaq 0xf(,%rax,4), %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, %rsp
testl %r14d, %r14d
movq 0x40(%rbp), %rbx
jle 0x30ab3
xorl %ecx, %ecx
movq -0x70(%rbp), %rsi
movq %rdi, %r8
movl $0x3f800000, (%rdx,%rcx,4) # imm = 0x3F800000
xorl %r9d, %r9d
xorps %xmm0, %xmm0
cvtsd2ss (%rsi,%r9,2), %xmm0
movss %xmm0, (%r8,%r9)
addq $0x4, %r9
cmpl $0xc, %r9d
jne 0x30a8b
incq %rcx
addq $0x70, %rsi
addq %r9, %r8
cmpq %rax, %rcx
jne 0x30a81
movq -0x98(%rbp), %r12
movq %r12, %rsi
movq -0x78(%rbp), %r14
movl %r14d, %ecx
callq 0x4dfa0
movq %rbx, %rdi
movq -0x88(%rbp), %rsi
movq -0x138(%rbp), %rdx
movl -0xb4(%rbp), %ecx
callq 0x4dfa0
cvtsd2ss %xmm0, %xmm0
movq %r15, %rdi
movq -0x70(%rbp), %rsi
movl %r14d, %edx
movq %r12, %rcx
movq -0x140(%rbp), %r8
movl $0x1, %r9d
callq 0x3285f
movq %r15, %rdi
callq 0x20c0
movq -0x128(%rbp), %rsp
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movss 0x28f28(%rip), %xmm0    # 0x59a58
movaps %xmm0, -0xd0(%rbp)
jmp 0x30901