// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/mutation.c
// Function: Predict_mutations
void Predict_mutations(struct Normal_Mode NM, float KAPPA,
		       atom *atoms, int natoms,
		       int N_axes, struct Reference Ref_kin, 
		       struct interaction *Int_list, int N_int,
		       struct residue *seq, int Nres,
		       char *nameout1, char *Mut_para,
		       int PRED_MUT, int IWT)
{
  int i_rank[20]; // For RMSD[a_wt] //IWT=3, 
  int ALLPAIR=0; if(PRED_MUT==2)ALLPAIR=1;

  // Exponent of the force for computation
  Read_pred_para(Mut_para);
  Exp=(1.+EXP_FORCE)/2;
  REXP=pow(RC, EXP_FORCE); scale_C=KAPPA*REXP;
  float C_size=C_SIZE*scale_C, C_stab=C_STAB*scale_C, C_dist=C_DIST*scale_C;
  Normalize_parameters();

  /* For all positions in the protein and all possible amino acid changes,
     predict the structural effect of the mutation */

  float *sigma2=NM.sigma2;
  /**************************************************************************
           Prepare reference atoms and determine their displacement str_diff_3
  ****************************************************************************/

  // Match any atom to closest kinetic atom
  int N_kin=Ref_kin.N_ref, N_Cart=3*N_kin, kin_atom[natoms]; 
  Match_atoms(kin_atom, atoms, natoms, Ref_kin.atom_num, N_kin);

  // Extract one reference atom per residue
  int resatom[Nres];
  int Na=Extract_reference_atoms(resatom, atoms, natoms, seq, Nres);

  // Contact list
  int *nc, **clist, **cnum;
  Get_contact_list(&nc, &clist, &cnum, Nres, atoms, Int_list, N_int);

  // Output files
  char para[200], head[800],tmp[50];
  sprintf(para, "# Mutation par.: C_SIZE= %.3g C_STAB= %.3g C_DIST=%.3g IWT=%d",
	  C_SIZE, C_STAB, C_DIST, IWT);
  strcpy(head, "#Mut\tncont");
  for(int a=0; a<20; a++){
    sprintf(tmp, "\t%c", AA_code[a]); strcat(head, tmp);
  }
  strcat(head,"\n");

  char name[200]; sprintf(name,"%s.mut_RMSD.dat", nameout1);
  char what[200]="Predicted RMSD of all mutations from WT";
  FILE *file_rmsd=fopen(name, "w");
  fprintf(file_rmsd, "# %s\n%s\n%s", what, para, head);
  printf("Writing %s in %s\n", what,name);

  sprintf(name,"%s.mut_DE.dat", nameout1);
  strcpy(what, "Predicted DE of all mutations from WT");
  FILE *file_de=fopen(name, "w");
  fprintf(file_de, "# %s\n%s\n%s", what,para,head);
  printf("Writing %s in %s\n",what, name);

  FILE *file_de_all=NULL, *file_rmsd_all=NULL;
  if(ALLPAIR){
    strcpy(head, "#pos");
    for(int a=0; a<20; a++){
      for(int b=a+1; b<20; b++){
	sprintf(tmp, "\t%c%c", AA_code[a], AA_code[b]);
	strcat(head, tmp);
      }
    }
    strcat(head,"\n");

    strcpy(what, "Predicted RMSD of all pairs of mutations");
    sprintf(name,"%s.mut_RMSD_all.dat", nameout1);
    file_rmsd_all=fopen(name, "w");
    fprintf(file_rmsd_all, "# %s\n%s\n%s", what,para,head);
    printf("Writing %s in %s\n",what, name);

    strcpy(what, "Predicted DE of all pairs of mutations");
    sprintf(name,"%s.mut_DE_all.dat", nameout1);
    file_de_all=fopen(name, "w");
    fprintf(file_de_all, "# %s\n%s\n%s", what,para,head);
    printf("Writing %s in %s\n",what, name);
  }

  FILE *file3=NULL;
  if(0){
    strcpy(what, "Predicted RMSD and DE of all mutations from WT");
    sprintf(name,"%s.mut_all.dat", nameout1);
    fopen(name, "w");
    printf("Writing %s in %s\n",what, name);
    fprintf(file3, "# %s\nRMSD DE\n", what);
  }

  FILE *file4=NULL;
  if(0){
    sprintf(what, "Predicted force of all mutations from WT");
    sprintf(name,"%s.mut_force.dat", nameout1);
    file4=fopen(name, "w");
    printf("Writing %s in %s\n",what, name);
    fprintf(file4, "# %s\n%s\n%s", what, para, head);
  }

  // Define memory
  float Force[N_Cart], Force_coeff[NM.N];
  int N3=3*Na;
  float pred_mut_Cart[N_Cart], pred_mut_Tors[N_axes],
    pred_mut_3[N3], pred_mut_2[Na]; // pred_mut_tot_2[Na];

  int Nmut=1, Posmut[1]; char AAwt[1], AAmut[1];
  float MSD_mut[20][20], MSD_cross=0, MSD[20];
  float DE_pred[20][20], DE[20];
  double RMSD_prof[Na]; for(int i=0; i<Na; i++)RMSD_prof[i]=0;
  for(int ipos=0; ipos<Nres; ipos++){
    printf("%d ",ipos);
    Posmut[0]=ipos; AAwt[0]=seq[ipos].amm; AAmut[0]='A';
    int wt=seq[ipos].i_aa;
    int mut_neigh[Na], n_cont_mut;
    Mut_neighbor(mut_neigh, Na, AAwt, Posmut, AAmut, Nmut,
		 clist, cnum, Int_list, atoms, Nres);
    char out[80]; int a, b;
    sprintf(out,"%c%s\t%d",AAwt[0],seq[ipos].pdbres, nc[ipos]); //ipos+1
    fprintf(file_rmsd,"%s",out);
    fprintf(file_de,"%s",out);
    if(file4)fprintf(file4,"%s",out);
    for(a=0; a<20; a++){
      if(a==wt){DE[a]=1000; MSD[a]=1000; continue;}
      AAmut[0]=AA_code[a];
      Pred_mut_str(C_size, C_stab, C_dist,
		   DE+a, MSD+a, &MSD_cross,
		   NULL, NULL, NULL, NULL,
		   pred_mut_3, pred_mut_2, NULL, Na,
		   &n_cont_mut, Force, Force_coeff,
		   pred_mut_Cart, N_Cart, pred_mut_Tors, N_axes, 
		   AAwt, Posmut, AAmut, Nmut,
		   clist, cnum, Int_list, seq, Na,
		   atoms, resatom, Ref_kin, kin_atom, NM, sigma2,
		   NULL, NULL, NULL, NULL);
      for(int i=0; i<Na; i++)RMSD_prof[i]+=pred_mut_2[i];
      if(file4){
	double F=0;
	if(AAmut[0]!=AAwt[0]){
	  for(int i=0; i<Na; i++)F+=Force[i]*Force[i];
	  F=sqrt(F/Na);
	}
	fprintf(file4,"\t%.2g",F);
      }
    }
    // Compute mutation to same a.a. as mean of IWT lowest ones
    if(IWT>0){
      DE[wt]=10000; f_sort(DE, 20, i_rank);
      double Y=0; for(a=0; a<IWT; a++)Y+=DE[i_rank[19-a]]; DE[wt]=Y/IWT;
      MSD[wt]=10000; f_sort(MSD, 20, i_rank);
      Y=0; for(a=0; a<IWT; a++)Y+=MSD[i_rank[19-a]]; MSD[wt]=Y/IWT;
    }else{
      double sum=0, norm=0; float *x=DE, p;
      for(a=0; a<20; a++){
	if(a!=wt){p=exp(-x[a]); sum+=x[a]*p; norm+=p;}
      }
      if(norm){x[wt]=sum/norm;}else{x[wt]=0;}
      sum=0; norm=0; x=MSD;
      for(a=0; a<20; a++){
	if(a!=wt){p=exp(-x[a]); sum+=x[a]*p; norm+=p;}
      }
      if(norm){x[wt]=sum/norm;}else{x[wt]=0;}
    }
    for(a=0; a<20; a++){
      float RMSD_mut=sqrt(MSD[a]);
      fprintf(file_rmsd,"\t%.2g",RMSD_mut);
      fprintf(file_de,"\t%.3g",DE[a]);
      if(file3)fprintf(file3,"%.2g %.3g\n", RMSD_mut, DE[a]);
    }
    fprintf(file_rmsd,"\n");
    fprintf(file_de,"\n");
    if(file3)fprintf(file3,"\n");
    if(file4)fprintf(file4,"\n");

    if(ALLPAIR){
      // Compute all pairs
      for(a=0; a<20; a++){
	if(a==wt)continue;
	DE_pred[a][wt]=DE[a];
	DE_pred[wt][a]=DE[a];
	MSD_mut[a][wt]=MSD[a];
	MSD_mut[wt][a]=MSD[a];
	AAwt[0]=AA_code[a];
	for(b=a+1; b<20; b++){
	  if(b==wt){continue;}
	  AAmut[0]=AA_code[b];
	  Pred_mut_str(C_size, C_stab, C_dist,
		       &(DE_pred[a][b]), &(MSD_mut[a][b]), &MSD_cross,
		       NULL, NULL, NULL, NULL,
		       pred_mut_3, pred_mut_2, NULL, Na,
		       &n_cont_mut, Force, Force_coeff,
		       pred_mut_Cart, N_Cart, pred_mut_Tors, N_axes, 
		       AAwt, Posmut, AAmut, Nmut,
		       clist, cnum, Int_list, seq, Na,
		       atoms, resatom, Ref_kin, kin_atom, NM, sigma2,
		       NULL, NULL, NULL, NULL);
	}
      } // end pairs
      // print all pairs
      char out[20];
      sprintf(out,"%c%s",AA_code[wt],seq[ipos].pdbres); //ipos+1
      fprintf(file_rmsd_all,"%s", out);
      fprintf(file_de_all,"%s", out);
      for(a=0; a<20; a++){
	for(b=a+1; b<20; b++){
	  fprintf(file_rmsd_all,"\t%.2g",sqrt(MSD_mut[a][b]));
	  fprintf(file_de_all,"\t%.3g",DE_pred[a][b]);
	}
      }
      fprintf(file_rmsd_all,"\n");
      fprintf(file_de_all,"\n");
    } // end ALLPAIR
  }
  fclose(file_rmsd);
  fclose(file_de);
  if(file3)fclose(file3);
  if(file4)fclose(file4);
  if(file_de_all)fclose(file_de_all);
  if(file_rmsd_all)fclose(file_rmsd_all);

  // Print profile RMSD
  int NMUT=19*Nres;
  sprintf(name,"%s.mut_prof_RMSD.dat",nameout1);
  FILE *file1=fopen(name,"w");
  printf("Printing profile of structural RMSD in %s\n",name);
  fprintf(file1,"# Profile of structural deviations");
  fprintf(file1," averaged over %d simulated point mutations\n",NMUT);
  fprintf(file1,"# 1=res 2=n_contact 3=predicted RMSD from w.t.\n");
  for(int i=0; i<Na; i++){
    fprintf(file1,"%c%d\t%d\t%.3f\n",
	    seq[i].amm, i+1, nc[i], sqrt(RMSD_prof[i]/NMUT));
  }
  fclose(file1);
  printf("\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x14f8, %rsp           # imm = 0x14F8
movq %r9, %rbx
movq %r8, -0x38(%rbp)
movq %rcx, -0x98(%rbp)
movl %edx, -0x68(%rbp)
movl %esi, %r15d
movq %rdi, %r14
movss %xmm0, -0x40(%rbp)
leaq 0xe0(%rbp), %r12
leaq 0x10(%rbp), %r13
movq 0x120(%rbp), %rdi
callq 0x3d421
cvtss2sd 0x39b60(%rip), %xmm1    # 0x79584
movsd 0x1171c(%rip), %xmm0    # 0x51148
addsd %xmm1, %xmm0
mulsd 0x11738(%rip), %xmm0    # 0x51170
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x39b44(%rip)    # 0x79588
xorps %xmm0, %xmm0
cvtss2sd 0x294f5(%rip), %xmm0    # 0x68f44
callq 0x20a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x294e8(%rip)    # 0x68f48
movss -0x40(%rbp), %xmm1
mulss %xmm0, %xmm1
movss %xmm1, -0x40(%rbp)
movss %xmm1, 0x39b16(%rip)    # 0x7958c
movss 0x294d2(%rip), %xmm0    # 0x68f50
movss %xmm0, -0x54(%rbp)
movss 0x294c9(%rip), %xmm0    # 0x68f54
movss %xmm0, -0x50(%rbp)
movss 0x294c0(%rip), %xmm0    # 0x68f58
movss %xmm0, -0x4c(%rbp)
callq 0x3f684
movq %rsp, -0x148(%rbp)
movq 0x28(%r13), %rax
movq %rax, -0x138(%rbp)
movl (%r12), %r8d
movl %r15d, %eax
movq %rsp, %rdi
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rdi
movq %rdi, %rsp
movq 0x28(%r12), %rcx
movq %rdi, -0x130(%rbp)
movq %r14, %rsi
movl %r15d, %edx
movq %r8, -0x48(%rbp)
callq 0x3d6a5
movq %rsp, %rdi
movl 0x110(%rbp), %r8d
leaq 0xf(,%r8,4), %rax
andq $-0x10, %rax
subq %rax, %rdi
movq %rdi, %rsp
movq %rdi, -0x128(%rbp)
movq %r14, %rsi
movl %r15d, %edx
movq %rbx, -0xa0(%rbp)
movq %rbx, %rcx
movq %r8, %rbx
callq 0x40b45
movq %rax, -0x78(%rbp)
subq $0x8, %rsp
leaq -0x140(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
movl %ebx, %ecx
movq %r14, -0xb8(%rbp)
movq %r14, %r8
movq -0x98(%rbp), %r9
pushq -0x38(%rbp)
callq 0x1f4d5
addq $0x10, %rsp
xorps %xmm0, %xmm0
cvtss2sd 0x293e3(%rip), %xmm0    # 0x68f50
xorps %xmm1, %xmm1
cvtss2sd 0x293dc(%rip), %xmm1    # 0x68f54
cvtss2sd 0x293d8(%rip), %xmm2    # 0x68f58
leaq 0x1cde5(%rip), %rsi     # 0x5c96c
leaq -0x390(%rbp), %rdi
movl 0x130(%rbp), %edx
movb $0x3, %al
callq 0x2270
movabsq $0x6f636e0974754d23, %rax # imm = 0x6F636E0974754D23
leaq -0x7d0(%rbp), %rbx
movq %rax, (%rbx)
movl $0x746e6f, 0x7(%rbx)    # imm = 0x746E6F
leaq 0x295bb(%rip), %r13     # 0x69178
leaq 0x1dc67(%rip), %r14     # 0x5d82b
leaq -0x2c0(%rbp), %r15
xorl %r12d, %r12d
movq (%r13), %rax
movsbl (%rax,%r12), %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2270
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2250
incq %r12
cmpq $0x14, %r12
jne 0x3fbce
leaq -0x7d0(%rbp), %r14
movq %r14, %rdi
callq 0x20d0
movw $0xa, -0x7d0(%rbp,%rax)
leaq 0x1cd9d(%rip), %rsi     # 0x5c9b5
movq $0x0, -0x38(%rbp)
leaq -0x460(%rbp), %r15
movq %r15, %rdi
movq 0x118(%rbp), %r12
movq %r12, %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x1cfbe(%rip), %rsi     # 0x5cc00
leaq -0x8a0(%rbp), %r13
movl $0xc8, %edx
movq %r13, %rdi
callq 0x21b0
leaq 0x175a3(%rip), %rsi     # 0x57200
movq %r15, %rdi
callq 0x2220
leaq 0x1cd59(%rip), %rbx     # 0x5c9c5
leaq -0x390(%rbp), %rcx
movq %rax, -0x90(%rbp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x21a0
leaq 0x1cd3c(%rip), %r14     # 0x5c9d0
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x20f0
leaq 0x1cd37(%rip), %rsi     # 0x5c9e2
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2270
movabsq $0x5457206d6f7266, %rax # imm = 0x5457206D6F7266
movq %rax, 0x1e(%r13)
movups 0x1cd23(%rip), %xmm0    # 0x5c9f0
movaps %xmm0, (%r13)
movupd 0x1cd26(%rip), %xmm0    # 0x5ca00
movapd %xmm0, 0x10(%r13)
movq %r15, %rdi
leaq 0x17516(%rip), %rsi     # 0x57200
callq 0x2220
movq %rax, -0x88(%rbp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r13, %rdx
leaq -0x390(%rbp), %rcx
leaq -0x7d0(%rbp), %r8
xorl %eax, %eax
callq 0x21a0
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x20f0
movq -0x48(%rbp), %rax
leal (%rax,%rax,2), %eax
movl %eax, -0x64(%rbp)
cmpl $0x2, 0x128(%rbp)
jne 0x3fee7
leaq -0x7d0(%rbp), %rax
movb $0x0, 0x4(%rax)
movl $0x736f7023, (%rax)     # imm = 0x736F7023
movl $0x1, %eax
movq %rax, -0x38(%rbp)
leaq 0x1ccbf(%rip), %rsi     # 0x5ca1b
leaq -0x2c0(%rbp), %r15
xorl %r13d, %r13d
cmpq $0x12, %r13
leaq 0x29407(%rip), %r14     # 0x69178
ja 0x3fdac
movq -0x38(%rbp), %r12
movq (%r14), %rax
movsbl (%rax,%r13), %edx
movsbl (%rax,%r12), %ecx
movq %r15, %rdi
movq %rsi, %rbx
xorl %eax, %eax
callq 0x2270
leaq -0x7d0(%rbp), %rdi
movq %r15, %rsi
callq 0x2250
movq %rbx, %rsi
incq %r12
cmpq $0x14, %r12
jne 0x3fd77
incq %r13
incq -0x38(%rbp)
cmpq $0x14, %r13
jne 0x3fd66
leaq -0x7d0(%rbp), %r14
movq %r14, %rdi
callq 0x20d0
movw $0xa, -0x7d0(%rbp,%rax)
movups 0x1cc48(%rip), %xmm0    # 0x5ca21
leaq -0x8a0(%rbp), %r15
movaps %xmm0, (%r15)
movups 0x1cc46(%rip), %xmm0    # 0x5ca31
movaps %xmm0, 0x10(%r15)
movups 0x1cc43(%rip), %xmm0    # 0x5ca3a
movups %xmm0, 0x19(%r15)
leaq 0x1cc47(%rip), %rsi     # 0x5ca4a
leaq -0x460(%rbp), %r13
movq %r13, %rdi
movq 0x118(%rbp), %r12
movq %r12, %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x173db(%rip), %rbx     # 0x57200
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2220
leaq 0x1cb8e(%rip), %rsi     # 0x5c9c5
leaq -0x390(%rbp), %rcx
movq %rax, -0x38(%rbp)
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x21a0
leaq 0x1cb77(%rip), %r14     # 0x5c9d0
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x20f0
movabsq $0x736e6f69746174, %rax # imm = 0x736E6F69746174
movq %rax, 0x1f(%r15)
movups 0x1cbe0(%rip), %xmm0    # 0x5ca5e
movaps %xmm0, (%r15)
movupd 0x1cbe4(%rip), %xmm0    # 0x5ca6e
movapd %xmm0, 0x10(%r15)
leaq 0x1cbee(%rip), %rsi     # 0x5ca85
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2270
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2220
movq %rax, -0x48(%rbp)
movq %rax, %rdi
leaq 0x1cb08(%rip), %rsi     # 0x5c9c5
movq %r15, %rdx
leaq -0x390(%rbp), %rcx
leaq -0x7d0(%rbp), %r8
xorl %eax, %eax
callq 0x21a0
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x20f0
jmp 0x3feef
movq $0x0, -0x48(%rbp)
movl -0x64(%rbp), %eax
movq %rsp, %rcx
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x120(%rbp)
movq %rcx, %rsp
leaq 0x10(%rbp), %rcx
movl (%rcx), %ecx
movq %rsp, %rdx
leaq 0xf(,%rcx,4), %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, -0x118(%rbp)
movq %rdx, %rsp
movq -0x78(%rbp), %rdx
leal (%rdx,%rdx,2), %ecx
movq %rsp, %rsi
subq %rax, %rsi
movq %rsi, -0x110(%rbp)
movq %rsi, %rsp
movl -0x68(%rbp), %eax
movq %rsp, %rsi
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rsi
movq %rsi, -0x108(%rbp)
movq %rsi, %rsp
leaq 0xf(,%rcx,4), %rax
andq $-0x10, %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x100(%rbp)
movq %rcx, %rsp
movl %edx, %ebx
movq %rsp, %rax
leaq 0xf(,%rbx,4), %rcx
andq $-0x10, %rcx
movq %rcx, -0x158(%rbp)
subq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq %rax, %rsp
movl $0x0, -0x7c(%rbp)
movq %rsp, %r14
leaq 0xf(,%rbx,8), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
testl %edx, %edx
movl 0x110(%rbp), %r12d
movq %r12, %r15
jle 0x3ffe3
leaq (,%rbx,8), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2110
testl %r15d, %r15d
movq %rbx, -0xa8(%rbp)
jle 0x409d0
movss -0x54(%rbp), %xmm0
movss -0x40(%rbp), %xmm1
mulss %xmm1, %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x50(%rbp), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x4c(%rbp), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, -0x4c(%rbp)
movl 0x130(%rbp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0xe8(%rbp)
movl %eax, %eax
negq %rax
movq %rax, -0x150(%rbp)
xorl %ebx, %ebx
leaq 0x1b8ea(%rip), %rdi     # 0x5b936
movl %ebx, %esi
xorl %eax, %eax
callq 0x20f0
movq %rsp, -0x168(%rbp)
movl %ebx, -0x6c(%rbp)
movq %rbx, %rax
shlq $0x5, %rax
movq -0xa0(%rbp), %rcx
leaq (%rcx,%rax), %r12
addq $0xd, %r12
movq %r15, %rax
movsbl 0x6(%r12), %r15d
movb %r15b, -0x2a(%rbp)
movb $0x41, -0x29(%rbp)
movswq 0x7(%r12), %r13
movq %rsp, %rdi
subq -0x158(%rbp), %rdi
movq %rdi, %rsp
subq $0x8, %rsp
movq -0x78(%rbp), %rsi
leaq -0x2a(%rbp), %rdx
leaq -0x6c(%rbp), %rcx
leaq -0x29(%rbp), %r8
movl $0x1, %r9d
pushq %rax
pushq -0xb8(%rbp)
pushq -0x98(%rbp)
pushq -0xc0(%rbp)
pushq -0xc8(%rbp)
callq 0x3d8b7
addq $0x30, %rsp
movq -0x140(%rbp), %rax
movq %rbx, -0x170(%rbp)
movl (%rax,%rbx,4), %r8d
leaq -0x4b0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x1c99f(%rip), %rsi     # 0x5ca97
movl %r15d, %edx
movq %r12, -0x160(%rbp)
movq %r12, %rcx
leaq 0x2906c(%rip), %r12     # 0x69178
xorl %eax, %eax
callq 0x2270
movq %rbx, %rdi
movq -0x90(%rbp), %rsi
callq 0x2100
movq %rbx, %rdi
movq -0x88(%rbp), %rsi
callq 0x2100
movq %r13, -0x60(%rbp)
movl %r13d, %edx
xorl %ebx, %ebx
movq -0xb0(%rbp), %r10
movq %rdx, -0x40(%rbp)
cmpq %rdx, %rbx
jne 0x40162
movl $0x447a0000, %eax       # imm = 0x447A0000
movl %eax, -0x210(%rbp,%rdx,4)
movl %eax, -0x1c0(%rbp,%rdx,4)
jmp 0x40352
movq (%r12), %rax
movb (%rax,%rbx), %al
movb %al, -0x29(%rbp)
leaq -0x210(,%rbx,4), %rax
addq %rbp, %rax
leaq -0x1c0(,%rbx,4), %rdx
addq %rbp, %rdx
movq -0xc8(%rbp), %r8
movq -0xc0(%rbp), %r9
subq $0x1f0, %rsp            # imm = 0x1F0
leaq 0xf0(%rsp), %rdi
movl $0x1a, %ecx
leaq 0x10(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xe0(%rbp), %rcx
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0xd8(%rsp)
movups %xmm1, 0xc8(%rsp)
movups %xmm0, 0xb8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x1d8(%rsp)
movups %xmm0, 0x1c8(%rsp)
movq -0x138(%rbp), %rcx
movq %rcx, 0x1c0(%rsp)
movq -0x130(%rbp), %rcx
movq %rcx, 0xe8(%rsp)
movq -0x128(%rbp), %rcx
movq %rcx, 0xb0(%rsp)
movq -0xb8(%rbp), %rcx
movq %rcx, 0xa8(%rsp)
movq -0x78(%rbp), %r15
movl %r15d, 0xa0(%rsp)
movq -0xa0(%rbp), %rcx
movq %rcx, 0x98(%rsp)
movq -0x98(%rbp), %rcx
movq %rcx, 0x90(%rsp)
movq %r9, 0x88(%rsp)
movq %r8, 0x80(%rsp)
leaq -0x29(%rbp), %rcx
movq %rcx, 0x70(%rsp)
leaq -0x6c(%rbp), %rcx
movq %rcx, 0x68(%rsp)
leaq -0x2a(%rbp), %rcx
movq %rcx, 0x60(%rsp)
movl -0x68(%rbp), %ecx
movl %ecx, 0x58(%rsp)
movq -0x108(%rbp), %rcx
movq %rcx, 0x50(%rsp)
movl -0x64(%rbp), %ecx
movl %ecx, 0x48(%rsp)
movq -0x110(%rbp), %rcx
movq %rcx, 0x40(%rsp)
movq -0x118(%rbp), %rcx
movq %rcx, 0x38(%rsp)
movq -0x120(%rbp), %rcx
movq %rcx, 0x30(%rsp)
leaq -0xcc(%rbp), %rcx
movq %rcx, 0x28(%rsp)
movl %r15d, 0x20(%rsp)
movl $0x0, %esi
movq %rsi, 0x18(%rsp)
movq %r10, 0x10(%rsp)
movq -0x100(%rbp), %rcx
movq %rcx, 0x8(%rsp)
movq %rsi, (%rsp)
movl $0x1, 0x78(%rsp)
movss -0x54(%rbp), %xmm0
movss -0x50(%rbp), %xmm1
movss -0x4c(%rbp), %xmm2
movq %rax, %rdi
movq %rdx, %rsi
leaq -0x7c(%rbp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x3e7ef
movq -0x40(%rbp), %rdx
movq -0xb0(%rbp), %r10
addq $0x1f0, %rsp            # imm = 0x1F0
testl %r15d, %r15d
movq -0xa8(%rbp), %rcx
jle 0x40352
xorl %eax, %eax
xorps %xmm0, %xmm0
cvtss2sd (%r10,%rax,4), %xmm0
addsd (%r14,%rax,8), %xmm0
movsd %xmm0, (%r14,%rax,8)
incq %rax
cmpq %rax, %rcx
jne 0x40335
incq %rbx
cmpq $0x14, %rbx
jne 0x40145
cmpl $0x0, 0x130(%rbp)
jle 0x40439
movq -0x60(%rbp), %rax
movl $0x461c4000, -0x210(%rbp,%rax,4) # imm = 0x461C4000
leaq -0x210(%rbp), %rdi
movl $0x14, %esi
leaq -0x280(%rbp), %rdx
callq 0x27c54
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq -0x150(%rbp), %rbx
movl 0x110(%rbp), %r15d
movslq -0x234(%rbp,%rax,4), %rcx
xorps %xmm1, %xmm1
cvtss2sd -0x210(%rbp,%rcx,4), %xmm1
addsd %xmm1, %xmm0
decq %rax
cmpq %rax, %rbx
jne 0x403a7
divsd -0xe8(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x60(%rbp), %rax
movss %xmm0, -0x210(%rbp,%rax,4)
movl $0x461c4000, -0x1c0(%rbp,%rax,4) # imm = 0x461C4000
leaq -0x1c0(%rbp), %rdi
movl $0x14, %esi
leaq -0x280(%rbp), %rdx
callq 0x27c54
xorps %xmm0, %xmm0
xorl %eax, %eax
movslq -0x234(%rbp,%rax,4), %rcx
xorps %xmm1, %xmm1
cvtss2sd -0x1c0(%rbp,%rcx,4), %xmm1
addsd %xmm1, %xmm0
decq %rax
cmpq %rax, %rbx
jne 0x40408
divsd -0xe8(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
jmp 0x40548
xorps %xmm1, %xmm1
xorl %ebx, %ebx
movl 0x110(%rbp), %r15d
cmpq %rbx, %rdx
je 0x40491
movss -0x210(%rbp,%rbx,4), %xmm0
xorps 0x10bd6(%rip), %xmm0    # 0x51030
cvtss2sd %xmm0, %xmm0
movaps %xmm1, -0xe0(%rbp)
callq 0x22b0
movq -0x40(%rbp), %rdx
cvtsd2ss %xmm0, %xmm0
movss -0x210(%rbp,%rbx,4), %xmm1
mulss %xmm0, %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtps2pd %xmm1, %xmm0
movapd -0xe0(%rbp), %xmm1
addpd %xmm0, %xmm1
incq %rbx
cmpq $0x14, %rbx
jne 0x40445
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
ucomisd 0x10cce(%rip), %xmm0    # 0x51178
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
jne 0x404bc
jp 0x404bc
xorps %xmm0, %xmm0
movq -0x60(%rbp), %rax
movss %xmm0, -0x210(%rbp,%rax,4)
xorpd %xmm1, %xmm1
xorl %ebx, %ebx
cmpq %rbx, %rdx
je 0x4051c
movss -0x1c0(%rbp,%rbx,4), %xmm0
xorps 0x10b4c(%rip), %xmm0    # 0x51030
cvtss2sd %xmm0, %xmm0
movapd %xmm1, -0xe0(%rbp)
callq 0x22b0
movq -0x40(%rbp), %rdx
cvtsd2ss %xmm0, %xmm0
movss -0x1c0(%rbp,%rbx,4), %xmm1
mulss %xmm0, %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtps2pd %xmm1, %xmm0
movapd -0xe0(%rbp), %xmm1
addpd %xmm0, %xmm1
incq %rbx
cmpq $0x14, %rbx
jne 0x404cf
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
ucomisd 0x10c43(%rip), %xmm0    # 0x51178
jne 0x4053d
jnp 0x409bc
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movq -0x60(%rbp), %rax
movss %xmm0, -0x1c0(%rbp,%rax,4)
xorl %ebx, %ebx
movss -0x1c0(%rbp,%rbx,4), %xmm0
ucomiss 0x10bb1(%rip), %xmm0    # 0x51118
jb 0x4056f
sqrtss %xmm0, %xmm0
jmp 0x40574
callq 0x21d0
cvtss2sd %xmm0, %xmm0
movq -0x90(%rbp), %rdi
leaq 0x1c519(%rip), %rsi     # 0x5ca9f
movb $0x1, %al
callq 0x21a0
xorps %xmm0, %xmm0
cvtss2sd -0x210(%rbp,%rbx,4), %xmm0
movq -0x88(%rbp), %rdi
leaq 0x172dd(%rip), %rsi     # 0x57884
movb $0x1, %al
callq 0x21a0
incq %rbx
cmpq $0x14, %rbx
jne 0x40557
movl $0xa, %edi
movq -0x90(%rbp), %rsi
callq 0x2140
movl $0xa, %edi
movq -0x88(%rbp), %rsi
callq 0x2140
cmpl $0x2, 0x128(%rbp)
jne 0x409a0
movl $0x1, %eax
movq %rax, -0xe0(%rbp)
leaq -0x151c(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0xedc(%rbp), %rax
movq %rax, -0xf0(%rbp)
xorl %ebx, %ebx
movq -0x40(%rbp), %rdi
cmpq %rdi, %rbx
je 0x40884
movss -0x210(%rbp,%rbx,4), %xmm0
movq %rbx, %rax
shlq $0x4, %rax
leaq (%rax,%rax,4), %rax
leaq (%rax,%rbp), %rcx
addq $-0xee0, %rcx           # imm = 0xF120
movq -0x60(%rbp), %rsi
movss %xmm0, (%rcx,%rsi,4)
movq %rsi, %rcx
shlq $0x4, %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rcx,%rbp), %rdx
addq $-0xee0, %rdx           # imm = 0xF120
movss %xmm0, (%rdx,%rbx,4)
movss -0x1c0(%rbp,%rbx,4), %xmm0
leaq -0x1520(%rbp,%rax), %rax
movss %xmm0, (%rax,%rsi,4)
leaq -0x1520(%rbp,%rcx), %rax
movss %xmm0, (%rax,%rbx,4)
leaq 0x28aee(%rip), %rax     # 0x69178
movq (%rax), %rax
movb (%rax,%rbx), %al
movb %al, -0x2a(%rbp)
cmpq $0x12, %rbx
ja 0x40884
movq -0xf8(%rbp), %r13
movq -0xf0(%rbp), %r15
movq -0xe0(%rbp), %r12
cmpq %r12, %rdi
je 0x4086f
leaq 0x28ab6(%rip), %rax     # 0x69178
movq (%rax), %rax
movb (%rax,%r12), %al
movb %al, -0x29(%rbp)
movq -0xc8(%rbp), %rax
movq -0xc0(%rbp), %rdx
subq $0x1f0, %rsp            # imm = 0x1F0
leaq 0xf0(%rsp), %rdi
movl $0x1a, %ecx
leaq 0x10(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xe0(%rbp), %rcx
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0xd8(%rsp)
movups %xmm1, 0xc8(%rsp)
movups %xmm0, 0xb8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x1d8(%rsp)
movups %xmm0, 0x1c8(%rsp)
movq -0x138(%rbp), %rcx
movq %rcx, 0x1c0(%rsp)
movq -0x130(%rbp), %rcx
movq %rcx, 0xe8(%rsp)
movq -0x128(%rbp), %rcx
movq %rcx, 0xb0(%rsp)
movq -0xb8(%rbp), %rcx
movq %rcx, 0xa8(%rsp)
movq -0x78(%rbp), %rsi
movl %esi, 0xa0(%rsp)
movq -0xa0(%rbp), %rcx
movq %rcx, 0x98(%rsp)
movq -0x98(%rbp), %rcx
movq %rcx, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movq %rax, 0x80(%rsp)
leaq -0x29(%rbp), %rax
movq %rax, 0x70(%rsp)
leaq -0x6c(%rbp), %rax
movq %rax, 0x68(%rsp)
leaq -0x2a(%rbp), %rax
movq %rax, 0x60(%rsp)
movl -0x68(%rbp), %eax
movl %eax, 0x58(%rsp)
movq -0x108(%rbp), %rax
movq %rax, 0x50(%rsp)
movl -0x64(%rbp), %eax
movl %eax, 0x48(%rsp)
movq -0x110(%rbp), %rax
movq %rax, 0x40(%rsp)
movq -0x118(%rbp), %rax
movq %rax, 0x38(%rsp)
movq -0x120(%rbp), %rax
movq %rax, 0x30(%rsp)
leaq -0xcc(%rbp), %rax
movq %rax, 0x28(%rsp)
movl %esi, 0x20(%rsp)
movl $0x0, %ecx
movq %rcx, 0x18(%rsp)
movq -0xb0(%rbp), %rax
movq %rax, 0x10(%rsp)
movq -0x100(%rbp), %rax
movq %rax, 0x8(%rsp)
movq %rcx, (%rsp)
movl $0x1, 0x78(%rsp)
movss -0x54(%rbp), %xmm0
movss -0x50(%rbp), %xmm1
movss -0x4c(%rbp), %xmm2
movq %r15, %rdi
movq %r13, %rsi
leaq -0x7c(%rbp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x3e7ef
movq -0x40(%rbp), %rdi
addq $0x1f0, %rsp            # imm = 0x1F0
incq %r12
addq $0x4, %r15
addq $0x4, %r13
cmpq $0x14, %r12
jne 0x406b2
incq %rbx
incq -0xe0(%rbp)
addq $0x54, -0xf0(%rbp)
addq $0x54, -0xf8(%rbp)
cmpq $0x14, %rbx
jne 0x40614
leaq 0x288c9(%rip), %rax     # 0x69178
movq (%rax), %rax
movq -0x60(%rbp), %rcx
movsbl (%rax,%rcx), %edx
leaq -0x230(%rbp), %rbx
movq %rbx, %rdi
leaq 0x18ab1(%rip), %rsi     # 0x5937c
movq -0x160(%rbp), %rcx
xorl %eax, %eax
callq 0x2270
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
callq 0x2100
movq %rbx, %rdi
movq -0x48(%rbp), %rsi
callq 0x2100
leaq -0xee0(%rbp), %rbx
leaq -0x1520(%rbp), %r15
xorl %r12d, %r12d
cmpq $0x12, %r12
ja 0x40969
movl $0x1, %r13d
xorps %xmm0, %xmm0
cvtss2sd (%r15,%r13,4), %xmm0
ucomisd 0x10859(%rip), %xmm0    # 0x51178
jb 0x40927
sqrtsd %xmm0, %xmm0
jmp 0x4092c
callq 0x22a0
movq -0x38(%rbp), %rdi
leaq 0x1c168(%rip), %rsi     # 0x5ca9f
movb $0x1, %al
callq 0x21a0
xorps %xmm0, %xmm0
cvtss2sd (%rbx,%r13,4), %xmm0
movq -0x48(%rbp), %rdi
leaq 0x16f32(%rip), %rsi     # 0x57884
movb $0x1, %al
callq 0x21a0
leaq (%r12,%r13), %rax
incq %rax
incq %r13
cmpq $0x14, %rax
jne 0x4090e
incq %r12
addq $0x54, %r15
addq $0x54, %rbx
cmpq $0x14, %r12
jne 0x40902
movl $0xa, %edi
movq -0x38(%rbp), %rsi
callq 0x2140
movl $0xa, %edi
movq -0x48(%rbp), %rsi
callq 0x2140
movl 0x110(%rbp), %r12d
movq %r12, %r15
movq -0x168(%rbp), %rsp
movq -0x170(%rbp), %rbx
incq %rbx
cmpq %r15, %rbx
jne 0x40045
jmp 0x409d0
movq -0x60(%rbp), %rax
movl $0x0, -0x1c0(%rbp,%rax,4)
jmp 0x40555
movq -0x90(%rbp), %rdi
callq 0x20c0
movq -0x88(%rbp), %rdi
callq 0x20c0
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x409f6
callq 0x20c0
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x40a04
callq 0x20c0
leal (%r15,%r15,8), %eax
leal (%r15,%rax,2), %r15d
leaq 0x1c092(%rip), %rsi     # 0x5caa5
leaq -0x460(%rbp), %rbx
movq %rbx, %rdi
movq 0x118(%rbp), %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x167ce(%rip), %rsi     # 0x57200
movq %rbx, %rdi
callq 0x2220
movq %rax, %r12
leaq 0x1c076(%rip), %rdi     # 0x5caba
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x1c090(%rip), %rdi     # 0x5cae5
movl $0x22, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2290
leaq 0x1c09a(%rip), %rsi     # 0x5cb08
movq %r12, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x21a0
leaq 0x1c0b3(%rip), %rdi     # 0x5cb35
movl $0x2f, %esi
movl $0x1, %edx
movq %r12, -0x38(%rbp)
movq %r12, %rcx
callq 0x2290
cmpl $0x0, -0x78(%rbp)
jle 0x40b1c
cvtsi2sd %r15d, %xmm0
movsd %xmm0, -0x48(%rbp)
shlq $0x2, -0xa8(%rbp)
movl $0x1, %r15d
xorl %r12d, %r12d
movq -0xa0(%rbp), %rax
movsbl 0x13(%rax,%r12,8), %r13d
movq -0x140(%rbp), %rax
movl (%rax,%r12), %ebx
movsd (%r14,%r12,2), %xmm0
divsd -0x48(%rbp), %xmm0
ucomisd 0x10694(%rip), %xmm0    # 0x51178
jb 0x40aec
sqrtsd %xmm0, %xmm0
jmp 0x40af1
callq 0x22a0
movq -0x38(%rbp), %rdi
leaq 0x1c069(%rip), %rsi     # 0x5cb65
movl %r13d, %edx
movl %r15d, %ecx
movl %ebx, %r8d
movb $0x1, %al
callq 0x21a0
addq $0x4, %r12
incl %r15d
cmpq %r12, -0xa8(%rbp)
jne 0x40ab9
movq -0x38(%rbp), %rdi
callq 0x20c0
movl $0xa, %edi
callq 0x2060
movq -0x148(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq