// File: /workspace/github_c_makefile_star2_O2/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 $0x258, %rsp            # imm = 0x258
movss %xmm0, -0x4c(%rbp)
movq %r9, -0x150(%rbp)
movq %r8, -0x80(%rbp)
movq %rcx, -0xa8(%rbp)
movq %rdx, -0x108(%rbp)
movq %rsi, -0x38(%rbp)
movl 0x60(%rbp), %r12d
movq 0x48(%rbp), %r15
movq 0x40(%rbp), %r14
movq 0x50(%rbp), %rbx
callq 0x2f672
movq %rax, 0x47794(%rip)     # 0x744f8
movq %rax, %rdi
callq 0x49ebc
movq 0x20(%rbp), %rdx
movl 0x10(%rbp), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rdx, -0x148(%rbp)
movl %ecx, -0xbc(%rbp)
callq 0x47a64
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xe0(%rbp)
leaq 0x27c6c(%rip), %rsi     # 0x54a0a
leaq -0x280(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x1eeee(%rip), %r15     # 0x4bca7
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x24383(%rip), %r13     # 0x51150
movq %r14, %rdi
movq %r13, %rsi
callq 0x2210
movq %rax, -0x88(%rbp)
leaq 0x27c3b(%rip), %rsi     # 0x54a21
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2260
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x20f0
movq %r14, %rdi
movq %r13, %rsi
callq 0x2210
movq %rax, -0xe8(%rbp)
movups 0x27c3e(%rip), %xmm0    # 0x54a57
leaq -0x210(%rbp), %rdi
movups %xmm0, 0x1f(%rdi)
movups 0x27c1d(%rip), %xmm0    # 0x54a48
movaps %xmm0, 0x10(%rdi)
movups 0x27c02(%rip), %xmm0    # 0x54a38
movaps %xmm0, (%rdi)
callq 0x20d0
addq %rbp, %rax
addq $-0x210, %rax           # imm = 0xFDF0
testl %r12d, %r12d
je 0x2ce5f
movabsq $0x70616c7265766f20, %rcx # imm = 0x70616C7265766F20
movq %rcx, (%rax)
movb $0x0, 0x8(%rax)
jmp 0x2ce73
movabsq $0x6e65757165726620, %rcx # imm = 0x6E65757165726620
movq %rcx, (%rax)
movl $0x79636e, 0x7(%rax)    # imm = 0x79636E
movss 0x26dbd(%rip), %xmm1    # 0x53c38
movss -0x4c(%rbp), %xmm0
mulss %xmm0, %xmm1
movaps %xmm1, -0x180(%rbp)
mulss 0x26da9(%rip), %xmm0    # 0x53c3c
movss %xmm0, -0x4c(%rbp)
leaq 0x2721f(%rip), %rsi     # 0x540be
xorl %ebx, %ebx
leaq -0x210(%rbp), %rdx
movq -0x88(%rbp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2190
leaq 0x27bb2(%rip), %rdi     # 0x54a72
pushq $0x28
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x2280
cvtss2sd -0xe0(%rbp), %xmm0
leaq 0x27cae(%rip), %rsi     # 0x54b8b
movq %r14, %rdi
movaps %xmm0, %xmm1
movb $0x2, %al
callq 0x2190
movq %rsp, -0x140(%rbp)
movq -0x38(%rbp), %rdx
movl 0x8(%rdx), %eax
movl 0xc(%rdx), %esi
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, %r15
subq %rax, %r15
movq %r15, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x58(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
movq %rsi, -0x90(%rbp)
leaq 0xf(,%rsi,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x30(%rbp)
movq %rcx, %rsp
movq -0x80(%rbp), %rcx
leal (%rcx,%rcx,2), %ecx
leaq 0xf(,%rcx,4), %rsi
andq $-0x10, %rsi
movq %rsp, %rcx
movq %rsi, -0x138(%rbp)
subq %rsi, %rcx
movq %rcx, -0xa0(%rbp)
movq %rcx, %rsp
movq %rsp, %r14
subq %rax, %r14
movq %r14, %rsp
movl (%rdx), %ecx
movq %rsp, %rdx
leaq 0xf(,%rcx,4), %rax
andq $-0x10, %rax
subq %rax, %rdx
movq %rdx, -0xf0(%rbp)
movq %rdx, %rsp
xorps %xmm1, %xmm1
movslq %ecx, %rax
cmpq %rax, %rbx
jge 0x2cfe7
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movss (%rax,%rbx,4), %xmm0
ucomiss %xmm1, %xmm0
jb 0x2cfc8
sqrtss %xmm0, %xmm0
jmp 0x2cfd0
callq 0x21c0
xorps %xmm1, %xmm1
movq -0xf0(%rbp), %rax
movss %xmm0, (%rax,%rbx,4)
incq %rbx
movq -0x38(%rbp), %rax
movl (%rax), %ecx
jmp 0x2cfa8
xorl %eax, %eax
movq -0x98(%rbp), %rdx
testl %edx, %edx
movl $0x0, %r8d
cmovgl %edx, %r8d
movq 0x40(%rbp), %rdx
movq 0x48(%rbp), %rsi
movq -0xb8(%rbp), %rdi
cmpq %rax, %r8
je 0x2d01a
andq $0x0, (%rdi,%rax,8)
incq %rax
jmp 0x2d00b
xorl %eax, %eax
movq -0x90(%rbp), %rdi
testl %edi, %edi
movl $0x0, %r9d
cmovgl %edi, %r9d
movq %r9, -0xf8(%rbp)
cmpq %rax, -0xf8(%rbp)
je 0x2d054
movss (%rsi,%rax,4), %xmm0
subss (%rdx,%rax,4), %xmm0
movss %xmm0, (%r14,%rax,4)
incq %rax
jmp 0x2d036
movq %r8, -0x100(%rbp)
movl %ecx, %eax
movq %rsp, %rdx
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rdx
movq %rdx, -0x60(%rbp)
movq %rdx, %rsp
movq %rsp, %rdx
subq %rax, %rdx
movq %rdx, -0x68(%rbp)
movq %rdx, %rsp
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb0(%rbp)
testl %r12d, %r12d
movq %r15, -0x48(%rbp)
je 0x2d8a6
pushq $-0x1
popq %rbx
xorl %r15d, %r15d
movq -0x38(%rbp), %r12
movslq %ecx, %rax
cmpq %rax, %r15
jge 0x2d0e3
movq 0x38(%r12), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
movq -0xb0(%rbp), %rdx
movq -0x90(%rbp), %rcx
callq 0xfd1e
movq -0x68(%rbp), %rax
movss %xmm0, (%rax,%r15,4)
incq %r15
movl (%r12), %ecx
jmp 0x2d0a9
movq %rsp, %rax
movl %ecx, %edx
movq %rsp, %rcx
leaq 0xf(,%rdx,4), %rdx
andq $-0x10, %rdx
subq %rdx, %rcx
movq %rcx, %rsp
movq -0x38(%rbp), %rdx
movl (%rdx), %edx
xorl %esi, %esi
testl %edx, %edx
cmovlel %esi, %edx
movq -0x48(%rbp), %r15
cmpq %rsi, %rdx
je 0x2d11c
andl $0x0, (%rcx,%rsi,4)
incq %rsi
jmp 0x2d10e
xorl %esi, %esi
movl 0x68(%rbp), %edi
testl %edi, %edi
movl $0x0, %r12d
cmovgl %edi, %r12d
movq -0x60(%rbp), %rdi
cmpq %rsi, %r12
je 0x2d13f
orl $-0x1, (%rdi,%rsi,4)
incq %rsi
jmp 0x2d131
xorl %esi, %esi
xorps %xmm0, %xmm0
movaps 0x240e5(%rip), %xmm1    # 0x51230
movq -0x68(%rbp), %r9
cmpq %r12, %rsi
je 0x2d1b1
xorps %xmm2, %xmm2
xorl %r8d, %r8d
movl %ebx, %edi
cmpq %r8, %rdx
je 0x2d18e
cmpl $0x0, (%rcx,%r8,4)
jne 0x2d189
movss (%r9,%r8,4), %xmm3
testl %edi, %edi
js 0x2d183
movaps %xmm3, %xmm4
andps %xmm1, %xmm4
movaps %xmm2, %xmm5
andps %xmm1, %xmm5
ucomiss %xmm5, %xmm4
jbe 0x2d189
movl %r8d, %edi
movaps %xmm3, %xmm2
incq %r8
jmp 0x2d15c
ucomiss %xmm0, %xmm2
jne 0x2d195
jnp 0x2d1b1
testl %edi, %edi
js 0x2d1b1
movl %edi, %r8d
movl $0x1, (%rcx,%r8,4)
movq -0x60(%rbp), %r8
movl %edi, (%r8,%rsi,4)
incq %rsi
jmp 0x2d14f
movq %rax, %rsp
movl 0x68(%rbp), %eax
leal -0x1(%rax), %ecx
movl %ecx, -0xc8(%rbp)
cvtsi2sd %eax, %xmm1
movsd 0x1dea4(%rip), %xmm0    # 0x4b070
movsd %xmm1, -0x168(%rbp)
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, -0xc4(%rbp)
movl %eax, %ecx
imull $0xa, %eax, %eax
movl %eax, -0xc0(%rbp)
movaps 0x2366c(%rip), %xmm0    # 0x50860
xorps -0x180(%rbp), %xmm0
movaps %xmm0, -0x190(%rbp)
movl %r12d, %r12d
movb $0x1, %al
movss 0x22905(%rip), %xmm1    # 0x4fb14
movss 0x267a1(%rip), %xmm0    # 0x539b8
pushq $0x1
popq %rdi
leaq 0xf(,%rcx,4), %rcx
andq $-0x10, %rcx
movq %rcx, -0x158(%rbp)
movl $0x0, -0x3c(%rbp)
movaps %xmm0, -0x130(%rbp)
movss %xmm0, -0x70(%rbp)
movss %xmm1, -0x50(%rbp)
movq 0x48(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x58(%rbp), %r8
testb $0x1, %al
je 0x2d688
movq %rsp, -0x160(%rbp)
movq %rsp, %r13
subq -0x158(%rbp), %r13
movq %r13, %rsp
movss 0x23f77(%rip), %xmm0    # 0x511ec
movss %xmm0, -0x6c(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, -0x74(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x2d2ad
xorl %eax, %eax
cmpq %rax, %r12
je 0x2d29b
andl $0x0, (%r13,%rax,4)
incq %rax
jmp 0x2d28b
xorpd %xmm0, %xmm0
movss %xmm0, -0x6c(%rbp)
movl -0xc0(%rbp), %eax
movl %eax, -0x74(%rbp)
xorl %esi, %esi
cmpl -0x74(%rbp), %esi
jg 0x2d65e
cmpl $0x0, -0x3c(%rbp)
movl %esi, -0xcc(%rbp)
je 0x2d325
movl %edi, %r15d
xorl %eax, %eax
callq 0x49ffd
mulsd -0x168(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl 0x68(%rbp), %ecx
cmpl %ecx, %eax
cmovgel -0xc8(%rbp), %eax
cltq
movq -0x60(%rbp), %rcx
movslq (%rcx,%rax,4), %rbx
testq %rbx, %rbx
js 0x2d607
leaq 0x471f8(%rip), %rdi     # 0x744f8
callq 0x49cbc
movq -0xf0(%rbp), %rax
mulss (%rax,%rbx,4), %xmm0
mulss -0x50(%rbp), %xmm0
movaps %xmm0, %xmm2
andps 0x23f10(%rip), %xmm2    # 0x51230
movl %r15d, %edi
jmp 0x2d3a1
xorpd %xmm0, %xmm0
xorl %eax, %eax
pushq $-0x1
popq %rcx
movl %ecx, %ebx
cmpq %rax, %r12
je 0x2d37f
movq -0x60(%rbp), %rcx
movslq (%rcx,%rax,4), %rcx
testq %rcx, %rcx
js 0x2d37a
cmpl $0x0, (%r13,%rcx,4)
jne 0x2d37a
movq -0x68(%rbp), %rdx
movss (%rdx,%rcx,4), %xmm4
testl %ebx, %ebx
js 0x2d374
movapd %xmm4, %xmm1
movapd 0x23ecd(%rip), %xmm3    # 0x51230
andpd %xmm3, %xmm1
movapd %xmm0, %xmm2
andpd %xmm3, %xmm2
ucomiss %xmm2, %xmm1
jbe 0x2d37a
movapd %xmm4, %xmm0
movl %ecx, %ebx
incq %rax
jmp 0x2d330
testl %ebx, %ebx
js 0x2d627
movapd %xmm0, %xmm2
andpd 0x23e9d(%rip), %xmm2    # 0x51230
movss -0x4c(%rbp), %xmm1
ucomiss %xmm2, %xmm1
ja 0x2d627
movaps -0x180(%rbp), %xmm1
ucomiss %xmm1, %xmm2
jbe 0x2d3c0
ucomiss 0x1dc58(%rip), %xmm0    # 0x4b00c
movaps %xmm1, %xmm0
ja 0x2d3c0
movaps -0x190(%rbp), %xmm0
testl %edi, %edi
sete %al
movl %ebx, %r15d
movaps -0x130(%rbp), %xmm1
movaps %xmm1, %xmm2
xorps 0x23487(%rip), %xmm2    # 0x50860
cvtss2sd %xmm2, %xmm2
movsd %xmm2, -0x170(%rbp)
subss -0x6c(%rbp), %xmm1
movaps %xmm1, -0x1a0(%rbp)
movb $0x1, %cl
testb $0x1, %cl
je 0x2d4e9
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax,%r15,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 -0x80(%rbp), %rax
movl %eax, 0x10(%rsp)
movq -0xa8(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x108(%rbp), %rax
movq %rax, (%rsp)
movq -0x48(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0xb8(%rbp), %r8
movq -0x98(%rbp), %r9
movaps %xmm0, -0xe0(%rbp)
callq 0x2d8f7
addq $0x50, %rsp
cvtss2sd %xmm0, %xmm1
xorps 0x233d6(%rip), %xmm0    # 0x50860
movaps %xmm0, -0x120(%rbp)
cvtss2sd -0xe0(%rbp), %xmm2
movq -0x88(%rbp), %rdi
leaq 0x276f6(%rip), %rsi     # 0x54b9d
movsd -0x170(%rbp), %xmm0
movl %ebx, %edx
movb $0x3, %al
callq 0x2190
movaps -0x120(%rbp), %xmm0
ucomiss -0x1a0(%rbp), %xmm0
ja 0x2d504
movaps -0xe0(%rbp), %xmm0
mulss 0x2263d(%rip), %xmm0    # 0x4fb14
movl $0x1, (%r13,%r15,4)
movb $0x1, %al
xorl %ecx, %ecx
jmp 0x2d3f3
xorl %edi, %edi
testb $0x1, %al
movq 0x48(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %r15
movq -0x58(%rbp), %r8
je 0x2d542
jmp 0x2d61a
xorl %eax, %eax
movq 0x48(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rsi
movq -0x100(%rbp), %r8
cmpq %rax, %r8
je 0x2d534
movsd (%rsi,%rax,8), %xmm0
movq -0xb8(%rbp), %rdi
movsd %xmm0, (%rdi,%rax,8)
incq %rax
jmp 0x2d519
movaps -0x120(%rbp), %xmm0
movaps %xmm0, -0x130(%rbp)
xorl %eax, %eax
movq -0xf8(%rbp), %rsi
cmpq %rax, %rsi
je 0x2d565
movss (%rdx,%rax,4), %xmm0
subss (%rcx,%rax,4), %xmm0
movss %xmm0, (%r14,%rax,4)
incq %rax
jmp 0x2d54b
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0x2d5a5
movq -0x60(%rbp), %rax
movslq (%rax,%rbx,4), %r15
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
movq -0xb0(%rbp), %rdx
movq -0x90(%rbp), %rcx
callq 0xfd1e
movq -0x68(%rbp), %rax
movss %xmm0, (%rax,%r15,4)
incq %rbx
jmp 0x2d567
movaps -0x120(%rbp), %xmm0
ucomiss -0x70(%rbp), %xmm0
jbe 0x2d5e1
xorl %eax, %eax
movq 0x48(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %r15
movq -0x58(%rbp), %r8
movq -0x100(%rbp), %rsi
cmpq %rax, %rsi
je 0x2d5f6
movsd (%r15,%rax,8), %xmm0
movsd %xmm0, (%r8,%rax,8)
incq %rax
jmp 0x2d5cb
pushq $0x1
popq %rdi
movq 0x48(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %r15
movq -0x58(%rbp), %r8
jmp 0x2d61a
pushq $0x1
popq %rdi
movaps -0x120(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
jmp 0x2d61a
movq 0x48(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x58(%rbp), %r8
movl %r15d, %edi
movq -0x48(%rbp), %r15
movl -0xcc(%rbp), %esi
incl %esi
jmp 0x2d2af
movq %r15, %r13
movl %edi, %r15d
movq -0x88(%rbp), %rdi
leaq 0x27460(%rip), %rsi     # 0x54a9b
movsd 0x265d5(%rip), %xmm0    # 0x53c18
movl %ebx, %edx
movb $0x1, %al
callq 0x2190
movl %r15d, %edi
movq %r13, %r15
movq 0x48(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x58(%rbp), %r8
movss -0x50(%rbp), %xmm0
mulss 0x224a9(%rip), %xmm0    # 0x4fb14
cmpl $0x0, -0x3c(%rbp)
je 0x2d676
movss %xmm0, -0x50(%rbp)
xorl $0x1, -0x3c(%rbp)
movq -0x160(%rbp), %rsp
xorl %eax, %eax
jmp 0x2d251
movq -0x38(%rbp), %rax
movq 0x40(%rax), %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 %rdx, 0x48(%rsp)
movq %r15, %rsi
movq -0x80(%rbp), %r15
movl %r15d, 0x10(%rsp)
movq -0xa8(%rbp), %r12
movq %r12, 0x8(%rsp)
movq -0x108(%rbp), %rax
movq %rax, (%rsp)
xorps %xmm0, %xmm0
movq -0xa0(%rbp), %rdx
movq -0x98(%rbp), %r9
callq 0x2d8f7
addq $0x50, %rsp
movss %xmm0, -0xe0(%rbp)
leaq 0x24945(%rip), %rdi     # 0x5204b
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq -0x88(%rbp), %r14
movq %r14, %rcx
callq 0x2280
cvtss2sd -0xe0(%rbp), %xmm0
leaq 0x27396(%rip), %rsi     # 0x54ac0
movq %r14, %rdi
movl 0x68(%rbp), %ebx
movl %ebx, %edx
movb $0x1, %al
callq 0x2190
movq %r14, %rdi
callq 0x20c0
leaq 0x25a2b(%rip), %rsi     # 0x53173
xorl %r14d, %r14d
pushq $0x1
popq %rdx
movq -0xe8(%rbp), %r13
movq %r13, %rdi
xorl %eax, %eax
callq 0x2190
leaq 0x27375(%rip), %rsi     # 0x54adb
leaq -0x210(%rbp), %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x2190
movaps -0x130(%rbp), %xmm0
xorps 0x230db(%rip), %xmm0    # 0x50860
cvtss2sd %xmm0, %xmm0
leaq 0x27356(%rip), %rsi     # 0x54ae6
movq %r13, %rdi
movb $0x1, %al
callq 0x2190
leaq 0x27364(%rip), %rdi     # 0x54b05
pushq $0x2a
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x2280
leaq 0x2737a(%rip), %rsi     # 0x54b30
movq %r13, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2190
movq %rsp, %rdi
subq -0x138(%rbp), %rdi
movq %rdi, %rsp
movl %r15d, %eax
movq %rsp, %rdx
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rdx
movq %rdx, %rsp
testl %r15d, %r15d
movl $0x0, %eax
cmovgl %r15d, %eax
movq %r12, %rcx
movq %rdi, %rsi
cmpq %rax, %r14
je 0x2d82d
movl $0x3f800000, (%rdx,%r14,4) # imm = 0x3F800000
xorl %r8d, %r8d
cmpl $0xc, %r8d
je 0x2d821
cvtsd2ss (%rcx,%r8,2), %xmm0
movss %xmm0, (%rsi,%r8)
addq $0x4, %r8
jmp 0x2d809
incq %r14
addq %r8, %rsi
addq $0x70, %rcx
jmp 0x2d7f9
movq -0xa0(%rbp), %r15
movq %r15, %rsi
movq -0x80(%rbp), %rbx
movl %ebx, %ecx
callq 0x47a64
movq 0x40(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x148(%rbp), %rdx
movl -0xbc(%rbp), %ecx
callq 0x47a64
cvtsd2ss %xmm0, %xmm0
pushq $0x1
popq %r9
movq -0xe8(%rbp), %r14
movq %r14, %rdi
movq -0xa8(%rbp), %rsi
movl %ebx, %edx
movq %r15, %rcx
movq -0x150(%rbp), %r8
callq 0x2f4bd
movq %r14, %rdi
callq 0x20c0
movq -0x140(%rbp), %rsp
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
movl 0x68(%rbp), %eax
testl %eax, %eax
movl $0x0, %r12d
cmovgl %eax, %r12d
cmpq %rbx, %r12
je 0x2d1b4
movq -0x60(%rbp), %rax
movl %ebx, (%rax,%rbx,4)
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax,%rbx,8), %rsi
movq %r14, %rdi
movq -0xb0(%rbp), %rdx
movq -0x90(%rbp), %rcx
callq 0xfd1e
movq -0x68(%rbp), %rax
movss %xmm0, (%rax,%rbx,4)
incq %rbx
jmp 0x2d8b7