// File: /workspace/github_c_makefile_star2_O1/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, -0x4c(%rbp)
movq %r9, -0x130(%rbp)
movq %r8, -0x78(%rbp)
movq %rcx, -0xa8(%rbp)
movq %rdx, -0xe0(%rbp)
movq %rsi, -0x38(%rbp)
movl 0x60(%rbp), %r13d
movq 0x48(%rbp), %r15
movq 0x40(%rbp), %r14
movq 0x50(%rbp), %rbx
callq 0x32e47
movq %rax, 0x491b6(%rip)     # 0x794f8
movq %rax, %rdi
callq 0x5050c
movq 0x20(%rbp), %rdx
movl 0x10(%rbp), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rdx, -0x128(%rbp)
movl %ecx, -0xbc(%rbp)
callq 0x4e010
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x30(%rbp)
leaq 0x2a78d(%rip), %rsi     # 0x5ab06
leaq -0x250(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x21947(%rip), %r15     # 0x51cdb
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x26e98(%rip), %r12     # 0x57240
movq %r14, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, -0x70(%rbp)
leaq 0x2a75f(%rip), %rsi     # 0x5ab1d
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 %r12, %rsi
callq 0x2210
movq %rax, %r15
movups 0x2a766(%rip), %xmm0    # 0x5ab53
leaq -0x1e0(%rbp), %rdi
movups %xmm0, 0x1f(%rdi)
movups 0x2a745(%rip), %xmm0    # 0x5ab44
movaps %xmm0, 0x10(%rdi)
movups 0x2a72a(%rip), %xmm0    # 0x5ab34
movaps %xmm0, (%rdi)
callq 0x20d0
addq %rbp, %rax
addq $-0x1e0, %rax           # imm = 0xFE20
testl %r13d, %r13d
je 0x30433
movabsq $0x70616c7265766f20, %rcx # imm = 0x70616C7265766F20
movq %rcx, (%rax)
movb $0x0, 0x8(%rax)
jmp 0x30447
movabsq $0x6e65757165726620, %rcx # imm = 0x6E65757165726620
movq %rcx, (%rax)
movl $0x79636e, 0x7(%rax)    # imm = 0x79636E
leaq 0x29d6c(%rip), %rsi     # 0x5a1ba
leaq -0x1e0(%rbp), %rdx
movq -0x70(%rbp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2190
leaq 0x2a704(%rip), %rdi     # 0x5ab6e
movl $0x28, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2280
xorps %xmm0, %xmm0
cvtss2sd -0x30(%rbp), %xmm0
leaq 0x2a7fc(%rip), %rsi     # 0x5ac87
movq %rbx, %rdi
movaps %xmm0, %xmm1
movb $0x2, %al
callq 0x2190
movq %rsp, -0x118(%rbp)
movq -0x38(%rbp), %rdx
movl 0x8(%rdx), %eax
movl 0xc(%rdx), %esi
movq %rsp, %rcx
movq %rax, -0x68(%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, -0x80(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xc8(%rbp)
movq %rcx, %rsp
movq %rsp, %rcx
movq %rsi, -0x58(%rbp)
leaq 0xf(,%rsi,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), %rsi
andq $-0x10, %rsi
movq %rsp, %rcx
movq %rsi, -0x110(%rbp)
subq %rsi, %rcx
movq %rcx, -0xb0(%rbp)
movq %rcx, %rsp
movq %rsp, %r14
subq %rax, %r14
movq %r14, %rsp
movl (%rdx), %ebx
testl %ebx, %ebx
movq 0x48(%rbp), %r12
movq %r14, -0xd8(%rbp)
jle 0x3057d
xorl %r14d, %r14d
xorps %xmm1, %xmm1
movq 0x28(%rdx), %rax
movss (%rax,%r14,4), %xmm0
ucomiss %xmm1, %xmm0
jae 0x3056b
callq 0x21c0
xorps %xmm1, %xmm1
movq -0x38(%rbp), %rdx
incq %r14
movslq (%rdx), %rbx
cmpq %rbx, %r14
jl 0x30550
movq -0xd8(%rbp), %r14
movq -0x68(%rbp), %rax
testl %eax, %eax
jle 0x3059b
leaq (,%rax,8), %rdx
movq -0xb8(%rbp), %rdi
xorl %esi, %esi
callq 0x2110
movq %r15, -0x120(%rbp)
movq -0x58(%rbp), %rdx
testl %edx, %edx
movq 0x40(%rbp), %rcx
jle 0x305c9
xorl %eax, %eax
movss (%r12,%rax,4), %xmm0
subss (%rcx,%rax,4), %xmm0
movss %xmm0, (%r14,%rax,4)
incq %rax
cmpq %rax, %rdx
jne 0x305b0
movl %ebx, %eax
movq %rsp, %rcx
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x30(%rbp)
movq %rcx, %rsp
movq %rsp, %r15
subq %rax, %r15
movq %r15, %rsp
movl 0x68(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
testl %r13d, %r13d
je 0x30729
movq -0x38(%rbp), %rcx
movl (%rcx), %eax
testl %eax, %eax
jle 0x30642
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %r12
xorl %r13d, %r13d
movq -0x58(%rbp), %rbx
movq 0x38(%rcx), %rax
movq (%rax,%r13,8), %rsi
movq %r14, %rdi
movq %r12, %rdx
movl %ebx, %ecx
callq 0x10c76
movq -0x38(%rbp), %rcx
movss %xmm0, (%r15,%r13,4)
incq %r13
movslq (%rcx), %rax
cmpq %rax, %r13
jl 0x30618
movq %rsp, %r14
movl %eax, %eax
movq %rsp, %r12
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movslq (%rcx), %r13
testq %r13, %r13
jle 0x30676
leaq (,%r13,4), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x2110
movl 0x68(%rbp), %ebx
testl %ebx, %ebx
jle 0x30697
movq -0x40(%rbp), %rax
leaq (,%rax,4), %rdx
movq -0x30(%rbp), %rdi
movl $0xff, %esi
callq 0x2110
testl %ebx, %ebx
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %r8
jle 0x3071e
movl %r13d, %eax
xorl %ecx, %ecx
movaps 0x26c71(%rip), %xmm0    # 0x57320
xorps %xmm1, %xmm1
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testl %r13d, %r13d
jle 0x306fe
xorps %xmm2, %xmm2
xorl %esi, %esi
cmpl $0x0, (%r12,%rsi,4)
jne 0x306e8
testl %edx, %edx
js 0x306e0
movss (%r15,%rsi,4), %xmm3
andps %xmm0, %xmm3
movaps %xmm2, %xmm4
andps %xmm0, %xmm4
ucomiss %xmm4, %xmm3
jbe 0x306e8
movss (%r15,%rsi,4), %xmm2
movl %esi, %edx
incq %rsi
cmpq %rsi, %rax
jne 0x306c1
cmpneqss %xmm1, %xmm2
movd %xmm2, %esi
andl $0x1, %esi
jmp 0x30700
xorl %esi, %esi
testb %sil, %sil
je 0x3071e
testl %edx, %edx
js 0x3071e
movl %edx, %esi
movl $0x1, (%r12,%rsi,4)
movl %edx, (%rdi,%rcx,4)
incq %rcx
cmpq %r8, %rcx
jne 0x306b2
movq %r14, %rsp
movq %r15, %rbx
movq %r8, %rdx
jmp 0x3078c
testl %eax, %eax
movq -0x38(%rbp), %r8
movq -0x58(%rbp), %rcx
movq %r15, %rbx
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
jle 0x3078c
movq %r14, %r12
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x60(%rbp)
xorl %r13d, %r13d
movl %r13d, (%rsi,%r13,4)
movq 0x38(%r8), %rax
movq (%rax,%r13,8), %rsi
movq %r12, %rdi
movq -0x60(%rbp), %rdx
movq %r8, %r14
movq %rcx, %r15
callq 0x10c76
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r15, %rcx
movq %r14, %r8
movss %xmm0, (%rbx,%r13,4)
incq %r13
cmpq %r13, %rdx
jne 0x30752
movq %rbx, -0x90(%rbp)
movq %rsp, -0x108(%rbp)
leaq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x60(%rbp)
movq %rsp, %rsi
leaq 0xf(,%rdx,4), %rax
andq $-0x10, %rax
subq %rax, %rsi
movq %rsi, %rsp
movl 0x68(%rbp), %r14d
testl %r14d, %r14d
movq %rdx, %rbx
movq %rsi, -0x48(%rbp)
jle 0x307e2
leaq (,%rbx,4), %rdx
movq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x2110
movq -0x48(%rbp), %rsi
testl %r14d, %r14d
movq -0xa8(%rbp), %r13
movq 0x48(%rbp), %rcx
movq -0x68(%rbp), %r12
movq -0x30(%rbp), %rdx
movq -0x90(%rbp), %r15
js 0x30bbe
movss 0x29527(%rip), %xmm1    # 0x59d34
movss -0x4c(%rbp), %xmm0
mulss %xmm0, %xmm1
leal (%r14,%r14), %eax
movaps 0x2610f(%rip), %xmm2    # 0x56930
movaps %xmm1, -0x160(%rbp)
xorps %xmm1, %xmm2
movaps %xmm2, -0x150(%rbp)
mulss 0x294fe(%rip), %xmm0    # 0x59d38
movss %xmm0, -0x4c(%rbp)
leal (%rax,%rax,4), %eax
shlq $0x3, %r12
movq %r12, -0xd0(%rbp)
xorl %edi, %edi
testl %eax, %eax
movl $0x0, %ecx
movq %rcx, -0xe8(%rbp)
cmovlel %edi, %eax
movl %eax, -0xc0(%rbp)
movss 0x29246(%rip), %xmm0    # 0x59ab4
movaps 0x26aab(%rip), %xmm2    # 0x57320
movss %xmm0, -0x50(%rbp)
movaps %xmm0, %xmm3
testl %r14d, %r14d
jle 0x308c8
xorps %xmm0, %xmm0
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %eax, %eax
movslq (%rdx,%rax,4), %rcx
testq %rcx, %rcx
js 0x308be
cmpl $0x0, (%rsi,%rcx,4)
jne 0x308be
testl %r12d, %r12d
js 0x308b5
movss (%r15,%rcx,4), %xmm4
andps %xmm2, %xmm4
movaps %xmm0, %xmm1
andps %xmm2, %xmm1
ucomiss %xmm1, %xmm4
jbe 0x308be
movss (%r15,%rcx,4), %xmm0
movl %ecx, %r12d
incq %rax
cmpq %rax, %rbx
jne 0x3088d
jmp 0x308d1
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
testl %r12d, %r12d
movaps %xmm3, -0xa0(%rbp)
js 0x30bc8
movaps %xmm0, %xmm4
andps %xmm2, %xmm4
movss -0x4c(%rbp), %xmm1
ucomiss %xmm4, %xmm1
ja 0x30bc8
movaps -0x160(%rbp), %xmm1
ucomiss %xmm1, %xmm4
jbe 0x3091a
ucomiss 0x20704(%rip), %xmm0    # 0x5100c
movaps %xmm1, %xmm0
movq -0x38(%rbp), %rax
ja 0x3091e
movaps -0x150(%rbp), %xmm0
jmp 0x3091e
movq -0x38(%rbp), %rax
movaps %xmm0, -0x170(%rbp)
movl %r12d, %ebx
movaps %xmm3, %xmm2
movaps 0x25ffe(%rip), %xmm1    # 0x56930
xorps %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
movsd %xmm1, -0x138(%rbp)
movq 0x40(%rax), %rax
movq (%rax,%rbx,8), %rdi
subq $0x50, %rsp
leaq 0x10(%rbp), %rax
movups (%rax), %xmm4
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x38(%rsp)
movups %xmm1, 0x28(%rsp)
movups %xmm4, 0x18(%rsp)
movq 0x48(%rbp), %rax
movq %rax, 0x48(%rsp)
movq -0x78(%rbp), %rax
movl %eax, 0x10(%rsp)
movq %r13, 0x8(%rsp)
movq -0xe0(%rbp), %rax
movq %rax, (%rsp)
movq -0x80(%rbp), %rsi
movq -0xb0(%rbp), %rdx
movq -0x88(%rbp), %rcx
movq -0xb8(%rbp), %r8
movq -0x68(%rbp), %r14
movl %r14d, %r9d
callq 0x30e17
addq $0x50, %rsp
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
xorps 0x25f6a(%rip), %xmm0    # 0x56930
movaps %xmm0, -0x100(%rbp)
xorps %xmm2, %xmm2
cvtss2sd -0x170(%rbp), %xmm2
movq -0x70(%rbp), %rdi
leaq 0x2a2b6(%rip), %rsi     # 0x5ac99
movsd -0x138(%rbp), %xmm0
movl %r12d, %edx
movb $0x3, %al
callq 0x2190
movaps -0x100(%rbp), %xmm3
movaps -0xa0(%rbp), %xmm1
ucomiss %xmm1, %xmm3
ja 0x30a2a
movq -0x48(%rbp), %rsi
movl $0x1, (%rsi,%rbx,4)
movaps %xmm1, %xmm0
movq %r14, %r12
movq -0x58(%rbp), %rbx
movq -0x60(%rbp), %rdx
movaps 0x268f8(%rip), %xmm2    # 0x57320
jmp 0x30a83
movaps %xmm3, %xmm0
testl %r14d, %r14d
movq %r14, %r12
movq -0x58(%rbp), %rbx
movq -0x60(%rbp), %rdx
movq -0x48(%rbp), %rsi
movaps 0x268da(%rip), %xmm2    # 0x57320
jle 0x30a83
movq -0xb8(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0xd0(%rbp), %rdx
callq 0x21a0
movaps -0x100(%rbp), %xmm3
movaps -0xa0(%rbp), %xmm1
movaps 0x268ac(%rip), %xmm2    # 0x57320
movq -0x48(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x58(%rbp), %rbx
movaps %xmm3, %xmm0
ucomiss %xmm1, %xmm3
movq 0x48(%rbp), %rcx
movl 0x68(%rbp), %r14d
ja 0x30aa2
movss -0x50(%rbp), %xmm1
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rbx
jmp 0x30b9a
movaps %xmm0, -0xa0(%rbp)
testl %ebx, %ebx
movq -0x88(%rbp), %rsi
movq -0xd8(%rbp), %r15
jle 0x30ad5
xorl %eax, %eax
movss (%rcx,%rax,4), %xmm0
subss (%rsi,%rax,4), %xmm0
movss %xmm0, (%r15,%rax,4)
incq %rax
cmpq %rax, %rbx
jne 0x30abd
testl %r14d, %r14d
movq %r15, %r14
movq -0x38(%rbp), %r15
movq -0x30(%rbp), %rsi
jle 0x30b26
movq %rbx, %rcx
xorl %r12d, %r12d
movslq (%rsi,%r12,4), %r13
movq 0x38(%r15), %rax
movq (%rax,%r13,8), %rsi
movq %r14, %rdi
movq %rcx, %rbx
callq 0x10c76
movq -0x40(%rbp), %r8
movq -0x90(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rcx
movq -0x60(%rbp), %rdx
movss %xmm0, (%rdi,%r13,4)
incq %r12
cmpq %r12, %r8
jne 0x30aeb
movq -0x68(%rbp), %r12
testl %r12d, %r12d
setle %al
movss -0x50(%rbp), %xmm0
movaps -0x100(%rbp), %xmm1
ucomiss %xmm0, %xmm1
setbe %cl
orb %al, %cl
je 0x30b4c
maxss %xmm0, %xmm1
jmp 0x30b6a
movq -0xc8(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0xd0(%rbp), %rdx
callq 0x21a0
movaps -0x100(%rbp), %xmm1
movq -0xa8(%rbp), %r13
movq 0x48(%rbp), %rcx
movl 0x68(%rbp), %r14d
movq -0x30(%rbp), %rdx
movq -0x90(%rbp), %r15
movq -0x40(%rbp), %rbx
movq -0x48(%rbp), %rsi
movaps 0x2678d(%rip), %xmm2    # 0x57320
movaps -0xa0(%rbp), %xmm0
movq -0xe8(%rbp), %rdi
leal 0x1(%rdi), %eax
movss %xmm1, -0x50(%rbp)
cmpl -0xc0(%rbp), %edi
movq %rax, -0xe8(%rbp)
jne 0x3087a
jmp 0x30bf4
movss 0x28eee(%rip), %xmm0    # 0x59ab4
jmp 0x30bf4
leaq 0x29fc8(%rip), %rsi     # 0x5ab97
movsd 0x29139(%rip), %xmm0    # 0x59d10
movq -0x70(%rbp), %rdi
movl %r12d, %edx
movb $0x1, %al
callq 0x2190
movaps -0xa0(%rbp), %xmm0
movq 0x48(%rbp), %rcx
movq -0x68(%rbp), %r12
movaps %xmm0, -0xa0(%rbp)
movq -0x108(%rbp), %rsp
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 %rcx, 0x48(%rsp)
movq -0x78(%rbp), %rbx
movl %ebx, 0x10(%rsp)
movq %r13, 0x8(%rsp)
movq -0xe0(%rbp), %rax
movq %rax, (%rsp)
xorps %xmm0, %xmm0
movq -0x80(%rbp), %rsi
movq -0xb0(%rbp), %rdx
movq -0x88(%rbp), %rcx
movq -0xc8(%rbp), %r8
movl %r12d, %r9d
callq 0x30e17
addq $0x50, %rsp
movss %xmm0, -0x30(%rbp)
leaq 0x274ab(%rip), %rdi     # 0x5812b
movl $0x2, %esi
movl $0x1, %edx
movq -0x70(%rbp), %r15
movq %r15, %rcx
callq 0x2280
xorps %xmm0, %xmm0
cvtss2sd -0x30(%rbp), %xmm0
leaq 0x29f17(%rip), %rsi     # 0x5abbc
movq %r15, %rdi
movl %r14d, %edx
movb $0x1, %al
callq 0x2190
movq %r15, %rdi
callq 0x20c0
leaq 0x285a5(%rip), %rsi     # 0x59266
movq -0x120(%rbp), %r15
movq %r15, %rdi
movl $0x1, %edx
xorl %eax, %eax
callq 0x2190
leaq 0x29ef9(%rip), %rsi     # 0x5abd7
leaq -0x1e0(%rbp), %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x2190
movaps -0xa0(%rbp), %xmm0
xorps 0x25c33(%rip), %xmm0    # 0x56930
cvtss2sd %xmm0, %xmm0
leaq 0x29eda(%rip), %rsi     # 0x5abe2
movq %r15, %rdi
movb $0x1, %al
callq 0x2190
leaq 0x29ee8(%rip), %rdi     # 0x5ac01
movl $0x2a, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2280
leaq 0x29efa(%rip), %rsi     # 0x5ac2c
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2190
movq %rsp, %rdi
subq -0x110(%rbp), %rdi
movq %rdi, %rsp
movl %ebx, %eax
movq %rsp, %rdx
leaq 0xf(,%rax,4), %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, %rsp
testl %ebx, %ebx
movq 0x40(%rbp), %r14
jle 0x30da5
xorl %ecx, %ecx
movq %r13, %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 0x30d7d
incq %rcx
addq $0x70, %rsi
addq %r9, %r8
cmpq %rax, %rcx
jne 0x30d73
movq -0xb0(%rbp), %r12
movq %r12, %rsi
movq -0x78(%rbp), %rbx
movl %ebx, %ecx
callq 0x4e010
movq %r14, %rdi
movq -0x88(%rbp), %rsi
movq -0x128(%rbp), %rdx
movl -0xbc(%rbp), %ecx
callq 0x4e010
cvtsd2ss %xmm0, %xmm0
movq %r15, %rdi
movq %r13, %rsi
movl %ebx, %edx
movq %r12, %rcx
movq -0x130(%rbp), %r8
movl $0x1, %r9d
callq 0x32c92
movq %r15, %rdi
callq 0x20c0
movq -0x118(%rbp), %rsp
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq