// File: /workspace/github_c_makefile_star2_O1/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, -0xa8(%rbp)
movl %edx, -0x70(%rbp)
movl %esi, %r15d
movq %rdi, %r14
movss %xmm0, -0x40(%rbp)
leaq 0xe0(%rbp), %r12
leaq 0x10(%rbp), %r13
movq 0x120(%rbp), %rdi
callq 0x3d457
cvtss2sd 0x39b66(%rip), %xmm1    # 0x79594
movsd 0x1160a(%rip), %xmm0    # 0x51040
addsd %xmm1, %xmm0
mulsd 0x11616(%rip), %xmm0    # 0x51058
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x39b4a(%rip)    # 0x79598
xorps %xmm0, %xmm0
cvtss2sd 0x294eb(%rip), %xmm0    # 0x68f44
callq 0x20a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x294de(%rip)    # 0x68f48
movss -0x40(%rbp), %xmm1
mulss %xmm0, %xmm1
movss %xmm1, -0x40(%rbp)
movss %xmm1, 0x39b1c(%rip)    # 0x7959c
movss 0x294c8(%rip), %xmm0    # 0x68f50
movss %xmm0, -0x54(%rbp)
movss 0x294bf(%rip), %xmm0    # 0x68f54
movss %xmm0, -0x50(%rbp)
movss 0x294b6(%rip), %xmm0    # 0x68f58
movss %xmm0, -0x4c(%rbp)
callq 0x3f68e
movq %rsp, -0x140(%rbp)
movq 0x28(%r13), %rax
movq %rax, -0x130(%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, -0x128(%rbp)
movq %r14, %rsi
movl %r15d, %edx
movq %r8, -0x48(%rbp)
callq 0x3d6db
movq %rsp, %rdi
movl 0x110(%rbp), %r8d
leaq 0xf(,%r8,4), %rax
andq $-0x10, %rax
subq %rax, %rdi
movq %rdi, %rsp
movq %rdi, -0x120(%rbp)
movq %r14, %rsi
movl %r15d, %edx
movq %rbx, -0xb0(%rbp)
movq %rbx, %rcx
movq %r8, %rbx
callq 0x40b74
movq %rax, -0x88(%rbp)
subq $0x8, %rsp
leaq -0x138(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
movl %ebx, %ecx
movq %r14, -0xc8(%rbp)
movq %r14, %r8
movq -0xa8(%rbp), %r9
pushq -0x38(%rbp)
callq 0x1fc28
addq $0x10, %rsp
xorps %xmm0, %xmm0
cvtss2sd 0x293d6(%rip), %xmm0    # 0x68f50
xorps %xmm1, %xmm1
cvtss2sd 0x293cf(%rip), %xmm1    # 0x68f54
cvtss2sd 0x293cb(%rip), %xmm2    # 0x68f58
leaq 0x1ce18(%rip), %rsi     # 0x5c9ac
leaq -0x390(%rbp), %rdi
movl 0x130(%rbp), %edx
movb $0x3, %al
callq 0x2260
movabsq $0x6f636e0974754d23, %rax # imm = 0x6F636E0974754D23
leaq -0x7d0(%rbp), %rbx
movq %rax, (%rbx)
movl $0x746e6f, 0x7(%rbx)    # imm = 0x746E6F
leaq 0x295ae(%rip), %r13     # 0x69178
leaq 0x1dc8a(%rip), %r14     # 0x5d85b
leaq -0x2c0(%rbp), %r15
xorl %r12d, %r12d
movq (%r13), %rax
movsbl (%rax,%r12), %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2260
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2240
incq %r12
cmpq $0x14, %r12
jne 0x3fbdb
leaq -0x7d0(%rbp), %r14
movq %r14, %rdi
callq 0x20d0
movw $0xa, -0x7d0(%rbp,%rax)
leaq 0x1cdd0(%rip), %rsi     # 0x5c9f5
movq $0x0, -0x38(%rbp)
leaq -0x460(%rbp), %r15
movq %r15, %rdi
movq 0x118(%rbp), %r12
movq %r12, %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x1cff1(%rip), %rsi     # 0x5cc40
leaq -0x8a0(%rbp), %r13
movl $0xc8, %edx
movq %r13, %rdi
callq 0x21a0
leaq 0x175d6(%rip), %rsi     # 0x57240
movq %r15, %rdi
callq 0x2210
leaq 0x1cd8c(%rip), %rbx     # 0x5ca05
leaq -0x390(%rbp), %rcx
movq %rax, -0xa0(%rbp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x2190
leaq 0x1cd6f(%rip), %r14     # 0x5ca10
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x20f0
leaq 0x1cd6a(%rip), %rsi     # 0x5ca22
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2260
movabsq $0x5457206d6f7266, %rax # imm = 0x5457206D6F7266
movq %rax, 0x1e(%r13)
movups 0x1cd56(%rip), %xmm0    # 0x5ca30
movaps %xmm0, (%r13)
movupd 0x1cd59(%rip), %xmm0    # 0x5ca40
movapd %xmm0, 0x10(%r13)
movq %r15, %rdi
leaq 0x17549(%rip), %rsi     # 0x57240
callq 0x2210
movq %rax, -0x98(%rbp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r13, %rdx
leaq -0x390(%rbp), %rcx
leaq -0x7d0(%rbp), %r8
xorl %eax, %eax
callq 0x2190
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, -0x6c(%rbp)
cmpl $0x2, 0x128(%rbp)
jne 0x3fef4
leaq -0x7d0(%rbp), %rax
movb $0x0, 0x4(%rax)
movl $0x736f7023, (%rax)     # imm = 0x736F7023
movl $0x1, %eax
movq %rax, -0x38(%rbp)
leaq 0x1ccf2(%rip), %rsi     # 0x5ca5b
leaq -0x2c0(%rbp), %r15
xorl %r13d, %r13d
cmpq $0x12, %r13
leaq 0x293fa(%rip), %r14     # 0x69178
ja 0x3fdb9
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 0x2260
leaq -0x7d0(%rbp), %rdi
movq %r15, %rsi
callq 0x2240
movq %rbx, %rsi
incq %r12
cmpq $0x14, %r12
jne 0x3fd84
incq %r13
incq -0x38(%rbp)
cmpq $0x14, %r13
jne 0x3fd73
leaq -0x7d0(%rbp), %r14
movq %r14, %rdi
callq 0x20d0
movw $0xa, -0x7d0(%rbp,%rax)
movups 0x1cc7b(%rip), %xmm0    # 0x5ca61
leaq -0x8a0(%rbp), %r15
movaps %xmm0, (%r15)
movups 0x1cc79(%rip), %xmm0    # 0x5ca71
movaps %xmm0, 0x10(%r15)
movups 0x1cc76(%rip), %xmm0    # 0x5ca7a
movups %xmm0, 0x19(%r15)
leaq 0x1cc7a(%rip), %rsi     # 0x5ca8a
leaq -0x460(%rbp), %r13
movq %r13, %rdi
movq 0x118(%rbp), %r12
movq %r12, %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x1740e(%rip), %rbx     # 0x57240
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2210
leaq 0x1cbc1(%rip), %rsi     # 0x5ca05
leaq -0x390(%rbp), %rcx
movq %rax, -0x38(%rbp)
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x2190
leaq 0x1cbaa(%rip), %r14     # 0x5ca10
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x20f0
movabsq $0x736e6f69746174, %rax # imm = 0x736E6F69746174
movq %rax, 0x1f(%r15)
movups 0x1cc13(%rip), %xmm0    # 0x5ca9e
movaps %xmm0, (%r15)
movupd 0x1cc17(%rip), %xmm0    # 0x5caae
movapd %xmm0, 0x10(%r15)
leaq 0x1cc21(%rip), %rsi     # 0x5cac5
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2260
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2210
movq %rax, -0x48(%rbp)
movq %rax, %rdi
leaq 0x1cb3b(%rip), %rsi     # 0x5ca05
movq %r15, %rdx
leaq -0x390(%rbp), %rcx
leaq -0x7d0(%rbp), %r8
xorl %eax, %eax
callq 0x2190
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x20f0
jmp 0x3fefc
movq $0x0, -0x48(%rbp)
movl -0x6c(%rbp), %eax
movq %rsp, %rcx
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x118(%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, -0x110(%rbp)
movq %rdx, %rsp
movq -0x88(%rbp), %rdx
leal (%rdx,%rdx,2), %ecx
movq %rsp, %rsi
subq %rax, %rsi
movq %rsi, -0x108(%rbp)
movq %rsi, %rsp
movl -0x70(%rbp), %eax
movq %rsp, %rsi
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rsi
movq %rsi, -0x100(%rbp)
movq %rsi, %rsp
leaq 0xf(,%rcx,4), %rax
andq $-0x10, %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0xf8(%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, -0xc0(%rbp)
movq %rax, %rsp
movl $0x0, -0x8c(%rbp)
movq %rsp, %r14
leaq 0xf(,%rbx,8), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
testl %edx, %edx
movl 0x130(%rbp), %r13d
jle 0x3fff3
leaq (,%rbx,8), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2110
movl 0x110(%rbp), %eax
testl %eax, %eax
movq %rbx, -0xb8(%rbp)
jle 0x409f4
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)
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd %xmm0, -0xe8(%rbp)
movl 0x110(%rbp), %eax
movl %eax, %eax
movq %rax, -0x150(%rbp)
movl %r13d, %eax
negq %rax
movq %rax, -0x148(%rbp)
xorl %ebx, %ebx
leaq 0x1b912(%rip), %rdi     # 0x5b97e
movl %ebx, %esi
xorl %eax, %eax
callq 0x20f0
movq %rsp, -0x168(%rbp)
movl %ebx, -0x74(%rbp)
movq %rbx, %rax
shlq $0x5, %rax
movq -0xb0(%rbp), %rcx
leaq (%rcx,%rax), %r12
addq $0xd, %r12
movsbl 0x6(%r12), %r15d
movb %r15b, -0x2a(%rbp)
movb $0x41, -0x29(%rbp)
movswl 0x7(%r12), %r13d
movslq %r13d, %rax
movq %rax, -0x68(%rbp)
movq %rsp, %rdi
subq -0x158(%rbp), %rdi
movq %rdi, %rsp
subq $0x8, %rsp
movq -0x88(%rbp), %rsi
leaq -0x2a(%rbp), %rdx
leaq -0x74(%rbp), %rcx
leaq -0x29(%rbp), %r8
movl $0x1, %r9d
movl 0x110(%rbp), %eax
pushq %rax
pushq -0xc8(%rbp)
pushq -0xa8(%rbp)
pushq -0xd0(%rbp)
pushq -0xd8(%rbp)
callq 0x3d8e9
addq $0x30, %rsp
movq -0x138(%rbp), %rax
movq %rbx, -0x170(%rbp)
movl (%rax,%rbx,4), %r8d
leaq -0x4b0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x1c9b2(%rip), %rsi     # 0x5cad7
movl %r15d, %edx
movq %r12, -0x160(%rbp)
movq %r12, %rcx
movl 0x130(%rbp), %r12d
xorl %eax, %eax
callq 0x2260
movq %rbx, %rdi
movq -0xa0(%rbp), %rsi
callq 0x2100
movq %rbx, %rdi
movq -0x98(%rbp), %rsi
callq 0x2100
xorl %ebx, %ebx
movq -0xc0(%rbp), %r10
movq %r13, -0x40(%rbp)
cmpq %r13, %rbx
jne 0x40188
movl $0x447a0000, %eax       # imm = 0x447A0000
movl %eax, -0x210(%rbp,%rbx,4)
movl %eax, -0x1c0(%rbp,%rbx,4)
jmp 0x40384
leaq 0x28fe9(%rip), %rax     # 0x69178
movq (%rax), %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 -0xd8(%rbp), %r8
movq -0xd0(%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 -0x130(%rbp), %rcx
movq %rcx, 0x1c0(%rsp)
movq -0x128(%rbp), %rcx
movq %rcx, 0xe8(%rsp)
movq -0x120(%rbp), %rcx
movq %rcx, 0xb0(%rsp)
movq -0xc8(%rbp), %rcx
movq %rcx, 0xa8(%rsp)
movq -0x88(%rbp), %r15
movl %r15d, 0xa0(%rsp)
movq -0xb0(%rbp), %rcx
movq %rcx, 0x98(%rsp)
movq -0xa8(%rbp), %rcx
movq %rcx, 0x90(%rsp)
movq %r9, 0x88(%rsp)
movq %r8, 0x80(%rsp)
leaq -0x29(%rbp), %rcx
movq %rcx, 0x70(%rsp)
leaq -0x74(%rbp), %rcx
movq %rcx, 0x68(%rsp)
leaq -0x2a(%rbp), %rcx
movq %rcx, 0x60(%rsp)
movl -0x70(%rbp), %ecx
movl %ecx, 0x58(%rsp)
movq -0x100(%rbp), %rcx
movq %rcx, 0x50(%rsp)
movl -0x6c(%rbp), %ecx
movl %ecx, 0x48(%rsp)
movq -0x108(%rbp), %rcx
movq %rcx, 0x40(%rsp)
movq -0x110(%rbp), %rcx
movq %rcx, 0x38(%rsp)
movq -0x118(%rbp), %rcx
movq %rcx, 0x30(%rsp)
leaq -0xdc(%rbp), %rcx
movq %rcx, 0x28(%rsp)
movl %r15d, 0x20(%rsp)
movl $0x0, %esi
movq %rsi, 0x18(%rsp)
movq %r10, 0x10(%rsp)
movq -0xf8(%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 -0x8c(%rbp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x3e7ae
movq -0x40(%rbp), %r13
movq -0xc0(%rbp), %r10
addq $0x1f0, %rsp            # imm = 0x1F0
testl %r15d, %r15d
movq -0xb8(%rbp), %rcx
jle 0x40384
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 0x40367
incq %rbx
cmpq $0x14, %rbx
jne 0x4016b
testl %r12d, %r12d
jle 0x40465
movq -0x68(%rbp), %rax
movl $0x461c4000, -0x210(%rbp,%rax,4) # imm = 0x461C4000
leaq -0x210(%rbp), %rdi
movl $0x14, %esi
leaq -0x280(%rbp), %rdx
callq 0x28211
xorpd %xmm0, %xmm0
xorl %eax, %eax
movq -0x148(%rbp), %rbx
movslq -0x234(%rbp,%rax,4), %rcx
xorps %xmm1, %xmm1
cvtss2sd -0x210(%rbp,%rcx,4), %xmm1
addsd %xmm1, %xmm0
decq %rax
cmpq %rax, %rbx
jne 0x403ce
divsd -0xe8(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x68(%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 0x28211
xorps %xmm0, %xmm0
testl %r12d, %r12d
jle 0x40454
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 0x40434
divsd -0xe8(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
jmp 0x4057e
xorpd %xmm0, %xmm0
xorl %ebx, %ebx
xorps %xmm2, %xmm2
cmpq %rbx, %r13
je 0x404c4
movsd %xmm0, -0x60(%rbp)
movss -0x210(%rbp,%rbx,4), %xmm0
xorps 0x164a8(%rip), %xmm0    # 0x56930
cvtss2sd %xmm0, %xmm0
movsd %xmm2, -0x80(%rbp)
callq 0x22a0
movsd -0x80(%rbp), %xmm2
movq -0x40(%rbp), %r13
cvtsd2ss %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
mulss -0x210(%rbp,%rbx,4), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm0, %xmm2
movsd -0x60(%rbp), %xmm0
addsd %xmm1, %xmm0
incq %rbx
cmpq $0x14, %rbx
jne 0x4046e
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
divsd %xmm0, %xmm2
xorps %xmm0, %xmm0
cvtsd2ss %xmm2, %xmm0
jne 0x404e7
jp 0x404e7
xorps %xmm0, %xmm0
movswq %r13w, %rax
movss %xmm0, -0x210(%rbp,%rax,4)
xorl %ebx, %ebx
xorpd %xmm2, %xmm2
cmpq %rbx, %r13
je 0x4055a
movss -0x1c0(%rbp,%rbx,4), %xmm0
xorps 0x16421(%rip), %xmm0    # 0x56930
cvtss2sd %xmm0, %xmm0
movsd %xmm1, -0x60(%rbp)
movsd %xmm2, -0x80(%rbp)
callq 0x22a0
movsd -0x80(%rbp), %xmm2
movq -0x40(%rbp), %r13
cvtsd2ss %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
mulss -0x1c0(%rbp,%rbx,4), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm0, %xmm2
movsd -0x60(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm1
incq %rbx
cmpq $0x14, %rbx
jne 0x404fa
ucomisd 0x10af5(%rip), %xmm1    # 0x51060
jne 0x40573
jnp 0x409e0
divsd %xmm1, %xmm2
xorps %xmm0, %xmm0
cvtsd2ss %xmm2, %xmm0
movq -0x68(%rbp), %rax
movss %xmm0, -0x1c0(%rbp,%rax,4)
xorl %ebx, %ebx
movss -0x1c0(%rbp,%rbx,4), %xmm0
ucomiss 0x10a6f(%rip), %xmm0    # 0x5100c
jb 0x405a5
sqrtss %xmm0, %xmm0
jmp 0x405aa
callq 0x21c0
cvtss2sd %xmm0, %xmm0
movq -0xa0(%rbp), %rdi
leaq 0x1c523(%rip), %rsi     # 0x5cadf
movb $0x1, %al
callq 0x2190
xorps %xmm0, %xmm0
cvtss2sd -0x210(%rbp,%rbx,4), %xmm0
movq -0x98(%rbp), %rdi
leaq 0x172e7(%rip), %rsi     # 0x578c4
movb $0x1, %al
callq 0x2190
incq %rbx
cmpq $0x14, %rbx
jne 0x4058d
movl $0xa, %edi
movq -0xa0(%rbp), %rsi
callq 0x2140
movl $0xa, %edi
movq -0x98(%rbp), %rsi
callq 0x2140
cmpl $0x2, 0x128(%rbp)
jne 0x409c0
movl $0x1, %eax
movq %rax, -0x60(%rbp)
leaq -0x151c(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0xedc(%rbp), %rax
movq %rax, -0xf0(%rbp)
xorl %ebx, %ebx
movq -0x40(%rbp), %rdi
cmpq %rdi, %rbx
je 0x408b4
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 -0x68(%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 0x28abe(%rip), %rax     # 0x69178
movq (%rax), %rax
movb (%rax,%rbx), %al
movb %al, -0x2a(%rbp)
cmpq $0x12, %rbx
ja 0x408b4
movq -0x80(%rbp), %r13
movq -0xf0(%rbp), %r15
movq -0x60(%rbp), %r12
cmpq %r12, %rdi
je 0x4089f
leaq 0x28a8c(%rip), %rax     # 0x69178
movq (%rax), %rax
movb (%rax,%r12), %al
movb %al, -0x29(%rbp)
movq -0xd8(%rbp), %rax
movq -0xd0(%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 -0x130(%rbp), %rcx
movq %rcx, 0x1c0(%rsp)
movq -0x128(%rbp), %rcx
movq %rcx, 0xe8(%rsp)
movq -0x120(%rbp), %rcx
movq %rcx, 0xb0(%rsp)
movq -0xc8(%rbp), %rcx
movq %rcx, 0xa8(%rsp)
movq -0x88(%rbp), %rsi
movl %esi, 0xa0(%rsp)
movq -0xb0(%rbp), %rcx
movq %rcx, 0x98(%rsp)
movq -0xa8(%rbp), %rcx
movq %rcx, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movq %rax, 0x80(%rsp)
leaq -0x29(%rbp), %rax
movq %rax, 0x70(%rsp)
leaq -0x74(%rbp), %rax
movq %rax, 0x68(%rsp)
leaq -0x2a(%rbp), %rax
movq %rax, 0x60(%rsp)
movl -0x70(%rbp), %eax
movl %eax, 0x58(%rsp)
movq -0x100(%rbp), %rax
movq %rax, 0x50(%rsp)
movl -0x6c(%rbp), %eax
movl %eax, 0x48(%rsp)
movq -0x108(%rbp), %rax
movq %rax, 0x40(%rsp)
movq -0x110(%rbp), %rax
movq %rax, 0x38(%rsp)
movq -0x118(%rbp), %rax
movq %rax, 0x30(%rsp)
leaq -0xdc(%rbp), %rax
movq %rax, 0x28(%rsp)
movl %esi, 0x20(%rsp)
movl $0x0, %ecx
movq %rcx, 0x18(%rsp)
movq -0xc0(%rbp), %rax
movq %rax, 0x10(%rsp)
movq -0xf8(%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 -0x8c(%rbp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x3e7ae
movq -0x40(%rbp), %rdi
addq $0x1f0, %rsp            # imm = 0x1F0
incq %r12
addq $0x4, %r15
addq $0x4, %r13
cmpq $0x14, %r12
jne 0x406dc
incq %rbx
incq -0x60(%rbp)
addq $0x54, -0xf0(%rbp)
addq $0x54, -0x80(%rbp)
cmpq $0x14, %rbx
jne 0x40644
leaq 0x2889f(%rip), %rax     # 0x69178
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movsbl (%rax,%rcx), %edx
leaq -0x230(%rbp), %rbx
movq %rbx, %rdi
leaq 0x18ade(%rip), %rsi     # 0x593d3
movq -0x160(%rbp), %rcx
xorl %eax, %eax
callq 0x2260
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 0x40993
movl $0x1, %r13d
xorps %xmm0, %xmm0
cvtss2sd (%r15,%r13,4), %xmm0
ucomisd 0x10717(%rip), %xmm0    # 0x51060
jb 0x40951
sqrtsd %xmm0, %xmm0
jmp 0x40956
callq 0x2290
movq -0x38(%rbp), %rdi
leaq 0x1c17e(%rip), %rsi     # 0x5cadf
movb $0x1, %al
callq 0x2190
xorps %xmm0, %xmm0
cvtss2sd (%rbx,%r13,4), %xmm0
movq -0x48(%rbp), %rdi
leaq 0x16f48(%rip), %rsi     # 0x578c4
movb $0x1, %al
callq 0x2190
leaq (%r12,%r13), %rax
incq %rax
incq %r13
cmpq $0x14, %rax
jne 0x40938
incq %r12
addq $0x54, %r15
addq $0x54, %rbx
cmpq $0x14, %r12
jne 0x4092c
movl $0xa, %edi
movq -0x38(%rbp), %rsi
callq 0x2140
movl $0xa, %edi
movq -0x48(%rbp), %rsi
callq 0x2140
movq -0x168(%rbp), %rsp
movq -0x170(%rbp), %rbx
incq %rbx
cmpq -0x150(%rbp), %rbx
jne 0x40065
jmp 0x409f4
movq -0x68(%rbp), %rax
movl $0x0, -0x1c0(%rbp,%rax,4)
jmp 0x4058b
movq -0xa0(%rbp), %rdi
callq 0x20c0
movq -0x98(%rbp), %rdi
callq 0x20c0
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x40a1a
callq 0x20c0
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x40a28
callq 0x20c0
movl 0x110(%rbp), %eax
movq %rax, %rcx
leal (%rax,%rax,8), %eax
leal (%rcx,%rax,2), %r15d
leaq 0x1c0a6(%rip), %rsi     # 0x5cae5
leaq -0x460(%rbp), %rbx
movq %rbx, %rdi
movq 0x118(%rbp), %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x167e2(%rip), %rsi     # 0x57240
movq %rbx, %rdi
callq 0x2210
movq %rax, %r12
leaq 0x1c08a(%rip), %rdi     # 0x5cafa
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x1c0a4(%rip), %rdi     # 0x5cb25
movl $0x22, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2280
leaq 0x1c0ae(%rip), %rsi     # 0x5cb48
movq %r12, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x2190
leaq 0x1c0c7(%rip), %rdi     # 0x5cb75
movl $0x2f, %esi
movl $0x1, %edx
movq %r12, -0x38(%rbp)
movq %r12, %rcx
callq 0x2280
cmpl $0x0, -0x88(%rbp)
jle 0x40b4b
cvtsi2sd %r15d, %xmm0
movsd %xmm0, -0x48(%rbp)
shlq $0x2, -0xb8(%rbp)
movl $0x1, %r15d
xorl %r12d, %r12d
movq -0xb0(%rbp), %rax
movsbl 0x13(%rax,%r12,8), %r13d
movq -0x138(%rbp), %rax
movl (%rax,%r12), %ebx
movsd (%r14,%r12,2), %xmm0
divsd -0x48(%rbp), %xmm0
ucomisd 0x1054d(%rip), %xmm0    # 0x51060
jb 0x40b1b
sqrtsd %xmm0, %xmm0
jmp 0x40b20
callq 0x2290
movq -0x38(%rbp), %rdi
leaq 0x1c07a(%rip), %rsi     # 0x5cba5
movl %r13d, %edx
movl %r15d, %ecx
movl %ebx, %r8d
movb $0x1, %al
callq 0x2190
addq $0x4, %r12
incl %r15d
cmpq %r12, -0xb8(%rbp)
jne 0x40ae8
movq -0x38(%rbp), %rdi
callq 0x20c0
movl $0xa, %edi
callq 0x2060
movq -0x140(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq