// File: /workspace/github_c_makefile_star2_O0/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 %r14
pushq %rbx
subq $0x2f0, %rsp            # imm = 0x2F0
movl 0x68(%rbp), %eax
movl 0x60(%rbp), %eax
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
leaq 0x10(%rbp), %rax
movq %rax, -0x260(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movl %r8d, -0x34(%rbp)
movq %r9, -0x40(%rbp)
movss %xmm0, -0x44(%rbp)
movl $0x1, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x60(%rbp)
movss 0x39003(%rip), %xmm0    # 0x7ed5c
movss %xmm0, -0x64(%rbp)
movss 0x3031a(%rip), %xmm0    # 0x76080
movss %xmm0, -0x68(%rbp)
movss 0x30329(%rip), %xmm0    # 0x7609c
movss %xmm0, -0x6c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x70(%rbp)
movss -0x64(%rbp), %xmm0
mulss -0x44(%rbp), %xmm0
movss %xmm0, -0x74(%rbp)
movss -0x68(%rbp), %xmm0
mulss -0x44(%rbp), %xmm0
movss %xmm0, -0x78(%rbp)
callq 0x49ce0
movq %rax, 0x5670e(%rip)     # 0x9c4b8
movq 0x56707(%rip), %rdi     # 0x9c4b8
callq 0x756e0
movq -0x260(%rbp), %rax
movq 0x40(%rbp), %rdi
movq 0x48(%rbp), %rsi
movq 0x10(%rax), %rdx
movl (%rax), %ecx
callq 0x70af0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x7c(%rbp)
leaq -0xe0(%rbp), %rdi
movq 0x50(%rbp), %rdx
leaq 0x39ffd(%rip), %rsi     # 0x7fde8
movb $0x0, %al
callq 0x1200
leaq -0xe0(%rbp), %rsi
leaq 0x316ee(%rip), %rdi     # 0x774ee
movb $0x0, %al
callq 0x10d0
leaq -0xe0(%rbp), %rdi
leaq 0x3655d(%rip), %rsi     # 0x7c372
callq 0x11b0
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
movq 0x50(%rbp), %rdx
leaq 0x39fcc(%rip), %rsi     # 0x7fdff
movb $0x0, %al
callq 0x1200
leaq -0xe0(%rbp), %rsi
leaq 0x316a6(%rip), %rdi     # 0x774ee
movb $0x0, %al
callq 0x10d0
leaq -0xe0(%rbp), %rdi
leaq 0x36515(%rip), %rsi     # 0x7c372
callq 0x11b0
movq %rax, -0xf0(%rbp)
leaq -0x160(%rbp), %rdi
leaq 0x39f9f(%rip), %rsi     # 0x7fe16
movb $0x0, %al
callq 0x1200
cmpl $0x0, 0x60(%rbp)
je 0x45e99
leaq -0x160(%rbp), %rdi
leaq 0x39fb3(%rip), %rsi     # 0x7fe45
callq 0x11e0
jmp 0x45eac
leaq -0x160(%rbp), %rdi
leaq 0x39fa7(%rip), %rsi     # 0x7fe4e
callq 0x11e0
movq -0xe8(%rbp), %rdi
leaq 0x39411(%rip), %rsi     # 0x7f2cb
xorl %eax, %eax
movb %al, -0x2a1(%rbp)
leaq -0x160(%rbp), %rdx
callq 0x1150
movb -0x2a1(%rbp), %al
movq -0xe8(%rbp), %rdi
leaq 0x39f77(%rip), %rsi     # 0x7fe59
callq 0x1150
movq -0xe8(%rbp), %rdi
movss -0x7c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
leaq 0x3a0a3(%rip), %rsi     # 0x7ffa1
movb $0x2, %al
movaps %xmm1, %xmm0
callq 0x1150
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x164(%rbp)
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x168(%rbp)
movl -0x164(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x170(%rbp)
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x2a0(%rbp)
movq %rcx, %rsp
movq %rax, -0x178(%rbp)
movl -0x164(%rbp), %eax
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x298(%rbp)
movq %rcx, %rsp
movq %rax, -0x180(%rbp)
movl -0x164(%rbp), %eax
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x290(%rbp)
movq %rcx, %rsp
movq %rax, -0x188(%rbp)
movl -0x168(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x288(%rbp)
movq %rcx, %rsp
movq %rax, -0x190(%rbp)
movl -0x168(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x280(%rbp)
movq %rcx, %rsp
movq %rax, -0x198(%rbp)
movl -0x34(%rbp), %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x278(%rbp)
movq %rcx, %rsp
movq %rax, -0x1a0(%rbp)
movl -0x168(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x270(%rbp)
movq %rcx, %rsp
movq %rax, -0x1a8(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x268(%rbp)
movq %rcx, %rsp
movq %rax, -0x1b0(%rbp)
movl $0x0, -0x1b4(%rbp)
movl -0x1b4(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x460d3
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x1b4(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1220
movq -0x268(%rbp), %rax
cvtsd2ss %xmm0, %xmm0
movslq -0x1b4(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
jmp 0x46080
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x164(%rbp), %eax
jge 0x46103
movq -0x2a0(%rbp), %rax
movslq -0x54(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x460da
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x168(%rbp), %eax
jge 0x46163
movq -0x270(%rbp), %rax
movq -0x280(%rbp), %rcx
movq 0x40(%rbp), %rdx
movslq -0x54(%rbp), %rsi
movss (%rdx,%rsi,4), %xmm0
movslq -0x54(%rbp), %rdx
movss %xmm0, (%rcx,%rdx,4)
movq 0x48(%rbp), %rdx
movslq -0x54(%rbp), %rsi
movss (%rdx,%rsi,4), %xmm0
movslq -0x54(%rbp), %rdx
subss (%rcx,%rdx,4), %xmm0
movslq -0x54(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x4610a
movq -0x20(%rbp), %rax
movl (%rax), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x2b8(%rbp)
movq %rcx, %rsp
movq %rax, -0x1c0(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x2b0(%rbp)
movq %rcx, %rsp
movq %rax, -0x1c8(%rbp)
cmpl $0x0, 0x60(%rbp)
jne 0x46228
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl 0x68(%rbp), %eax
jge 0x46223
movq -0x270(%rbp), %rdi
movq -0x260(%rbp), %rax
movq -0x2b8(%rbp), %rcx
movl -0x5c(%rbp), %esi
movslq -0x5c(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movq -0x20(%rbp), %rcx
movq 0x38(%rcx), %rcx
movslq -0x5c(%rbp), %rdx
movq (%rcx,%rdx,8), %rsi
movq 0x18(%rax), %rdx
movl -0x168(%rbp), %ecx
callq 0x15510
movq -0x2b0(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x461c2
jmp 0x46437
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x46282
movq -0x270(%rbp), %rdi
movq -0x260(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x38(%rcx), %rcx
movslq -0x54(%rbp), %rdx
movq (%rcx,%rdx,8), %rsi
movq 0x18(%rax), %rdx
movl -0x168(%rbp), %ecx
callq 0x15510
movq -0x2b0(%rbp), %rax
movslq -0x54(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x4622f
movq -0x20(%rbp), %rax
movl (%rax), %eax
movq %rsp, %rcx
movq %rcx, -0x1d0(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x2c0(%rbp)
movq %rcx, %rsp
movq %rax, -0x1d8(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x462e4
movq -0x2c0(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x462bc
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl 0x68(%rbp), %eax
jge 0x46310
movq -0x2b8(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x462eb
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl 0x68(%rbp), %eax
jge 0x4642d
movl $0xffffffff, -0x1dc(%rbp) # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movss %xmm0, -0x1e0(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x463d7
movq -0x2c0(%rbp), %rax
movslq -0x5c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x46361
jmp 0x463c9
cmpl $0x0, -0x1dc(%rbp)
jl 0x463a6
movq -0x2b0(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movaps 0x3610b(%rip), %xmm1    # 0x7c490
pand %xmm1, %xmm0
movss -0x1e0(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movaps 0x360f4(%rip), %xmm2    # 0x7c490
pand %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x463c7
movq -0x2b0(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl %ecx, -0x1dc(%rbp)
movslq -0x5c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x1e0(%rbp)
jmp 0x463c9
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x4633f
movss -0x1e0(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x463eb
jp 0x463eb
jmp 0x463f4
cmpl $0x0, -0x1dc(%rbp)
jge 0x463f6
jmp 0x4642d
movq -0x2b8(%rbp), %rax
movq -0x2c0(%rbp), %rcx
movslq -0x1dc(%rbp), %rdx
movl $0x1, (%rcx,%rdx,4)
movl -0x1dc(%rbp), %edx
movslq -0x54(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x46317
movq -0x1d0(%rbp), %rax
movq %rax, %rsp
movl 0x68(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x1e4(%rbp)
movl $0x1, -0x1e8(%rbp)
movl $0x0, -0x1ec(%rbp)
movss 0x386b9(%rip), %xmm0    # 0x7eb18
movss %xmm0, -0x1f0(%rbp)
movss 0x386a9(%rip), %xmm0    # 0x7eb18
movss %xmm0, -0x1f4(%rbp)
movss 0x38699(%rip), %xmm0    # 0x7eb18
movss %xmm0, -0x1f8(%rbp)
movss 0x2fbd9(%rip), %xmm0    # 0x76068
movss %xmm0, -0x200(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x208(%rbp)
movl $0x0, -0x20c(%rbp)
movl -0x20c(%rbp), %eax
cmpl -0x48(%rbp), %eax
jge 0x46baa
movl 0x68(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x218(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x2c8(%rbp)
movq %rcx, %rsp
movq %rax, -0x220(%rbp)
cmpl $0x0, -0x1ec(%rbp)
je 0x4651b
movss -0x6c(%rbp), %xmm0
movss %xmm0, -0x1fc(%rbp)
cvtsi2sdl 0x68(%rbp), %xmm0
movsd 0x2fafa(%rip), %xmm1    # 0x76008
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x50(%rbp)
jmp 0x46559
xorps %xmm0, %xmm0
movss %xmm0, -0x1fc(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl 0x68(%rbp), %eax
jge 0x46552
movq -0x2c8(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x4652d
imull $0xa, 0x68(%rbp), %eax
movl %eax, -0x50(%rbp)
movl $0x0, -0x228(%rbp)
movl -0x228(%rbp), %eax
cmpl -0x50(%rbp), %eax
jg 0x46b51
cmpl $0x0, -0x1ec(%rbp)
je 0x4661f
cvtsi2sdl 0x68(%rbp), %xmm0
movsd %xmm0, -0x2d0(%rbp)
movb $0x0, %al
callq 0x75930
movaps %xmm0, %xmm1
movsd -0x2d0(%rbp), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x22c(%rbp)
movl -0x22c(%rbp), %eax
cmpl -0x1e4(%rbp), %eax
jle 0x465c6
movl -0x1e4(%rbp), %eax
movl %eax, -0x22c(%rbp)
movq -0x2b8(%rbp), %rax
movslq -0x22c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x224(%rbp)
cmpl $0x0, -0x224(%rbp)
jge 0x465eb
jmp 0x46b3d
leaq 0x55ec6(%rip), %rdi     # 0x9c4b8
callq 0x75410
movq -0x268(%rbp), %rax
movslq -0x224(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
mulss -0x200(%rbp), %xmm0
movss %xmm0, -0x208(%rbp)
jmp 0x46741
movl $0xffffffff, -0x224(%rbp) # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movss %xmm0, -0x208(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl 0x68(%rbp), %eax
jge 0x466e7
movq -0x2b8(%rbp), %rax
movslq -0x58(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jl 0x4666f
movq -0x2c8(%rbp), %rax
movslq -0x5c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x46671
jmp 0x466d9
cmpl $0x0, -0x224(%rbp)
jl 0x466b6
movq -0x2b0(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movaps 0x35dfb(%rip), %xmm1    # 0x7c490
pand %xmm1, %xmm0
movss -0x208(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movaps 0x35de4(%rip), %xmm2    # 0x7c490
pand %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x466d7
movq -0x2b0(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl %ecx, -0x224(%rbp)
movslq -0x5c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x208(%rbp)
jmp 0x466d9
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x4663b
cmpl $0x0, -0x224(%rbp)
jl 0x46716
movss -0x208(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movaps 0x35d8d(%rip), %xmm0    # 0x7c490
pand %xmm0, %xmm1
movss -0x78(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x4673f
movq -0xe8(%rbp), %rdi
movss -0x68(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movl -0x224(%rbp), %edx
leaq 0x3974f(%rip), %rsi     # 0x7fe82
movb $0x1, %al
callq 0x1150
jmp 0x46b51
jmp 0x46741
movss -0x208(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movaps 0x35d3c(%rip), %xmm1    # 0x7c490
pand %xmm1, %xmm0
movss -0x74(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x467a2
movss -0x208(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x46786
movss -0x74(%rbp), %xmm0
movss %xmm0, -0x208(%rbp)
jmp 0x467a0
movss -0x74(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, -0x208(%rbp)
jmp 0x467a2
movl $0x0, -0x230(%rbp)
movl -0x230(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jg 0x46989
movq -0x2a0(%rbp), %r8
movq -0x288(%rbp), %rcx
movq -0x278(%rbp), %rdx
movq -0x298(%rbp), %rsi
movq -0x260(%rbp), %rax
movss -0x208(%rbp), %xmm0
movq -0x20(%rbp), %rdi
movq 0x40(%rdi), %rdi
movslq -0x224(%rbp), %r9
movq (%rdi,%r9,8), %rdi
movl -0x164(%rbp), %r9d
movq -0x28(%rbp), %r10
movq -0x30(%rbp), %r11
movl -0x34(%rbp), %ebx
movq 0x48(%rbp), %r14
subq $0x50, %rsp
movups (%rax), %xmm1
movups 0x10(%rax), %xmm2
movups 0x20(%rax), %xmm3
movq %rsp, %rax
movups %xmm3, 0x38(%rax)
movups %xmm2, 0x28(%rax)
movups %xmm1, 0x18(%rax)
movq %r14, 0x48(%rax)
movl %ebx, 0x10(%rax)
movq %r11, 0x8(%rax)
movq %r10, (%rax)
callq 0x46ef0
addq $0x50, %rsp
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, -0x204(%rbp)
movq -0xe8(%rbp), %rdi
movss -0x1f0(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x204(%rbp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
cvtss2sd %xmm1, %xmm1
movl -0x224(%rbp), %edx
movss -0x208(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x39708(%rip), %rsi     # 0x7ffb3
movb $0x3, %al
callq 0x1150
movss -0x204(%rbp), %xmm0
movss -0x1f0(%rbp), %xmm1
subss -0x1fc(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x46938
movl $0x1, -0x1e8(%rbp)
movss -0x1f0(%rbp), %xmm0
movss %xmm0, -0x1f4(%rbp)
movss -0x204(%rbp), %xmm0
movss %xmm0, -0x1f0(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x164(%rbp), %eax
jge 0x46936
movq -0x2a0(%rbp), %rax
movq -0x298(%rbp), %rcx
movslq -0x54(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movslq -0x54(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x46900
jmp 0x46989
movq -0x2c8(%rbp), %rax
movl $0x0, -0x1e8(%rbp)
movss -0x208(%rbp), %xmm0
movss 0x2f73b(%rip), %xmm1    # 0x76094
divss %xmm1, %xmm0
movss %xmm0, -0x208(%rbp)
movslq -0x224(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x46975
movl -0x230(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x230(%rbp)
jmp 0x467ac
cmpl $0x0, -0x1e8(%rbp)
jne 0x46997
jmp 0x46b3d
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x168(%rbp), %eax
jge 0x469fa
movq -0x270(%rbp), %rax
movq -0x288(%rbp), %rcx
movq -0x280(%rbp), %rdx
movslq -0x54(%rbp), %rsi
movss (%rcx,%rsi,4), %xmm0
movslq -0x54(%rbp), %rsi
movss %xmm0, (%rdx,%rsi,4)
movq 0x48(%rbp), %rdx
movslq -0x54(%rbp), %rsi
movss (%rdx,%rsi,4), %xmm0
movslq -0x54(%rbp), %rdx
subss (%rcx,%rdx,4), %xmm0
movslq -0x54(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x4699e
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl 0x68(%rbp), %eax
jge 0x46a62
movq -0x270(%rbp), %rdi
movq -0x260(%rbp), %rax
movq -0x2b8(%rbp), %rcx
movslq -0x54(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x5c(%rbp)
movq -0x20(%rbp), %rcx
movq 0x38(%rcx), %rcx
movslq -0x5c(%rbp), %rdx
movq (%rcx,%rdx,8), %rsi
movq 0x18(%rax), %rdx
movl -0x168(%rbp), %ecx
callq 0x15510
movq -0x2b0(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x46a01
movss -0x204(%rbp), %xmm0
ucomiss -0x1f8(%rbp), %xmm0
jbe 0x46ac2
movss -0x204(%rbp), %xmm0
movss %xmm0, -0x1f8(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x164(%rbp), %eax
jge 0x46ac0
movq -0x290(%rbp), %rax
movq -0x298(%rbp), %rcx
movslq -0x54(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movslq -0x54(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x46a8a
jmp 0x46ac2
movss -0x1f4(%rbp), %xmm0
subss -0x1f0(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movaps 0x359b3(%rip), %xmm0    # 0x7c490
pand %xmm0, %xmm1
movss -0x70(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x46b3b
cmpl $0x0, -0x1ec(%rbp)
jne 0x46b3b
movq -0xe8(%rbp), %rdi
movss -0x1f4(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x1f0(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x39388(%rip), %rsi     # 0x7fea7
movb $0x2, %al
callq 0x1150
movq -0x2c8(%rbp), %rax
movslq -0x224(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x46b3d
movl -0x228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
jmp 0x46563
cmpl $0x0, -0x1ec(%rbp)
je 0x46b82
movl $0x0, -0x1ec(%rbp)
movss -0x200(%rbp), %xmm0
movss 0x2f520(%rip), %xmm1    # 0x76094
divss %xmm1, %xmm0
movss %xmm0, -0x200(%rbp)
jmp 0x46b8c
movl $0x1, -0x1ec(%rbp)
movq -0x218(%rbp), %rax
movq %rax, %rsp
movl -0x20c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20c(%rbp)
jmp 0x464ac
movq -0x290(%rbp), %r8
movq -0x288(%rbp), %rcx
movq -0x278(%rbp), %rdx
movq -0x298(%rbp), %rsi
movq -0x260(%rbp), %rax
movq -0x20(%rbp), %rdi
movq 0x40(%rdi), %rdi
movq (%rdi), %rdi
movl -0x164(%rbp), %r9d
movq -0x28(%rbp), %r10
movq -0x30(%rbp), %r11
movl -0x34(%rbp), %ebx
movq 0x48(%rbp), %r14
subq $0x50, %rsp
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movq %rsp, %rax
movups %xmm2, 0x38(%rax)
movups %xmm1, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movq %r14, 0x48(%rax)
movl %ebx, 0x10(%rax)
movq %r11, 0x8(%rax)
movq %r10, (%rax)
xorps %xmm0, %xmm0
callq 0x46ef0
addq $0x50, %rsp
movaps 0x38133(%rip), %xmm1    # 0x7ed60
movaps %xmm1, -0x300(%rbp)
pxor %xmm1, %xmm0
movss %xmm0, -0x204(%rbp)
movq -0xe8(%rbp), %rdi
leaq 0x36746(%rip), %rsi     # 0x7d394
xorl %eax, %eax
movb %al, -0x2e1(%rbp)
callq 0x1150
movaps -0x300(%rbp), %xmm1
movq -0xe8(%rbp), %rdi
movl 0x68(%rbp), %edx
movss -0x204(%rbp), %xmm0
pxor %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3924b(%rip), %rsi     # 0x7fece
movb $0x1, %al
movb %al, -0x2e2(%rbp)
callq 0x1150
movq -0xe8(%rbp), %rdi
callq 0x10a0
movb -0x2e1(%rbp), %al
movl -0x60(%rbp), %ecx
incl %ecx
movl %ecx, -0x60(%rbp)
movq -0xf0(%rbp), %rdi
movl -0x60(%rbp), %edx
leaq 0x3776a(%rip), %rsi     # 0x7e425
callq 0x1150
movb -0x2e1(%rbp), %al
movq -0xf0(%rbp), %rdi
leaq 0x39215(%rip), %rsi     # 0x7fee9
leaq -0x160(%rbp), %rdx
callq 0x1150
movaps -0x300(%rbp), %xmm1
movb -0x2e2(%rbp), %al
movq -0xf0(%rbp), %rdi
movss -0x1f0(%rbp), %xmm0
pxor %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x391e9(%rip), %rsi     # 0x7fef4
callq 0x1150
movb -0x2e1(%rbp), %al
movq -0xf0(%rbp), %rdi
leaq 0x391ef(%rip), %rsi     # 0x7ff13
callq 0x1150
movb -0x2e1(%rbp), %al
movq -0xf0(%rbp), %rdi
movl 0x68(%rbp), %edx
leaq 0x391fe(%rip), %rsi     # 0x7ff3e
callq 0x1150
movl -0x34(%rbp), %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
movl %eax, %ecx
leaq 0xf(,%rcx,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rax
subq %rdx, %rax
movq %rax, -0x2e0(%rbp)
movq %rax, %rsp
movq %rcx, -0x238(%rbp)
movq %rax, -0x240(%rbp)
movl -0x34(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x2d8(%rbp)
movq %rcx, %rsp
movq %rax, -0x248(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x46e46
movq -0x2d8(%rbp), %rax
movslq -0x54(%rbp), %rcx
movss 0x2f2cb(%rip), %xmm0    # 0x76090
movss %xmm0, (%rax,%rcx,4)
movq -0x30(%rbp), %rax
movslq -0x54(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x250(%rbp)
movl $0x0, -0x5c(%rbp)
cmpl $0x3, -0x5c(%rbp)
jge 0x46e36
movq -0x250(%rbp), %rax
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x240(%rbp), %rax
movss %xmm0, (%rax)
movq -0x240(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x240(%rbp)
movq -0x250(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x250(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x46de7
jmp 0x46e38
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x46da6
movq -0x278(%rbp), %rsi
movq -0x2d8(%rbp), %rdx
movq -0x2e0(%rbp), %rdi
movl -0x34(%rbp), %ecx
callq 0x70af0
movq -0x260(%rbp), %rax
movq -0x288(%rbp), %rsi
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x254(%rbp)
movq 0x40(%rbp), %rdi
movq 0x10(%rax), %rdx
movl (%rax), %ecx
callq 0x70af0
movq -0x278(%rbp), %rcx
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x254(%rbp)
movq -0xf0(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x34(%rbp), %edx
movq -0x40(%rbp), %r8
movl -0x60(%rbp), %r9d
movss -0x254(%rbp), %xmm0
callq 0x49a60
movq -0xf0(%rbp), %rdi
callq 0x10a0
movq -0x170(%rbp), %rax
movq %rax, %rsp
xorl %eax, %eax
leaq -0x10(%rbp), %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)