// File: /workspace/github_c_makefile_star2_O1/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 $0x288, %rsp            # imm = 0x288
movq %r9, -0x190(%rbp)
movq %r8, -0x90(%rbp)
movq %rcx, -0xe0(%rbp)
movq %rdx, -0x138(%rbp)
movq %rsi, %r13
leaq 0x10(%rbp), %r14
movq 0x50(%rbp), %rdx
cvtss2sd %xmm0, %xmm1
mulsd 0x28dfe(%rip), %xmm1    # 0x59d18
movsd %xmm1, -0x50(%rbp)
mulss 0x28e15(%rip), %xmm0    # 0x59d3c
movaps %xmm0, -0x1c0(%rbp)
leaq 0x29bd1(%rip), %rsi     # 0x5ab06
leaq -0x2b0(%rbp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2260
leaq 0x20d8e(%rip), %r15     # 0x51cdb
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x262df(%rip), %r12     # 0x57240
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, -0xd8(%rbp)
leaq 0x29ba3(%rip), %rsi     # 0x5ab1d
movq %rbx, %rdi
movq 0x50(%rbp), %rdx
xorl %eax, %eax
callq 0x2260
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, -0xe8(%rbp)
movq 0x10(%r14), %rdx
movl (%r14), %ecx
movq 0x40(%rbp), %rdi
movq 0x48(%rbp), %rsi
movq %rdx, -0x130(%rbp)
movl %ecx, -0xc0(%rbp)
callq 0x4e010
movq %rsp, -0x158(%rbp)
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xa0(%rbp)
movl 0x8(%r13), %eax
movl 0xc(%r13), %r15d
movq %rsp, %rcx
movq %rax, -0x98(%rbp)
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xb8(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xf8(%rbp)
movq %rcx, %rsp
movq %rsp, %rbx
leaq 0xf(,%r15,4), %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x60(%rbp)
movq %rcx, %rsp
movq -0x90(%rbp), %rcx
leal (%rcx,%rcx,2), %ecx
leaq 0xf(,%rcx,4), %rcx
andq $-0x10, %rcx
movq %rsp, %rdx
movq %rcx, -0x188(%rbp)
subq %rcx, %rdx
movq %rdx, -0xf0(%rbp)
movq %rdx, %rsp
movq %rsp, %r12
subq %rax, %r12
movq %r12, %rsp
movl (%r13), %eax
movq %rsp, %rdx
leaq 0xf(,%rax,4), %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, -0x120(%rbp)
movq %rdx, %rsp
testl %eax, %eax
jle 0x310cf
xorl %r14d, %r14d
xorpd %xmm1, %xmm1
movq 0x28(%r13), %rax
movss (%rax,%r14,4), %xmm0
ucomiss %xmm1, %xmm0
jb 0x310ae
sqrtss %xmm0, %xmm0
jmp 0x310b6
callq 0x21c0
xorps %xmm1, %xmm1
movq -0x120(%rbp), %rax
movss %xmm0, (%rax,%r14,4)
incq %r14
movslq (%r13), %rax
cmpq %rax, %r14
jl 0x31099
xorps %xmm0, %xmm0
cvtsd2ss -0x50(%rbp), %xmm0
movss %xmm0, -0x104(%rbp)
callq 0x32e47
movq %rax, 0x4840d(%rip)     # 0x794f8
movq %rax, %rdi
callq 0x5050c
xorps %xmm0, %xmm0
cvtss2sd -0xa0(%rbp), %xmm0
movsd %xmm0, -0x168(%rbp)
movaps 0x25823(%rip), %xmm0    # 0x56930
xorps -0x1c0(%rbp), %xmm0
movaps %xmm0, -0x1d0(%rbp)
movl -0x90(%rbp), %ecx
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x160(%rbp)
movq -0x98(%rbp), %rax
leaq (,%rax,8), %rax
movq %rax, -0x110(%rbp)
leaq (,%r15,4), %rax
movq %rax, -0x128(%rbp)
movq %rcx, -0x180(%rbp)
leaq 0xf(,%rcx,4), %rax
andq $-0x10, %rax
movq %rax, -0x178(%rbp)
movl $0x0, -0x74(%rbp)
movq %r12, -0x68(%rbp)
xorl %eax, %eax
movq %rbx, -0xd0(%rbp)
movq %r13, -0x198(%rbp)
movq %rax, -0xa8(%rbp)
testl %eax, %eax
je 0x311a8
movabsq $0x207261656e694c, %rax # imm = 0x207261656E694C
movq %rax, -0x240(%rbp)
jmp 0x311c3
movabsq $0x616e6f6973726f54, %rax # imm = 0x616E6F6973726F54
movq %rax, -0x240(%rbp)
movl $0x206c61, -0x239(%rbp) # imm = 0x206C61
leaq -0x240(%rbp), %r14
movq %r14, %rdi
callq 0x20d0
movabsq $0x79622064656b6e, %rcx # imm = 0x79622064656B6E
movq %rcx, -0x222(%rbp,%rax)
movups 0x29952(%rip), %xmm0    # 0x5ab3d
movups %xmm0, -0x240(%rbp,%rax)
movups 0x29953(%rip), %xmm0    # 0x5ab4d
movups %xmm0, -0x230(%rbp,%rax)
movq %r14, %rdi
callq 0x20d0
movabsq $0x6e65757165726620, %rcx # imm = 0x6E65757165726620
movq %rcx, -0x240(%rbp,%rax)
movl $0x79636e, -0x239(%rbp,%rax) # imm = 0x79636E
movq -0xd8(%rbp), %r12
movq %r12, %rdi
leaq 0x28f82(%rip), %rsi     # 0x5a1ba
movq %r14, %rdx
xorl %eax, %eax
callq 0x2190
movl $0x2e, %esi
movl $0x1, %edx
leaq 0x29a03(%rip), %rdi     # 0x5ac56
movq %r12, %rcx
callq 0x2280
movq %r12, %rdi
leaq 0x29a20(%rip), %rsi     # 0x5ac85
movsd -0x168(%rbp), %xmm0
movaps %xmm0, %xmm1
movb $0x2, %al
callq 0x2190
cmpl $0x0, -0x98(%rbp)
jle 0x31295
movq -0xb8(%rbp), %rdi
xorl %esi, %esi
movq -0x110(%rbp), %rdx
callq 0x2110
testl %r15d, %r15d
movq 0x40(%rbp), %rsi
movq -0x68(%rbp), %rbx
movq 0x48(%rbp), %r9
jle 0x312d8
movq -0x60(%rbp), %rdi
movq -0x128(%rbp), %rdx
callq 0x21a0
movq 0x48(%rbp), %r9
movq 0x40(%rbp), %rcx
xorl %eax, %eax
movss (%r9,%rax,4), %xmm0
subss (%rcx,%rax,4), %xmm0
movss %xmm0, (%rbx,%rax,4)
incq %rax
cmpq %rax, %r15
jne 0x312c0
movq %rsp, -0x170(%rbp)
movl (%r13), %eax
movq %rsp, %r14
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movl (%r13), %eax
testl %eax, %eax
jle 0x31343
movq %r13, %rbx
movq %r14, %r13
xorl %r14d, %r14d
movq -0x160(%rbp), %r12
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rsi
movq -0x68(%rbp), %rdi
movq %r12, %rdx
movl %r15d, %ecx
callq 0x10c76
movss %xmm0, (%r13,%r14,4)
incq %r14
movslq (%rbx), %rax
cmpq %rax, %r14
jl 0x31310
movq 0x48(%rbp), %r9
movq %r13, %r14
movq %rbx, %r13
movl %eax, %eax
movq %rsp, %rdi
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rdi
movq %rdi, %rsp
cmpl $0x0, (%r13)
jle 0x31b87
movl $0x1, %eax
movq %rax, -0x118(%rbp)
xorl %eax, %eax
movss 0x28739(%rip), %xmm0    # 0x59ab4
movss %xmm0, -0x7c(%rbp)
movaps %xmm0, %xmm3
movq -0x60(%rbp), %rsi
movaps 0x25f92(%rip), %xmm2    # 0x57320
movq -0xa8(%rbp), %r12
movq %r14, -0x70(%rbp)
movq -0xd0(%rbp), %rbx
movq %rdi, -0x88(%rbp)
movq %rax, -0xb0(%rbp)
movl %eax, (%rdi,%rax,4)
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x1a8(%rbp)
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xb0(%rbp), %rax
movb $0x1, %cl
movl $0x0, -0x54(%rbp)
movl %eax, %r8d
movaps %xmm3, %xmm4
movss 0x2478f(%rip), %xmm0    # 0x55b7c
movss %xmm0, -0x78(%rbp)
testb $0x1, %cl
je 0x319cd
movq %rsp, -0x1a0(%rbp)
movl (%r13), %eax
movq %rsp, %rcx
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x100(%rbp)
movq %rcx, %rsp
movss 0x28916(%rip), %xmm0    # 0x59d40
movss %xmm0, -0xbc(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x3148f
movslq (%r13), %rdx
xorps %xmm0, %xmm0
movss %xmm0, -0xbc(%rbp)
testq %rdx, %rdx
jle 0x3148f
shlq $0x2, %rdx
movq -0x100(%rbp), %rdi
xorl %esi, %esi
movq %r8, -0x38(%rbp)
movq %r9, %r13
movss %xmm4, -0x2c(%rbp)
callq 0x2110
movss -0x2c(%rbp), %xmm4
movq %r13, %r9
movq -0x38(%rbp), %r8
movq -0x198(%rbp), %r13
movq -0x88(%rbp), %rdi
movaps 0x25e95(%rip), %xmm2    # 0x57320
movq -0x60(%rbp), %rsi
xorl %r11d, %r11d
testl %r12d, %r12d
movl %r11d, -0xc4(%rbp)
movss %xmm4, -0x2c(%rbp)
je 0x31521
movq %r8, -0x38(%rbp)
movslq %r8d, %r12
movss (%r14,%r12,4), %xmm1
testl %r15d, %r15d
jle 0x314da
movq 0x38(%r13), %rax
movq (%rax,%r12,8), %rax
xorl %ecx, %ecx
movss (%rax,%rcx,4), %xmm0
mulss %xmm1, %xmm0
addss (%rsi,%rcx,4), %xmm0
movss %xmm0, (%rbx,%rcx,4)
incq %rcx
cmpq %rcx, %r15
jne 0x314bf
movaps %xmm1, -0x50(%rbp)
movq %r9, %rdi
movq %rbx, %rsi
movq -0x130(%rbp), %rdx
movl -0xc0(%rbp), %ecx
callq 0x4e010
xorps %xmm2, %xmm2
cvtsd2ss %xmm0, %xmm2
xorps 0x2542c(%rip), %xmm2    # 0x56930
movb $0x1, %r14b
movss -0x2c(%rbp), %xmm3
ucomiss %xmm3, %xmm2
jae 0x31597
movaps %xmm3, %xmm1
movq -0x68(%rbp), %r12
jmp 0x317b1
cmpl $0x0, -0x54(%rbp)
je 0x315ed
movl %r11d, %eax
movq -0xb0(%rbp), %r14
cmpq %rax, %r14
jb 0x31970
xorl %eax, %eax
movq %rdi, %r12
callq 0x50647
mulsd -0x1a8(%rbp), %xmm0
cvttsd2si %xmm0, %eax
cmpl %eax, %r14d
cmovll %r14d, %eax
cltq
movslq (%r12,%rax,4), %r14
leaq 0x47f90(%rip), %rdi     # 0x794f8
callq 0x502bc
movss -0x2c(%rbp), %xmm4
movq %r14, %r8
movaps 0x25da4(%rip), %xmm2    # 0x57320
movapd %xmm0, %xmm5
movq -0x120(%rbp), %rax
mulss (%rax,%r14,4), %xmm5
mulss -0x78(%rbp), %xmm5
jmp 0x3165b
movq -0x98(%rbp), %rdx
testl %edx, %edx
movq -0x38(%rbp), %rcx
jle 0x3192a
movq 0x40(%r13), %rax
movq (%rax,%r12,8), %rax
xorl %edi, %edi
movq -0xb8(%rbp), %rsi
movaps -0x50(%rbp), %xmm5
movss (%rax,%rdi,4), %xmm0
mulss %xmm5, %xmm0
cvtss2sd %xmm0, %xmm0
addsd (%rsi,%rdi,8), %xmm0
movsd %xmm0, (%rsi,%rdi,8)
incq %rdi
cmpq %rdi, %rdx
jne 0x315bf
xorl %r14d, %r14d
movaps %xmm2, %xmm1
movq -0x68(%rbp), %r12
jmp 0x317b9
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorps %xmm5, %xmm5
movq -0x118(%rbp), %rax
movl -0x4(%rdi,%rax,4), %ecx
movslq %ecx, %rdx
movq -0x100(%rbp), %r10
cmpl $0x0, (%r10,%rdx,4)
jne 0x31634
testl %r8d, %r8d
js 0x3162b
movss (%r14,%rdx,4), %xmm0
andps %xmm2, %xmm0
movaps %xmm5, %xmm1
andps %xmm2, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x31634
movss (%r14,%rdx,4), %xmm5
movl %ecx, %r8d
decq %rax
jg 0x315fd
movb $0x1, %al
testl %r8d, %r8d
js 0x319c8
movaps %xmm5, %xmm0
andps %xmm2, %xmm0
movss -0x104(%rbp), %xmm1
ucomiss %xmm0, %xmm1
ja 0x319bc
movaps %xmm5, %xmm0
andps %xmm2, %xmm0
movaps -0x1c0(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x31680
ucomiss 0x1f998(%rip), %xmm5    # 0x5100c
movaps %xmm1, %xmm5
ja 0x31680
movaps -0x1d0(%rbp), %xmm5
movq %r8, -0x38(%rbp)
movslq %r8d, %r14
subss -0xbc(%rbp), %xmm4
movss %xmm4, -0x150(%rbp)
movl $0x4, %r12d
movaps %xmm5, -0x50(%rbp)
movq 0x40(%r13), %rax
movq (%rax,%r14,8), %rdi
subq $0x50, %rsp
leaq 0x10(%rbp), %rax
movups (%rax), %xmm0
movupd 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x38(%rsp)
movupd %xmm1, 0x28(%rsp)
movups %xmm0, 0x18(%rsp)
movq 0x48(%rbp), %rax
movq %rax, 0x48(%rsp)
movq -0x90(%rbp), %rax
movl %eax, 0x10(%rsp)
movq -0xe0(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x138(%rbp), %rax
movq %rax, (%rsp)
movaps %xmm5, %xmm0
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
movq %rbx, %rcx
movq -0xb8(%rbp), %r8
movq -0x98(%rbp), %r9
callq 0x30e17
addq $0x50, %rsp
movaps %xmm0, %xmm2
xorps 0x25203(%rip), %xmm2    # 0x56930
ucomiss -0x150(%rbp), %xmm2
ja 0x3176c
movaps -0x50(%rbp), %xmm5
mulss 0x2443a(%rip), %xmm5    # 0x55b7c
movq -0x100(%rbp), %rax
movl $0x1, (%rax,%r14,4)
decl %r12d
jne 0x3169d
movb $0x1, %r14b
movss -0x2c(%rbp), %xmm1
movq -0x68(%rbp), %r12
movq -0x38(%rbp), %rcx
jmp 0x317b9
cmpl $0x0, -0x98(%rbp)
movq -0x68(%rbp), %r12
jle 0x317a1
movq -0xb8(%rbp), %rdi
movq -0xf8(%rbp), %rsi
movq -0x110(%rbp), %rdx
movaps %xmm2, -0x150(%rbp)
callq 0x21a0
movaps -0x150(%rbp), %xmm2
xorl %r14d, %r14d
movaps %xmm2, %xmm1
movss -0x2c(%rbp), %xmm0
movss %xmm0, -0x7c(%rbp)
movq -0x38(%rbp), %rcx
movaps -0x50(%rbp), %xmm5
movaps %xmm1, -0x50(%rbp)
movaps %xmm1, %xmm0
movaps 0x25169(%rip), %xmm1    # 0x56930
xorps %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
xorps %xmm2, %xmm2
cvtss2sd %xmm5, %xmm2
movq -0xd8(%rbp), %rdi
leaq 0x294a9(%rip), %rsi     # 0x5ac96
movq -0xb0(%rbp), %rdx
movq %rcx, -0x38(%rbp)
movb $0x3, %al
callq 0x2190
testb %r14b, %r14b
je 0x31849
movl -0xc4(%rbp), %r11d
incl %r11d
movaps -0x50(%rbp), %xmm3
movaps %xmm3, %xmm4
cmpl $0xb, %r11d
movq 0x48(%rbp), %r9
movq -0x60(%rbp), %rsi
movaps 0x25af8(%rip), %xmm2    # 0x57320
movq -0xa8(%rbp), %r12
movq -0x70(%rbp), %r14
movq -0x88(%rbp), %rdi
movq -0x38(%rbp), %r8
jne 0x31492
jmp 0x31966
testl %r15d, %r15d
movq 0x48(%rbp), %r14
jle 0x31880
movq -0x60(%rbp), %rdi
movq %rbx, %rsi
movq -0x128(%rbp), %rdx
callq 0x21a0
xorl %eax, %eax
movss (%r14,%rax,4), %xmm0
subss (%rbx,%rax,4), %xmm0
movss %xmm0, (%r12,%rax,4)
incq %rax
cmpq %rax, %r15
jne 0x31867
cmpl $0x0, (%r13)
movq -0x70(%rbp), %rbx
movq -0xa0(%rbp), %rdx
jle 0x318c1
xorl %r14d, %r14d
movq 0x38(%r13), %rax
movq (%rax,%r14,8), %rsi
movq %r12, %rdi
movl %r15d, %ecx
callq 0x10c76
movq -0xa0(%rbp), %rdx
movss %xmm0, (%rbx,%r14,4)
incq %r14
movslq (%r13), %rax
cmpq %rax, %r14
jl 0x31895
movq -0xa8(%rbp), %r12
testl %r12d, %r12d
jne 0x31939
movss -0x7c(%rbp), %xmm0
movaps -0x50(%rbp), %xmm3
subss %xmm3, %xmm0
movaps 0x25a3f(%rip), %xmm2    # 0x57320
andps %xmm2, %xmm0
movss 0x25a04(%rip), %xmm1    # 0x572f0
ucomiss %xmm0, %xmm1
movb $0x1, %al
movq -0x60(%rbp), %rsi
movq -0xd0(%rbp), %rbx
movq -0x88(%rbp), %rdi
movq -0x38(%rbp), %r8
ja 0x3196a
movl -0xc4(%rbp), %r11d
incl %r11d
movaps %xmm3, %xmm4
cmpl $0xb, %r11d
movq 0x48(%rbp), %r9
movq -0x70(%rbp), %r14
jne 0x31492
jmp 0x31979
xorl %r14d, %r14d
movaps %xmm2, %xmm1
movq -0x68(%rbp), %r12
jmp 0x317b5
xorl %eax, %eax
movq 0x48(%rbp), %r9
movq -0x60(%rbp), %rsi
movaps 0x259d6(%rip), %xmm2    # 0x57320
movq -0x70(%rbp), %r14
movq -0xd0(%rbp), %rbx
movq -0x88(%rbp), %rdi
movq -0x38(%rbp), %r8
movaps -0x50(%rbp), %xmm3
jmp 0x31979
movb $0x1, %al
jmp 0x31979
movq 0x48(%rbp), %r9
jmp 0x31975
movb $0x1, %al
movaps %xmm4, %xmm3
movq -0x70(%rbp), %r14
testb %al, %al
je 0x3199f
xorl %ecx, %ecx
movss -0x78(%rbp), %xmm0
mulss 0x241f0(%rip), %xmm0    # 0x55b7c
cmpl $0x0, -0x54(%rbp)
sete %dl
je 0x3199a
movss %xmm0, -0x78(%rbp)
movb %dl, %cl
movl %ecx, -0x54(%rbp)
movq -0x1a0(%rbp), %rsp
xorl %ecx, %ecx
movaps %xmm3, %xmm4
testb %al, %al
movq -0xb0(%rbp), %rax
jne 0x313f2
jmp 0x319d0
movaps %xmm4, %xmm3
movq -0x88(%rbp), %rdi
jmp 0x31979
movaps %xmm4, %xmm3
jmp 0x31979
movaps %xmm4, %xmm3
cmpq $0xa, %rax
jne 0x31b61
movl -0x74(%rbp), %edx
incl %edx
movq -0xe8(%rbp), %r14
movq %r14, %rdi
leaq 0x27876(%rip), %rsi     # 0x59266
movl %edx, -0x74(%rbp)
xorl %eax, %eax
movaps %xmm3, -0x50(%rbp)
callq 0x2190
movq %r14, %rdi
leaq 0x291cf(%rip), %rsi     # 0x5abd7
leaq -0x240(%rbp), %rdx
xorl %eax, %eax
callq 0x2190
movaps -0x50(%rbp), %xmm0
xorps 0x24f0f(%rip), %xmm0    # 0x56930
cvtss2sd %xmm0, %xmm0
movq %r14, %rdi
leaq 0x291b3(%rip), %rsi     # 0x5abe2
movb $0x1, %al
callq 0x2190
movl $0x2a, %esi
movl $0x1, %edx
leaq 0x291ba(%rip), %rdi     # 0x5ac01
movq %r14, %rcx
callq 0x2280
movq %r14, %rdi
leaq 0x291d3(%rip), %rsi     # 0x5ac2c
movl $0xa, %edx
xorl %eax, %eax
callq 0x2190
movq %rsp, -0xa0(%rbp)
movq %rsp, %rdi
subq -0x188(%rbp), %rdi
movq %rdi, %rsp
movq %rsp, %rdx
subq -0x178(%rbp), %rdx
movq %rdx, %rsp
cmpl $0x0, -0x90(%rbp)
movq -0x180(%rbp), %r9
jle 0x31ad4
movq -0xe0(%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 0x31aac
incq %rcx
addq $0x70, %rax
addq %r8, %rsi
cmpq %r9, %rcx
jne 0x31aa2
movq -0xf0(%rbp), %r12
movq %r12, %rsi
movq -0x90(%rbp), %r14
movl %r14d, %ecx
callq 0x4e010
movq 0x40(%rbp), %rdi
movq %rbx, %rsi
movq -0x130(%rbp), %rdx
movl -0xc0(%rbp), %ecx
callq 0x4e010
cvtsd2ss %xmm0, %xmm0
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movl %r14d, %edx
movq %r12, %rcx
movq -0xa8(%rbp), %r12
movq -0x190(%rbp), %r8
movl -0x74(%rbp), %r9d
callq 0x32c92
movq -0xa0(%rbp), %rsp
movq 0x48(%rbp), %r9
movq -0x60(%rbp), %rsi
movaps 0x257d5(%rip), %xmm2    # 0x57320
movq -0xb0(%rbp), %rax
movq -0x70(%rbp), %r14
movq -0x88(%rbp), %rdi
movaps -0x50(%rbp), %xmm3
incq %rax
movq %rax, %rcx
movslq (%r13), %rax
incq -0x118(%rbp)
cmpq %rax, %rcx
movq %rcx, %rax
jl 0x313a7
movq %rax, %r14
movaps %xmm3, -0x50(%rbp)
jmp 0x31b9d
xorl %r14d, %r14d
movss 0x27f22(%rip), %xmm0    # 0x59ab4
movaps %xmm0, -0x50(%rbp)
movq -0xd0(%rbp), %rbx
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 %r9, 0x48(%rsp)
movq -0x90(%rbp), %rax
movl %eax, 0x10(%rsp)
movq -0xe0(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x138(%rbp), %rax
movq %rax, (%rsp)
xorps %xmm0, %xmm0
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
movq %rbx, %rcx
movq -0xb8(%rbp), %r8
movq -0x98(%rbp), %r9
callq 0x30e17
addq $0x50, %rsp
movaps -0x50(%rbp), %xmm1
xorps 0x24d0d(%rip), %xmm1    # 0x56930
xorps %xmm2, %xmm2
cvtss2sd %xmm1, %xmm2
movsd %xmm2, -0x50(%rbp)
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movq -0xd8(%rbp), %r12
movq %r12, %rdi
leaq 0x29065(%rip), %rsi     # 0x5acac
movl %r14d, %edx
movaps %xmm2, %xmm0
movb $0x2, %al
callq 0x2190
movl $0x2, %esi
movl $0x1, %edx
leaq 0x264c6(%rip), %rdi     # 0x5812b
movq %r12, %rcx
callq 0x2280
leaq 0x29069(%rip), %rdi     # 0x5acdd
movl %r14d, %esi
movsd -0x50(%rbp), %xmm0
movb $0x1, %al
callq 0x20f0
movq -0x170(%rbp), %rsp
movq -0xa8(%rbp), %rcx
leal 0x1(%rcx), %eax
testl %ecx, %ecx
je 0x3118a
movq -0xd8(%rbp), %rdi
callq 0x20c0
movq -0xe8(%rbp), %rdi
callq 0x20c0
movq -0x158(%rbp), %rsp
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq