// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/confchange.c
// Function: Mode_confchange_old
int Mode_confchange_old(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 NMODES_CC=10, nround=1, itmax=10, nreduce=4, i, j, k, num_mod=0;
  float STEP_MAX=0.4, c_thr=0.02*M_sqrt, TOL=0.04, TOL2=0.01;
  float c_max=STEP_MAX*M_sqrt;
  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");

  float rmsd_ini=rmsd_mclachlan_f(coord_1,coord_2,Ref.mass_atom,Ref.N_ref);
  int naxes=NM->N_axes, ncoord=NM->N_Cart;
  double d_phi_opt[naxes], d_phi[naxes];
  float coord_new[ncoord], coord_step[ncoord], coord_all[3*natoms];
  float D_coord[ncoord];   int done[NM->N];
  float gasdev(long *idum);
  float sigma[NM->N]; for(int i=0; i<NM->N; i++)sigma[i]=sqrt(NM->sigma2[i]);
  idum=randomgenerator();
  InitRandom((RANDOMTYPE)idum);

  for(int type=0; type<1; type++){
    for(int lin=0; lin<2; lin++){
      if(lin==1 && type==1)continue;

      char what[100];
      if(lin){sprintf(what, "Linear ");}
      else{sprintf(what, "Torsional ");}
      strcat(what, " conformations, norm. modes ranked by"); 
      if(type){strcat(what, " overlap");}
      else{strcat(what, " frequency");}
      fprintf(file_out, "# %s\n", what);
      fprintf(file_out,"#1=n.modes 2=rmsd_min 3=rmsd 4=mode 5=c_alpha\n");
      fprintf(file_out, "0\t%.3g\t%.3g\t0\t0\n",rmsd_ini,rmsd_ini);

      if(type)for(k=0; k<NM->N; k++)done[k]=0;
      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];
      }
      float c_lin[NM->N];
      for (i=0; i<NM->N; i++){
	c_lin[i]=Scalar_product_weighted(D_coord, NM->Cart[i],
					 Ref.mass_coord, ncoord);
      }

      int jmode[NM->N], imode, accept=1, kj=0;
      float score_opt=-1000, score_old=-1000, yy, cc=0;

      for(imode=0; imode<NM->N; imode++){

	if(type==0){
	  kj=imode; // Rank the modes by the frequency
	}else{ 
	  // Rank the modes by the correlation with conf.change
	  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[imode]=kj;

	int random=0; float tol, rfact=0.5;
	for(int round=0; round<nround; round++){

	  int done2[NM->N];
	  if(random){tol=TOL;}
	  else{tol=0; for(i=0; i<NM->N; i++)done2[i]=0;}

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

	    if(lin){
	      cc=c_lin[kj]; float *cart=NM->Cart[kj];
	      for(i=0; i<ncoord; i++)coord_new[i]=coord_step[i]+cc*cart[i];
	      yy=-rmsd_mclachlan_f(coord_2,coord_new,Ref.mass_atom,Ref.N_ref);
	      if(yy>=score_opt){
		accept=1; score_opt=yy;
		float *mode=NM->Tors[kj];
		for(i=0; i<naxes; i++)d_phi_opt[i]+=cc*mode[i];
	      }else{accept=0;}
	      goto print_rmsd;
	    }

	    // Full reconstruction, optimize the coefficient
	    // Determine mode (kj) and coefficient (cc)
	    if(random){
	      if(iter>imode)break;
	      int iran=imode*RandomFloating();
	      if(iran>imode)iran=imode;
	      kj=jmode[iran];
	      cc=gasdev(&idum)*sigma[kj]*rfact;
	    }else{ // Minimization
	      kj=-1; cc=0;
	      for(j=imode; j>=0; j--){
		k=jmode[j]; if(done2[k])continue;
		if(kj<0 || fabs(c_lin[k])>fabs(cc)){kj=k; cc=c_lin[k];}
	      }
	      if(kj<0 || fabs(cc)<c_thr)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);
	      // 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; done2[kj]=1;}
	    }
	  print_rmsd:
	    fprintf(file_out, "%d\t%.3g\t%.3g\t%d\t%.3g\n",
		    imode,-score_opt,-yy,kj,cc);
	    if(accept==0)continue;
	    
	    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<NM->N; i++){
	      c_lin[i]=Scalar_product_weighted(D_coord, NM->Cart[i],
					       Ref.mass_coord, ncoord);
	    } 

	    if(lin)goto print_pdb;
	    if(fabs(score_old-score_opt)<TOL2)break;
	  } // end iter
	  if(random){random=0; rfact/=2;}else{random=1;}
	} // end round
	
      print_pdb:
	if(imode==NMODES_CC){ //&& sel
	  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_CC);
	  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);
	}
    
      } // end imode
  
      if(type==1 &&  lin==0) // Store angles
	for(i=0; i<naxes; i++)Diff->Tors[i]=d_phi_opt[i];
      
      yy=-RMSD_confchange(0, NM->Tors[0], d_phi, coord_all, coord_new,
			  d_phi_opt,naxes,bonds,atoms,natoms,Ref,coord_2);
      fprintf(file_out, "#%d modes RMSD= %.3f RMSD tors. reconstr.= %.3f\n",
	      imode, -score_opt, -yy);
      fprintf(file_out, "&\n");
      printf("%d best modes RMSD=%.3f\n", imode, -score_opt);
      
      /*fprintf(file_out,"# %d non-zero coefficients of normal modes:\n",imode);
	for(i=0; i<NM->N; i++)if(cnew[i])
	fprintf(file_out,"%d %.3g\n",i,cnew[i]);*/
    } // end lin
  }// end type
  fclose(file_out);
  fclose(file_pdb);
  return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %r9, -0x140(%rbp)
movq %r8, -0x78(%rbp)
movq %rcx, -0xb8(%rbp)
movq %rdx, -0x108(%rbp)
movq %rsi, %r13
leaq 0x10(%rbp), %r14
movq 0x50(%rbp), %rdx
cvtss2sd %xmm0, %xmm1
mulsd 0x29084(%rip), %xmm1    # 0x59cc0
movsd %xmm1, -0x50(%rbp)
mulss 0x2909b(%rip), %xmm0    # 0x59ce4
movaps %xmm0, -0x160(%rbp)
leaq 0x29e53(%rip), %rsi     # 0x5aaaa
leaq -0x260(%rbp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2270
leaq 0x210e0(%rip), %r15     # 0x51d4f
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x2657d(%rip), %r12     # 0x57200
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2220
movq %rax, -0xb0(%rbp)
leaq 0x29e25(%rip), %rsi     # 0x5aac1
movq %rbx, %rdi
movq 0x50(%rbp), %rdx
xorl %eax, %eax
callq 0x2270
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2220
movq %rax, -0xc0(%rbp)
movq 0x10(%r14), %rdx
movl (%r14), %ecx
movq 0x40(%rbp), %rdi
movq 0x48(%rbp), %rsi
movq %rdx, -0xf8(%rbp)
movl %ecx, -0xa4(%rbp)
callq 0x4dfa0
movq %rsp, -0x110(%rbp)
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
movl 0x8(%r13), %eax
movl 0xc(%r13), %r15d
movq %rsp, %rcx
movq %rax, -0x80(%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, -0xd8(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
leaq 0xf(,%r15,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x40(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x98(%rbp)
movq %rcx, %rsp
movq -0x78(%rbp), %rcx
leal (%rcx,%rcx,2), %ecx
leaq 0xf(,%rcx,4), %rcx
andq $-0x10, %rcx
movq %rsp, %rdx
movq %rcx, -0x138(%rbp)
subq %rcx, %rdx
movq %rdx, -0xd0(%rbp)
movq %rdx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x88(%rbp)
movq %rcx, %rsp
cmpl $0x0, (%r13)
jle 0x30dc4
xorl %ebx, %ebx
xorpd %xmm1, %xmm1
movq 0x28(%r13), %rax
movss (%rax,%rbx,4), %xmm0
ucomiss %xmm1, %xmm0
jae 0x30db8
callq 0x21d0
xorps %xmm1, %xmm1
incq %rbx
movslq (%r13), %rax
cmpq %rax, %rbx
jl 0x30da2
xorps %xmm0, %xmm0
cvtsd2ss -0x50(%rbp), %xmm0
movss %xmm0, -0xdc(%rbp)
callq 0x32a14
movq %rax, %rdi
callq 0x503ac
xorps %xmm0, %xmm0
cvtss2sd -0x60(%rbp), %xmm0
movsd %xmm0, -0x120(%rbp)
movaps 0x20238(%rip), %xmm0    # 0x51030
xorps -0x160(%rbp), %xmm0
movaps %xmm0, -0x170(%rbp)
movl -0x78(%rbp), %eax
movq %rax, -0x130(%rbp)
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %r12
movq -0x80(%rbp), %rax
leaq (,%rax,8), %rax
movq %rax, -0xe8(%rbp)
leaq (,%r15,4), %rax
movq %rax, -0xf0(%rbp)
movb $0x1, %al
movl $0x0, -0x6c(%rbp)
movq %r13, -0x58(%rbp)
movq %r12, -0x118(%rbp)
movl %eax, -0x30(%rbp)
testb $0x1, %al
je 0x30e72
movabsq $0x616e6f6973726f54, %rax # imm = 0x616E6F6973726F54
movq %rax, -0x1f0(%rbp)
movl $0x206c61, -0x1e9(%rbp) # imm = 0x206C61
jmp 0x30e83
movabsq $0x207261656e694c, %rax # imm = 0x207261656E694C
movq %rax, -0x1f0(%rbp)
leaq -0x1f0(%rbp), %r14
movq %r14, %rdi
callq 0x20d0
movabsq $0x79622064656b6e, %rcx # imm = 0x79622064656B6E
movq %rcx, -0x1d2(%rbp,%rax)
movups 0x29c36(%rip), %xmm0    # 0x5aae1
movups %xmm0, -0x1f0(%rbp,%rax)
movups 0x29c37(%rip), %xmm0    # 0x5aaf1
movups %xmm0, -0x1e0(%rbp,%rax)
movq %r14, %rdi
callq 0x20d0
movabsq $0x6e65757165726620, %rcx # imm = 0x6E65757165726620
movq %rcx, -0x1f0(%rbp,%rax)
movl $0x79636e, -0x1e9(%rbp,%rax) # imm = 0x79636E
movq -0xb0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x29266(%rip), %rsi     # 0x5a15e
movq %r14, %rdx
xorl %eax, %eax
callq 0x21a0
movl $0x2e, %esi
movl $0x1, %edx
leaq 0x29ce7(%rip), %rdi     # 0x5abfa
movq %rbx, %rcx
callq 0x2290
movq %rbx, %rdi
leaq 0x29d04(%rip), %rsi     # 0x5ac29
movsd -0x120(%rbp), %xmm0
movaps %xmm0, %xmm1
movb $0x2, %al
callq 0x21a0
cmpl $0x0, -0x80(%rbp)
movq 0x40(%rbp), %rbx
jle 0x30f56
movq -0xa0(%rbp), %rdi
xorl %esi, %esi
movq -0xe8(%rbp), %rdx
callq 0x2110
testl %r15d, %r15d
movq 0x48(%rbp), %rcx
movq -0x88(%rbp), %rdi
jle 0x30fa0
movq -0x98(%rbp), %rdi
movq %rbx, %rsi
movq -0xf0(%rbp), %rdx
callq 0x21b0
movq -0x88(%rbp), %rdi
movq 0x48(%rbp), %rcx
xorl %eax, %eax
movss (%rcx,%rax,4), %xmm0
subss (%rbx,%rax,4), %xmm0
movss %xmm0, (%rdi,%rax,4)
incq %rax
cmpq %rax, %r15
jne 0x30f89
movq %rsp, -0x128(%rbp)
movl (%r13), %eax
movq %rsp, %r9
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r9
movq %r9, %rsp
xorl %r14d, %r14d
cmpl $0x0, (%r13)
jle 0x316f0
xorl %ebx, %ebx
movq %r9, -0x60(%rbp)
movq 0x38(%r13), %rax
movq (%rax,%rbx,8), %rsi
movq %r12, %rdx
movl %r15d, %ecx
callq 0x107c4
movq -0x60(%rbp), %r9
movq -0x88(%rbp), %rdi
movss %xmm0, (%r9,%rbx,4)
incq %rbx
movslq (%r13), %rax
cmpq %rax, %rbx
jl 0x30fd4
movl %eax, %ecx
movq %rsp, %rdi
leaq 0xf(,%rcx,4), %rcx
andq $-0x10, %rcx
subq %rcx, %rdi
movq %rdi, %rsp
testl %eax, %eax
jle 0x316fe
movl $0x1, %ecx
movq %rcx, -0x100(%rbp)
xorl %r14d, %r14d
movss 0x28a1e(%rip), %xmm0    # 0x59a58
movss %xmm0, -0x70(%rbp)
movaps %xmm0, %xmm2
movq -0x40(%rbp), %r8
movl -0x30(%rbp), %esi
movaps 0x26290(%rip), %xmm3    # 0x572e0
movq %rdi, -0x90(%rbp)
movq %rsp, -0x148(%rbp)
movl %r14d, (%rdi,%r14,4)
leaq 0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq %rcx, -0x150(%rbp)
movl %eax, %eax
movq %rsp, %r12
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movslq (%r13), %rdx
testq %rdx, %rdx
jle 0x310c0
shlq $0x2, %rdx
movq %r12, %rdi
xorl %esi, %esi
movaps %xmm2, -0x50(%rbp)
callq 0x2110
movaps -0x50(%rbp), %xmm2
movq -0x90(%rbp), %rdi
movq -0x60(%rbp), %r9
movaps 0x26227(%rip), %xmm3    # 0x572e0
movl -0x30(%rbp), %esi
movq -0x40(%rbp), %r8
movaps %xmm2, %xmm5
movq %r14, -0xc8(%rbp)
movl %r14d, %ebx
xorl %r14d, %r14d
movq -0x98(%rbp), %rdx
testb $0x1, %sil
movss %xmm5, -0x68(%rbp)
je 0x3117b
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
xorps %xmm4, %xmm4
movq -0x100(%rbp), %rax
movl -0x4(%rdi,%rax,4), %ecx
movslq %ecx, %rdx
cmpl $0x0, (%r12,%rdx,4)
jne 0x31126
movss (%r9,%rdx,4), %xmm0
testl %r10d, %r10d
js 0x31120
movaps %xmm0, %xmm1
andps %xmm3, %xmm1
movaps %xmm4, %xmm2
andps %xmm3, %xmm2
ucomiss %xmm2, %xmm1
jbe 0x31126
movl %ecx, %r10d
movaps %xmm0, %xmm4
decq %rax
jg 0x310f6
testl %r10d, %r10d
js 0x31513
movaps %xmm4, %xmm0
andps %xmm3, %xmm0
movss -0xdc(%rbp), %xmm1
ucomiss %xmm0, %xmm1
ja 0x31513
movaps -0x160(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3125d
ucomiss 0x1ffb6(%rip), %xmm4    # 0x51118
movaps %xmm1, %xmm4
movq 0x48(%rbp), %rcx
ja 0x31261
movaps -0x170(%rbp), %xmm4
jmp 0x31261
movl %ebx, -0x2c(%rbp)
movslq %ebx, %rbx
movss (%r9,%rbx,4), %xmm1
testl %r15d, %r15d
jle 0x311b6
movq -0x58(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax,%rbx,8), %rax
xorl %ecx, %ecx
movss (%rax,%rcx,4), %xmm0
mulss %xmm1, %xmm0
addss (%rdx,%rcx,4), %xmm0
movss %xmm0, (%r8,%rcx,4)
incq %rcx
cmpq %rcx, %r15
jne 0x3119a
movaps %xmm1, -0x50(%rbp)
movq 0x48(%rbp), %rdi
movq %r8, %rsi
movq -0xf8(%rbp), %rdx
movl -0xa4(%rbp), %ecx
callq 0x4dfa0
xorps %xmm3, %xmm3
cvtsd2ss %xmm0, %xmm3
xorps 0x1fe4f(%rip), %xmm3    # 0x51030
movss -0x68(%rbp), %xmm2
ucomiss %xmm2, %xmm3
jae 0x31203
movaps %xmm2, %xmm0
movl -0x2c(%rbp), %ebx
movq -0x58(%rbp), %r13
movaps -0x50(%rbp), %xmm4
movb $0x1, %al
movl %eax, -0x34(%rbp)
jmp 0x313a5
movq -0x80(%rbp), %rdx
testl %edx, %edx
movq -0xa0(%rbp), %rsi
jle 0x31378
movq -0x58(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax,%rbx,8), %rax
xorl %ecx, %ecx
movaps -0x50(%rbp), %xmm4
movss (%rax,%rcx,4), %xmm0
mulss %xmm4, %xmm0
cvtss2sd %xmm0, %xmm0
addsd (%rsi,%rcx,8), %xmm0
movsd %xmm0, (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %rdx
jne 0x31228
movl $0x0, -0x34(%rbp)
movaps %xmm3, %xmm0
movl -0x2c(%rbp), %ebx
movq -0x58(%rbp), %r13
jmp 0x313a5
movq 0x48(%rbp), %rcx
movl %r10d, -0x2c(%rbp)
movl %r10d, %r13d
movl $0x4, %ebx
movaps %xmm4, -0x50(%rbp)
movq -0x58(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax,%r13,8), %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 %rcx, 0x48(%rsp)
movq -0x78(%rbp), %rax
movl %eax, 0x10(%rsp)
movq -0xb8(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x108(%rbp), %rax
movq %rax, (%rsp)
movaps %xmm4, %xmm0
movq -0xd8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
movq %r8, %rcx
movq -0xa0(%rbp), %r8
movq -0x80(%rbp), %r9
callq 0x30b3c
movss -0x68(%rbp), %xmm5
addq $0x50, %rsp
movaps %xmm0, %xmm3
xorps 0x1fd36(%rip), %xmm3    # 0x51030
ucomiss %xmm5, %xmm3
ja 0x31334
movaps -0x50(%rbp), %xmm4
mulss 0x248b9(%rip), %xmm4    # 0x55bc4
movl $0x1, (%r12,%r13,4)
decl %ebx
movq 0x48(%rbp), %rcx
movq -0x40(%rbp), %r8
jne 0x3126d
movb $0x1, %al
movl %eax, -0x34(%rbp)
movaps %xmm5, %xmm0
movq -0x58(%rbp), %r13
movl -0x2c(%rbp), %ebx
jmp 0x313a5
cmpl $0x0, -0x80(%rbp)
jle 0x3138b
movq -0xa0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
movq -0xe8(%rbp), %rdx
movaps %xmm3, -0x180(%rbp)
callq 0x21b0
movaps -0x180(%rbp), %xmm3
movl $0x0, -0x34(%rbp)
movaps %xmm3, %xmm0
movss -0x68(%rbp), %xmm1
movss %xmm1, -0x70(%rbp)
jmp 0x3139a
movl $0x0, -0x34(%rbp)
movaps %xmm3, %xmm0
movl -0x2c(%rbp), %ebx
movq -0x58(%rbp), %r13
jmp 0x313a1
movl $0x0, -0x34(%rbp)
movaps %xmm3, %xmm0
movss %xmm5, -0x70(%rbp)
movq -0x58(%rbp), %r13
movl -0x2c(%rbp), %ebx
movaps -0x50(%rbp), %xmm4
movaps %xmm0, -0x50(%rbp)
movaps 0x1fc80(%rip), %xmm1    # 0x51030
xorps %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm3
xorps %xmm1, %xmm1
cvtss2sd %xmm3, %xmm1
xorps %xmm2, %xmm2
cvtss2sd %xmm4, %xmm2
movq -0xb0(%rbp), %rdi
leaq 0x29864(%rip), %rsi     # 0x5ac3a
movq -0xc8(%rbp), %rdx
movl %ebx, %ecx
movb $0x3, %al
callq 0x21a0
cmpb $0x0, -0x34(%rbp)
je 0x31425
incl %r14d
movaps -0x50(%rbp), %xmm2
movaps %xmm2, %xmm5
cmpl $0xb, %r14d
movq -0x40(%rbp), %r8
movq -0x98(%rbp), %rdx
movl -0x30(%rbp), %esi
movaps 0x25ed1(%rip), %xmm3    # 0x572e0
movq -0x60(%rbp), %r9
movq -0x90(%rbp), %rdi
jne 0x310d7
jmp 0x31534
movl %ebx, -0x2c(%rbp)
movl %r14d, -0x68(%rbp)
testl %r15d, %r15d
movq -0x40(%rbp), %rsi
movq -0x88(%rbp), %rdi
jle 0x31477
movq -0x98(%rbp), %rdi
movq -0xf0(%rbp), %rdx
callq 0x21b0
movq -0x88(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq 0x48(%rbp), %rcx
xorl %eax, %eax
movss (%rcx,%rax,4), %xmm0
subss (%rdx,%rax,4), %xmm0
movss %xmm0, (%rdi,%rax,4)
incq %rax
cmpq %rax, %r15
jne 0x31460
cmpl $0x0, (%r13)
movq -0x60(%rbp), %r9
movq -0x150(%rbp), %r14
jle 0x314bb
xorl %ebx, %ebx
movq 0x38(%r13), %rax
movq (%rax,%rbx,8), %rsi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x107c4
movq -0x60(%rbp), %r9
movq -0x88(%rbp), %rdi
movss %xmm0, (%r9,%rbx,4)
incq %rbx
movslq (%r13), %rax
cmpq %rax, %rbx
jl 0x3148b
movl -0x30(%rbp), %esi
testb $0x1, %sil
movl -0x68(%rbp), %r14d
je 0x31518
movss -0x70(%rbp), %xmm0
movaps -0x50(%rbp), %xmm2
subss %xmm2, %xmm0
movaps 0x25e04(%rip), %xmm3    # 0x572e0
andps %xmm3, %xmm0
movss 0x25dc9(%rip), %xmm1    # 0x572b0
ucomiss %xmm0, %xmm1
movq -0x98(%rbp), %rdx
movq -0x90(%rbp), %rdi
ja 0x31530
incl %r14d
movaps %xmm2, %xmm5
cmpl $0xb, %r14d
movq -0x40(%rbp), %r8
movl -0x2c(%rbp), %ebx
jne 0x310d7
jmp 0x31534
movaps %xmm5, %xmm2
jmp 0x31534
movq -0x40(%rbp), %r8
movaps 0x25dbd(%rip), %xmm3    # 0x572e0
movq -0x90(%rbp), %rdi
movaps -0x50(%rbp), %xmm2
jmp 0x31534
movq -0x40(%rbp), %r8
movq -0x148(%rbp), %rsp
movq -0xc8(%rbp), %r14
cmpq $0xa, %r14
jne 0x316c8
movl -0x6c(%rbp), %edx
incl %edx
movq -0xc0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x27cb1(%rip), %rsi     # 0x59213
movl %edx, -0x6c(%rbp)
xorl %eax, %eax
movaps %xmm2, -0x50(%rbp)
callq 0x21a0
movq %rbx, %rdi
leaq 0x29601(%rip), %rsi     # 0x5ab7b
leaq -0x1f0(%rbp), %rdx
xorl %eax, %eax
callq 0x21a0
movaps -0x50(%rbp), %xmm0
xorps 0x1fa9d(%rip), %xmm0    # 0x51030
cvtss2sd %xmm0, %xmm0
movq %rbx, %rdi
leaq 0x295e5(%rip), %rsi     # 0x5ab86
movb $0x1, %al
callq 0x21a0
movl $0x2a, %esi
movl $0x1, %edx
leaq 0x295ec(%rip), %rdi     # 0x5aba5
movq %rbx, %rcx
callq 0x2290
movq %rbx, %rdi
leaq 0x29605(%rip), %rsi     # 0x5abd0
movl $0xa, %edx
xorl %eax, %eax
callq 0x21a0
movq %rsp, -0x68(%rbp)
movq %rsp, %rdi
subq -0x138(%rbp), %rdi
movq %rdi, %rsp
movq %rsp, %rdx
movq -0x130(%rbp), %r9
leaq 0xf(,%r9,4), %rax
andq $-0x10, %rax
subq %rax, %rdx
movq %rdx, %rsp
cmpl $0x0, -0x78(%rbp)
jle 0x31648
movq -0xb8(%rbp), %rax
xorl %ecx, %ecx
movq %rdi, %rsi
movl $0x3f800000, (%rdx,%rcx,4) # imm = 0x3F800000
xorl %r8d, %r8d
xorps %xmm0, %xmm0
cvtsd2ss (%rax,%r8,2), %xmm0
movss %xmm0, (%rsi,%r8)
addq $0x4, %r8
cmpl $0xc, %r8d
jne 0x31620
incq %rcx
addq $0x70, %rax
addq %r8, %rsi
cmpq %r9, %rcx
jne 0x31616
movq -0xd0(%rbp), %r14
movq %r14, %rsi
movq -0x78(%rbp), %rbx
movl %ebx, %ecx
callq 0x4dfa0
movq 0x40(%rbp), %rdi
movq -0x40(%rbp), %r12
movq %r12, %rsi
movq -0xf8(%rbp), %rdx
movl -0xa4(%rbp), %ecx
callq 0x4dfa0
cvtsd2ss %xmm0, %xmm0
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movl %ebx, %edx
movq %r14, %rcx
movq -0x140(%rbp), %r8
movl -0x6c(%rbp), %r9d
callq 0x3285f
movq %r12, %r8
movq -0x68(%rbp), %rsp
movl -0x30(%rbp), %esi
movaps 0x25c2e(%rip), %xmm3    # 0x572e0
movq -0xc8(%rbp), %r14
movq -0x60(%rbp), %r9
movq -0x90(%rbp), %rdi
movaps -0x50(%rbp), %xmm2
incq %r14
movslq (%r13), %rax
incq -0x100(%rbp)
cmpq %rax, %r14
jl 0x31057
movq 0x48(%rbp), %rcx
movq -0x118(%rbp), %r12
movaps %xmm2, -0x50(%rbp)
jmp 0x31712
movss 0x28360(%rip), %xmm0    # 0x59a58
movaps %xmm0, -0x50(%rbp)
jmp 0x3170e
movss 0x28352(%rip), %xmm0    # 0x59a58
movaps %xmm0, -0x50(%rbp)
movq 0x48(%rbp), %rcx
movq -0x40(%rbp), %r8
movq 0x40(%r13), %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 %rcx, 0x48(%rsp)
movq -0x78(%rbp), %rax
movl %eax, 0x10(%rsp)
movq -0xb8(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x108(%rbp), %rax
movq %rax, (%rsp)
xorps %xmm0, %xmm0
movq -0xd8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
movq %r8, %rcx
movq -0xa0(%rbp), %r8
movq -0x80(%rbp), %r9
callq 0x30b3c
addq $0x50, %rsp
movaps -0x50(%rbp), %xmm1
xorps 0x1f89e(%rip), %xmm1    # 0x51030
xorps %xmm2, %xmm2
cvtss2sd %xmm1, %xmm2
movsd %xmm2, -0x50(%rbp)
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movq -0xb0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x2949a(%rip), %rsi     # 0x5ac50
movl %r14d, %edx
movaps %xmm2, %xmm0
movb $0x2, %al
callq 0x21a0
movl $0x2, %esi
movl $0x1, %edx
leaq 0x26917(%rip), %rdi     # 0x580eb
movq %rbx, %rcx
callq 0x2290
leaq 0x2949e(%rip), %rdi     # 0x5ac81
movl %r14d, %esi
movsd -0x50(%rbp), %xmm0
movb $0x1, %al
callq 0x20f0
movq -0x128(%rbp), %rsp
testb $0x1, -0x30(%rbp)
movl $0x0, %eax
jne 0x30e4e
movq -0xb0(%rbp), %rdi
callq 0x20c0
movq -0xc0(%rbp), %rdi
callq 0x20c0
movq -0x110(%rbp), %rsp
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq