// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/allostery.c
// Function: Binding_sites
void Binding_sites(int *site,
		   float *Prof_dir, float **Coup_dir,
		   float *Prof_coord, float **Coup_coord,
		   float *Prof_proximity, float **Coup_proximity, 
		   float *Prof_deformation, float **Coup_deformation,
		   //float *Prof_deformation_dist,float **Coup_deformation_dist,
		   float *Prof_dr_dir, float **Coup_dr_dir,
		   int *atomres, char **pdbres, char *amm, 
		   int Na, char *chain, int Nchain,
		   struct residue *seq, int Nres,
		   char *pdb, char *nameout1, char *SITES)
{
  int numran=1000; int i, j, k;
  
  int NMAX=1000;
  int *site_res[NMAX], nres_site[NMAX];
  char *chain_res[NMAX], *description[NMAX], file_site[200];
  int PRINT_SITE=1;  // Print active site read in the PDB?
  printf("Reading binding sites\n");
  int N_sites=
    Read_sites(site_res, nres_site, chain_res, description, file_site,
	       NMAX, SITES, pdb, chain, Nchain, seq, Nres,PRINT_SITE);
  printf("%d binding sites read\n", N_sites);
  if(N_sites==0)return;

  /*
  int NMAX=1000, SMAX=80, N_sites=0;
  int nres_site[NMAX]; char *chain_res[NMAX];
  for(i=0; i<NMAX; i++)chain_res[i]=malloc(SMAX*sizeof(char));
  char *description[NMAX]; for(i=0; i<NMAX; i++)description[i]=NULL;
  int **site_res=Allocate_mat2_i(NMAX,SMAX);
  char file_site[200];
  if(SITES[0]!='\0'){
    N_sites=Read_sites_file(site_res, chain_res, nres_site, description,
			    SITES, chain, seq, Nres, NMAX, SMAX);
    if(N_sites)strcpy(file_site, SITES);
  }
  if(N_sites==0){
    N_sites=Read_sites_PDB(site_res, chain_res, nres_site, description,
			   pdb, chain, seq, Nres, NMAX, SMAX);
    if(N_sites)strcpy(file_site, pdb);
    // Print site
    if(PRINT_SITE && N_sites)
      Print_sites(site_res, nres_site, description, N_sites,
		  seq, pdb, chain);
  }
  if(N_sites==0)return;
  for(i=0; i<N_sites; i++){
    if(description[i]==NULL){
      description[i]=malloc(10*sizeof(char));
      sprintf(description[i], "site%d", i+1);
    }else{
      char *ptr=description[i];
      while(*ptr!='\0'){
	if(*ptr=='\n'){*ptr='\0'; break;} ptr++;
      } 
    }
  }
  int S_sites=0;
  for(i=0; i<N_sites; i++){
    if(nres_site[i]>0)S_sites++;
  }
  if(S_sites==0)return;
  */

  // Testing active sites
  int numcoup=5, icoup=0;
  float *prof[numcoup], **coup[numcoup];
  char name_p[numcoup][40];
  if(Coup_dir){
    prof[icoup]=Prof_dir;
    coup[icoup]=Coup_dir;
    strcpy(name_p[icoup], "directionality");
    icoup++;
  }
  if(Coup_coord){
    prof[icoup]=Prof_coord;
    coup[icoup]=Coup_coord;
    strcpy(name_p[icoup], "coordination");
    icoup++;
  }
  if(Coup_proximity){
    prof[icoup]=Prof_proximity;
    coup[icoup]=Coup_proximity;
    strcpy(name_p[icoup], "proximity");
    icoup++;
  }
  if(Coup_deformation){
    prof[icoup]=Prof_deformation;
    coup[icoup]=Coup_deformation;
    strcpy(name_p[icoup], "deformation");
    icoup++;
  }
  if(Coup_dr_dir){
    prof[icoup]=Prof_dr_dir;
    coup[icoup]=Coup_dr_dir;
    strcpy(name_p[icoup], "covariance");
    icoup++;
  }

  /*if(Coup_deformation_dist){
    prof[icoup]=Prof_deformation_dist;
    coup[icoup]=Coup_deformation_dist;
    strcpy(name_p[icoup], "deformation_dist");
    icoup++;
    }*/

  int *site_res_ran[numran];
  for(j=0; j<numran; j++)
    site_res_ran[j]=malloc(Nres*sizeof(int *));

  char nameout[200];
  sprintf(nameout, "%s.binding_sites.dat", nameout1);
  FILE *file_out=fopen(nameout, "w");
  printf("Writing %s\n", nameout);
  fprintf(file_out, "# read binding sites in file %s\n", file_site);
  fprintf(file_out, "# profile type %c\n", PROF_TYPE);
  fprintf(file_out, "# N= %d, %d random sites\n", Na, numran);
  fprintf(file_out, "### 1=nres\t2=nchain"); j=3;
  for(k=0; k<icoup; k++){
    fprintf(file_out, "\t%d=<%s_prof>\t%d=Z(%s_prof)\t%d=P>(%s_prof)",
	    j, name_p[k], j+1, name_p[k], j+2, name_p[k]); j+=3;
    if(PRINT_RAN){
      fprintf(file_out, "\t%d=E(%s_p_ran>)\t%d=sigma(%s_p_ran>)",
	      j, name_p[k], j+1, name_p[k]); j+=2;
    }
    fprintf(file_out, "\t%d=<%s_coup>\t%d=Z(%s_coup)\t%d=P>(%s_coup)",
	    j, name_p[k], j+1, name_p[k], j+2, name_p[k]); j+=3;
    if(PRINT_RAN){
      fprintf(file_out, "\t%d=E(%s_p_ran>)\t%d=sigma(%s_p_ran>)",
	      j, name_p[k], j+1, name_p[k]); j+=2;
    }
  }
  fprintf(file_out, "\n");

  // Set chains
  char res_chain[Nres]; for(i=0; i<Nres; i++)res_chain[i]=seq[i].chain;
  char lab_chain[Nres]; int ini_chain[Nres], end_chain[Nres], ichain[Nres];
  //int Nchain=
  Count_chains(ichain, ini_chain, end_chain, lab_chain,res_chain, NULL, Nres);

  struct site_results site_results[numcoup], *res;
  int atom_site[Na]; for(i=0; i<Na; i++)atom_site[i]=0;
  int min_chain[Na], max_chain[Na], all_chain[Na];
  char chain_lab[Na];
  for(i=0; i<N_sites; i++){
    int nr=nres_site[i]; //if(nr<=1)continue;
    int *isite=site_res[i];
    int nchain=Count_chains(ichain, min_chain, max_chain, chain_lab,
			    chain_res[i], isite, nr);
    Identify_chains(all_chain, chain_lab, nchain, lab_chain, Nchain);
    fprintf(file_out, "## %s\n", description[i]);
    fprintf(file_out, "%d\t%d", nr, nchain);
    for(j=0; j<numran; j++){
      Random_sites(site_res_ran[j], nr, isite,
		   ichain, min_chain, max_chain, all_chain, nchain,
		   ini_chain, end_chain);
    }
    res=site_results;
    for(k=0; k<icoup; k++){
      Test_site(res, atom_site, prof[k], coup[k], Na,
		isite, site_res_ran, numran, nr, atomres);
      fprintf(file_out, "\t%.3g\t%.1f\t%.3f",
	      res->prof, res->Z_p, res->P_p);
      if(PRINT_RAN)
	fprintf(file_out, "\t%.3g\t%.1f", res->p_ran1, res->p_ran2);
      fprintf(file_out, "\t%.3g\t%.1f\t%.3f",
	      res->coup, res->Z_c, res->P_c); //->c_ran1
      if(PRINT_RAN)
	fprintf(file_out, "\t%.3g\t%.1f", res->c_ran1, res->c_ran2);
      res++;
    }
    fprintf(file_out, "\n");
  }
  fclose(file_out);

  // Profile for binding residues
  /*float ave_p[icoup];
  for(k=0; k<icoup; k++){
    double sum=0; float *p=prof[k];
    for(i=0; i<Na; i++)sum+=p[i];
    ave_p[k]=sum/Na;
    }*/

  sprintf(nameout, "%s.binding_residues.dat", nameout1);
  file_out=fopen(nameout, "w");
  printf("Writing %s\n", nameout);
  fprintf(file_out, "#res\taa\tchain");
  for(k=0; k<icoup; k++){
    fprintf(file_out, "\t%s_p", name_p[k]);
  }
  fprintf(file_out, "\n");
  for(i=0; i<Na; i++){
    site[i]=0;
    if(atom_site[i]==0)continue;
    if(atom_site[i]<0){
      int r=-atom_site[i];
      printf("WARNING, reference atom of res. %d  %c%s%c does not exist",
	     r, seq[r].amm, seq[r].pdbres, seq[r].chain);
      continue;
    }
    site[i]=1;
    //fprintf(file_out, "%s\t%c\t%c", pdbres[i], amm[i], chain[i]);
    fprintf(file_out, "%s\t%c\t%c", seq[i].pdbres, seq[i].amm, seq[i].chain);
    for(k=0; k<icoup; k++){
      fprintf(file_out, "\t%.3g", prof[k][i]); ///ave_p[k]
    }
    fprintf(file_out, "\n");
  }
  fclose(file_out);

  // Test pairs of sites
  if(N_sites<2){
    for(j=0; j<numran; j++)free(site_res_ran[j]);
    return;
  }
  sprintf(nameout, "%s.pairs_sites.dat", nameout1);
  printf("Writing %s\n", nameout);
  file_out=fopen(nameout, "w");
  fprintf(file_out, "# read binding sites in file %s\n", file_site);
  fprintf(file_out, "# profile type %c\n", PROF_TYPE);
  fprintf(file_out, "# N= %d, %d random sites\n", Na, numran);
  fprintf(file_out, "###1=nres1\t2=nres2\t3=overlap"); j=4;
  for(k=0; k<icoup; k++){
    fprintf(file_out, "\t%d=<%s_coup>\t%d=Z(%s_coup)\t%d=P>(%s_coup)",
	    j, name_p[k], j+1, name_p[k], j+2, name_p[k]); j+=3;
  }
  fprintf(file_out, "\n");

  int coupled_site[Nres];
  char chain_site[Nres];
  for(i=0; i<N_sites; i++){
    int n1=nres_site[i]; if(n1<=0)continue;
    int *isite=site_res[i];
    for(k=0; k<n1; k++){
      coupled_site[k]=isite[k]; chain_site[k]=chain_res[i][k];
    }
    for(j=i+1; j<N_sites; j++){
      int n2=nres_site[j]; if(n2<=0)continue;
      int *jsite=site_res[j], l=n1;
      for(k=0; k<n2; k++){
	coupled_site[l]=jsite[k]; chain_site[l]=chain_res[j][k]; l++;
      }
      int nchain=Count_chains(ichain, min_chain, max_chain, chain_lab,
			      chain_site, coupled_site, l);
      Identify_chains(all_chain, chain_lab, nchain, lab_chain, Nchain);
      for(k=0; k<numran; k++){
	Random_sites(site_res_ran[k], l, coupled_site,
		     ichain, min_chain, max_chain, all_chain, nchain,
		     ini_chain, end_chain);
      }
      fprintf(file_out, "## %s\t%s", description[i], description[j]);
      if(Nchain>1)fprintf(file_out, "\t%d chains", nchain);
      fprintf(file_out, "\n");
      int q=Site_overlap(isite, n1, jsite, n2);
      fprintf(file_out, "%d\t%d\t%d", n1, n2, q);
      res=site_results;
      for(k=0; k<icoup; k++){
	Test_pairs(res, atom_site, prof[k], coup[k], Na,
		   coupled_site, site_res_ran, numran, n1, l, atomres);
	fprintf(file_out, "\t%.3g\t%.1f\t%.3f",
		res->coup, res->Z_c, res->P_c);
	res++;
      }
      fprintf(file_out, "\n");
    }
  }
  fclose(file_out);
  for(j=0; j<numran; j++)free(site_res_ran[j]);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6fe8, %rsp           # imm = 0x6FE8
movq %r9, -0x38(%rbp)
movq %r8, -0x40(%rbp)
movq %rcx, -0x58(%rbp)
movq %rdx, %r12
movq %rsi, -0x50(%rbp)
movq %rdi, -0x98(%rbp)
movl 0x70(%rbp), %ebx
movl 0x60(%rbp), %r14d
movq 0x78(%rbp), %r15
movq 0x58(%rbp), %r13
leaq 0x18e30(%rip), %rdi     # 0x5dc7f
callq 0x2090
subq $0x8, %rsp
leaq -0x7010(%rbp), %rdi
leaq -0x1250(%rbp), %rsi
leaq -0x50d0(%rbp), %rdx
leaq -0x3190(%rbp), %rcx
leaq -0x2b0(%rbp), %r8
movl $0x3e8, %r9d            # imm = 0x3E8
pushq $0x1
pushq %rbx
pushq 0x68(%rbp)
pushq %r14
pushq %r13
pushq %r15
pushq 0x88(%rbp)
callq 0x487e7
addq $0x40, %rsp
movl %eax, %ebx
leaq 0x187c4(%rip), %rdi     # 0x5d669
movq $0x0, -0x30(%rbp)
movl %eax, %esi
xorl %eax, %eax
callq 0x20f0
movl %ebx, -0x88(%rbp)
testl %ebx, %ebx
je 0x45c01
movq %rsp, %r11
addq $-0x30, %r11
movq %r11, %rsp
movq %rsp, %r9
addq $-0x30, %r9
movq %r9, %rsp
movq %rsp, %r10
addq $-0xd0, %r10
movq %r10, %rsp
testq %r12, %r12
je 0x44f18
movq -0x50(%rbp), %rax
movq %rax, (%r11)
movq %r12, (%r9)
movabsq $0x7974696c616e6f, %rax # imm = 0x7974696C616E6F
movq %rax, 0x7(%r10)
movabsq $0x6f69746365726964, %rax # imm = 0x6F69746365726964
movq %rax, (%r10)
movl $0x1, %eax
movq %rax, -0x30(%rbp)
movq 0x10(%rbp), %rax
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x44f65
movq -0x30(%rbp), %rsi
movl %esi, %ecx
leal (,%rsi,8), %edx
movq -0x58(%rbp), %r8
movq %r8, (%r11,%rdx)
movq %rdi, (%r9,%rdx)
leaq (%rcx,%rcx,4), %rcx
movabsq $0x6e6f6974616e69, %rdx # imm = 0x6E6F6974616E69
movq %rdx, 0x5(%r10,%rcx,8)
movabsq $0x616e6964726f6f63, %rdx # imm = 0x616E6964726F6F63
movq %rdx, (%r10,%rcx,8)
incl %esi
movq %rsi, -0x30(%rbp)
movq 0x20(%rbp), %rcx
testq %rax, %rax
je 0x44fa7
movq -0x30(%rbp), %rdi
movl %edi, %edx
leal (,%rdi,8), %esi
movq -0x38(%rbp), %r8
movq %r8, (%r11,%rsi)
movq %rax, (%r9,%rsi)
leaq (%rdx,%rdx,4), %rax
movabsq $0x74696d69786f7270, %rdx # imm = 0x74696D69786F7270
movq %rdx, (%r10,%rax,8)
movw $0x79, 0x8(%r10,%rax,8)
incl %edi
movq %rdi, -0x30(%rbp)
movq 0x30(%rbp), %rax
testq %rcx, %rcx
je 0x44fed
movq 0x18(%rbp), %rdx
movq -0x30(%rbp), %r8
movl %r8d, %esi
leal (,%r8,8), %edi
movq %rdx, (%r11,%rdi)
movq %rcx, (%r9,%rdi)
leaq (%rsi,%rsi,4), %rcx
movabsq $0x74616d726f666564, %rdx # imm = 0x74616D726F666564
movq %rdx, (%r10,%rcx,8)
movl $0x6e6f69, 0x8(%r10,%rcx,8) # imm = 0x6E6F69
incl %r8d
movq %r8, -0x30(%rbp)
testq %rax, %rax
movq %r11, -0x68(%rbp)
movq %r10, -0x60(%rbp)
je 0x45034
movq 0x28(%rbp), %rcx
movq -0x30(%rbp), %rdi
movl %edi, %edx
leal (,%rdi,8), %esi
movq %rcx, (%r11,%rsi)
movq %rax, (%r9,%rsi)
leaq (%rdx,%rdx,4), %rax
movabsq $0x6e61697261766f63, %rcx # imm = 0x6E61697261766F63
movq %rcx, (%r10,%rax,8)
movl $0x65636e, 0x7(%r10,%rax,8) # imm = 0x65636E
incl %edi
movq %rdi, -0x30(%rbp)
movq %r9, -0x110(%rbp)
movq %rsp, %r15
addq $-0x1f40, %r15          # imm = 0xE0C0
movq %r15, %rsp
movl 0x70(%rbp), %eax
movslq %eax, %rbx
shlq $0x3, %rbx
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x21e0
movq %rax, (%r15,%r14,8)
incq %r14
cmpq $0x3e8, %r14            # imm = 0x3E8
jne 0x45055
movq %r15, -0x40(%rbp)
leaq 0x1863b(%rip), %rsi     # 0x5d6b3
leaq -0x1e0(%rbp), %rbx
movq %rbx, %rdi
movq 0x80(%rbp), %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x12169(%rip), %rsi     # 0x57200
movq %rbx, %rdi
callq 0x2220
movq %rax, %r14
leaq 0xcca6(%rip), %rdi      # 0x51d4f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x1860e(%rip), %rsi     # 0x5d6c8
leaq -0x2b0(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x21a0
leaq 0x22172(%rip), %rax     # 0x67244
movsbl (%rax), %edx
leaq 0x1860d(%rip), %rsi     # 0x5d6e9
movq %r14, %rdi
xorl %eax, %eax
callq 0x21a0
leaq 0x1860f(%rip), %rsi     # 0x5d6fc
movq %r14, %rdi
movl 0x50(%rbp), %edx
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %eax, %eax
callq 0x21a0
leaq 0x18610(%rip), %rdi     # 0x5d716
movl $0x13, %esi
movl $0x1, %edx
movq %r14, -0x48(%rbp)
movq %r14, %rcx
callq 0x2290
movq -0x30(%rbp), %rax
movl %eax, %r14d
testl %eax, %eax
movq %r14, -0x78(%rbp)
jle 0x451fe
movl $0x3, %ebx
movq -0x60(%rbp), %r12
movq -0x48(%rbp), %r15
leal 0x1(%rbx), %r8d
leal 0x2(%rbx), %r10d
movq %r15, %rdi
leaq 0x185dc(%rip), %rsi     # 0x5d72a
movl %ebx, %edx
movq %r12, %rcx
movq %r12, %r9
xorl %eax, %eax
pushq %r12
pushq %r10
callq 0x21a0
addq $0x10, %rsp
leal 0x3(%rbx), %r13d
cmpl $0x0, 0x35910(%rip)     # 0x7aa80
je 0x45196
leal 0x4(%rbx), %r8d
movq %r15, %rdi
leaq 0x185d5(%rip), %rsi     # 0x5d755
movl %r13d, %edx
movq %r12, %rcx
movq %r12, %r9
xorl %eax, %eax
callq 0x21a0
addl $0x5, %ebx
movl %ebx, %r13d
leal 0x1(%r13), %r8d
leal 0x2(%r13), %r10d
movq %r15, %rdi
leaq 0x185d2(%rip), %rsi     # 0x5d77a
movl %r13d, %edx
movq %r12, %rcx
movq %r12, %r9
xorl %eax, %eax
pushq %r12
pushq %r10
callq 0x21a0
addq $0x10, %rsp
leal 0x3(%r13), %ebx
cmpl $0x0, 0x358b5(%rip)     # 0x7aa80
je 0x451f1
leal 0x4(%r13), %r8d
movq %r15, %rdi
leaq 0x1857a(%rip), %rsi     # 0x5d755
movl %ebx, %edx
movq %r12, %rcx
movq %r12, %r9
xorl %eax, %eax
callq 0x21a0
addl $0x5, %r13d
movl %r13d, %ebx
addq $0x28, %r12
decq %r14
jne 0x4513c
movl $0xa, %edi
movq -0x48(%rbp), %r12
movq %r12, %rsi
callq 0x2140
movl 0x70(%rbp), %eax
movq %rax, %rcx
movl %ecx, %eax
movq %rsp, %r8
leaq 0xf(%rax), %rdi
andq $-0x10, %rdi
subq %rdi, %r8
movq %r8, %rsp
testl %ecx, %ecx
jle 0x45249
movq 0x68(%rbp), %rcx
addq $0xc, %rcx
xorl %edx, %edx
movb (%rcx), %sil
movb %sil, (%r8,%rdx)
incq %rdx
addq $0x20, %rcx
cmpq %rdx, %rax
jne 0x45236
movq %rsp, %rcx
movq %rdi, -0xd0(%rbp)
subq %rdi, %rcx
movq %rcx, %rsp
movq %rsp, %r14
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movq %rsp, %rdx
subq %rax, %rdx
movq %rdx, %rsp
movq %rsp, %rdi
movq %rax, -0xc8(%rbp)
subq %rax, %rdi
movq %rdi, %rsp
subq $0x8, %rsp
movq %rdi, -0xc0(%rbp)
movq %r14, %rsi
movq %rdx, -0xf8(%rbp)
movq %rcx, -0x108(%rbp)
xorl %r9d, %r9d
movl 0x70(%rbp), %eax
pushq %rax
callq 0x46d5f
addq $0x10, %rsp
movq %rsp, %rax
addq $-0xd0, %rax
movq %rax, -0xe8(%rbp)
movq %rax, %rsp
movl 0x50(%rbp), %eax
movl %eax, %r13d
movq %rsp, %r15
leaq 0xf(,%r13,4), %rbx
andq $-0x10, %rbx
subq %rbx, %r15
movq %r15, %rsp
testl %eax, %eax
jle 0x452f7
leaq (,%r13,4), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x2110
movq %r15, -0xb0(%rbp)
movq %r14, -0x100(%rbp)
movq %rsp, %rax
subq %rbx, %rax
movq %rax, -0x58(%rbp)
movq %rax, %rsp
movq %rsp, %rax
subq %rbx, %rax
movq %rax, -0x50(%rbp)
movq %rax, %rsp
movq %rsp, %rax
subq %rbx, %rax
movq %rax, -0xb8(%rbp)
movq %rax, %rsp
movq %rsp, %rcx
movq %r13, -0x90(%rbp)
leaq 0xf(%r13), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xf0(%rbp)
movq %rcx, %rsp
movl -0x88(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0xa0(%rbp)
testl %eax, %eax
jle 0x455a9
xorl %r14d, %r14d
movl -0x1250(%rbp,%r14,4), %r15d
movq -0x7010(%rbp,%r14,8), %r9
movq -0x50d0(%rbp,%r14,8), %r8
subq $0x8, %rsp
movq -0xc0(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0xf0(%rbp), %rbx
movq %rbx, %rcx
movq %r9, -0x80(%rbp)
pushq %r15
callq 0x46d5f
addq $0x10, %rsp
movq %r12, %r13
movl %eax, %r12d
movq -0xb8(%rbp), %rdi
movq %rbx, %rsi
movl %eax, %edx
movq -0x108(%rbp), %rcx
movl 0x60(%rbp), %r8d
callq 0x46deb
movq %r14, -0xa8(%rbp)
movq -0x3190(%rbp,%r14,8), %rdx
movq %r13, %rdi
leaq 0x14d76(%rip), %rsi     # 0x5a15d
xorl %eax, %eax
callq 0x21a0
movq %r13, %rdi
leaq 0x1847e(%rip), %rsi     # 0x5d876
movq %r15, -0x38(%rbp)
movl %r15d, %edx
movq %r12, -0x70(%rbp)
movl %r12d, %ecx
xorl %eax, %eax
callq 0x21a0
xorl %ebx, %ebx
movq -0x40(%rbp), %r15
movq -0x100(%rbp), %r14
movq -0xc0(%rbp), %r12
movq -0xf8(%rbp), %r13
movq (%r15,%rbx,8), %rdi
movq -0x38(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq %r12, %rcx
movq -0x58(%rbp), %r8
movq -0x50(%rbp), %r9
pushq %r13
pushq %r14
pushq -0x70(%rbp)
pushq -0xb8(%rbp)
callq 0x47d24
addq $0x20, %rsp
incq %rbx
cmpq $0x3e8, %rbx            # imm = 0x3E8
jne 0x45428
cmpl $0x0, -0x30(%rbp)
movl 0x50(%rbp), %r15d
movq -0x68(%rbp), %r14
jle 0x45581
xorl %ebx, %ebx
movq -0xe8(%rbp), %r12
movq (%r14,%rbx,8), %rdx
movq -0x110(%rbp), %rax
movq (%rax,%rbx,8), %rcx
movq %r12, %rdi
movq -0xb0(%rbp), %rsi
movl %r15d, %r8d
movq -0x80(%rbp), %r9
pushq 0x38(%rbp)
pushq -0x38(%rbp)
pushq $0x3e8                  # imm = 0x3E8
pushq -0x40(%rbp)
callq 0x4725a
addq $0x20, %rsp
xorps %xmm0, %xmm0
cvtss2sd (%r12), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x8(%r12), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x4(%r12), %xmm2
movq -0x48(%rbp), %r13
movq %r13, %rdi
leaq 0x182c7(%rip), %rsi     # 0x5d7a5
movb $0x3, %al
callq 0x21a0
cmpl $0x0, 0x35594(%rip)     # 0x7aa80
je 0x45513
xorps %xmm0, %xmm0
cvtss2sd 0x18(%r12), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x1c(%r12), %xmm1
movq %r13, %rdi
leaq 0x182a9(%rip), %rsi     # 0x5d7b5
movb $0x2, %al
callq 0x21a0
xorps %xmm0, %xmm0
cvtss2sd 0xc(%r12), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x14(%r12), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x10(%r12), %xmm2
movq %r13, %rdi
leaq 0x1826a(%rip), %rsi     # 0x5d7a5
movb $0x3, %al
callq 0x21a0
cmpl $0x0, 0x35537(%rip)     # 0x7aa80
je 0x45570
xorps %xmm0, %xmm0
cvtss2sd 0x20(%r12), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x24(%r12), %xmm1
movq %r13, %rdi
leaq 0x1824c(%rip), %rsi     # 0x5d7b5
movb $0x2, %al
callq 0x21a0
addq $0x28, %r12
incq %rbx
cmpq %rbx, -0x78(%rbp)
jne 0x4547c
movl $0xa, %edi
movq -0x48(%rbp), %r12
movq %r12, %rsi
callq 0x2140
movq -0xa8(%rbp), %r14
incq %r14
cmpq -0xa0(%rbp), %r14
jne 0x45368
movq %r12, %rdi
callq 0x20c0
leaq 0x18208(%rip), %rsi     # 0x5d7c0
leaq -0x1e0(%rbp), %r14
movq %r14, %rdi
movq 0x80(%rbp), %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x11c29(%rip), %rsi     # 0x57200
movq %r14, %rdi
callq 0x2220
movq %rax, %rbx
leaq 0xc766(%rip), %rdi      # 0x51d4f
movq %r14, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x181de(%rip), %rdi     # 0x5d7d8
movl $0xd, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2290
cmpl $0x0, -0x30(%rbp)
jle 0x4563a
leaq 0x181cd(%rip), %r14     # 0x5d7e6
movq -0x78(%rbp), %r12
movq -0x60(%rbp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x21a0
addq $0x28, %r15
decq %r12
jne 0x45621
movl $0xa, %edi
movq %rbx, -0x38(%rbp)
movq %rbx, %rsi
callq 0x2140
cmpl $0x0, 0x50(%rbp)
movq -0x98(%rbp), %r14
movq -0xb0(%rbp), %r15
movq -0x90(%rbp), %r12
jle 0x45754
leaq 0x12213(%rip), %rbx     # 0x57884
xorl %r13d, %r13d
movl $0x0, (%r14,%r13,4)
movl (%r15,%r13,4), %esi
testl %esi, %esi
je 0x45748
js 0x4571d
movl $0x1, (%r14,%r13,4)
movq %r13, %rax
shlq $0x5, %rax
movq 0x68(%rbp), %rcx
leaq (%rcx,%rax), %rdx
addq $0xd, %rdx
movsbl 0x6(%rdx), %ecx
movsbl -0x1(%rdx), %r8d
movq -0x38(%rbp), %rdi
leaq 0x18169(%rip), %rsi     # 0x5d826
xorl %eax, %eax
callq 0x21a0
cmpl $0x0, -0x30(%rbp)
movq -0x78(%rbp), %r15
movq -0x68(%rbp), %r12
jle 0x456f8
xorl %r14d, %r14d
movq (%r12,%r14,8), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%r13,4), %xmm0
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x21a0
incq %r14
cmpq %r14, %r15
jne 0x456d5
movl $0xa, %edi
movq -0x38(%rbp), %rsi
callq 0x2140
movq -0x98(%rbp), %r14
movq -0xb0(%rbp), %r15
movq -0x90(%rbp), %r12
jmp 0x45748
negl %esi
movq %rsi, %rax
shlq $0x5, %rax
movq 0x68(%rbp), %rcx
addq %rax, %rcx
addq $0xd, %rcx
movsbl 0x6(%rcx), %edx
movsbl -0x1(%rcx), %r8d
leaq 0x180ab(%rip), %rdi     # 0x5d7ec
xorl %eax, %eax
callq 0x20f0
incq %r13
cmpq %r12, %r13
jne 0x45674
movq -0x38(%rbp), %rdi
callq 0x20c0
cmpl $0x1, -0x88(%rbp)
jg 0x45786
xorl %ebx, %ebx
movq -0x40(%rbp), %r14
movq (%r14,%rbx,8), %rdi
callq 0x2050
incq %rbx
cmpq $0x3e8, %rbx            # imm = 0x3E8
jne 0x4576c
jmp 0x45c01
leaq 0x180a2(%rip), %rsi     # 0x5d82f
leaq -0x1e0(%rbp), %rbx
movq %rbx, %rdi
movq 0x80(%rbp), %rdx
xorl %eax, %eax
callq 0x2270
leaq 0xc5a3(%rip), %rdi      # 0x51d4f
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x11a43(%rip), %rsi     # 0x57200
movq %rbx, %rdi
callq 0x2220
movq %rax, %rbx
leaq 0x17ef9(%rip), %rsi     # 0x5d6c8
leaq -0x2b0(%rbp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0x21a0
leaq 0x21a5d(%rip), %rax     # 0x67244
movsbl (%rax), %edx
leaq 0x17ef8(%rip), %rsi     # 0x5d6e9
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21a0
leaq 0x17efa(%rip), %rsi     # 0x5d6fc
movq %rbx, %rdi
movl 0x50(%rbp), %edx
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %eax, %eax
callq 0x21a0
leaq 0x18027(%rip), %rdi     # 0x5d842
movl $0x1, %eax
movq %rax, -0xe0(%rbp)
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2290
cmpl $0x0, -0x30(%rbp)
movq -0x40(%rbp), %r12
movq -0x60(%rbp), %r13
jle 0x4588a
movq -0x78(%rbp), %rax
leaq (%rax,%rax,2), %r14
xorl %r15d, %r15d
leal 0x4(%r15), %edx
leal 0x5(%r15), %r8d
leal 0x6(%r15), %r10d
movq %rbx, %rdi
leaq 0x17f12(%rip), %rsi     # 0x5d77a
movq %r13, %rcx
movq %r13, %r9
xorl %eax, %eax
pushq %r13
pushq %r10
callq 0x21a0
addq $0x10, %rsp
addq $0x28, %r13
addq $0x3, %r15
cmpq %r15, %r14
jne 0x45852
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2140
movq %rsp, %r9
subq -0xc8(%rbp), %r9
movq %r9, %rsp
movq %rsp, %r8
subq -0xd0(%rbp), %r8
movq %r8, %rsp
xorl %r10d, %r10d
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0xb8(%rbp), %r14
movq %rbx, -0x48(%rbp)
movq %r8, -0xc8(%rbp)
movq %r9, -0x38(%rbp)
movl -0x1250(%rbp,%r10,4), %r11d
testl %r11d, %r11d
jle 0x45bc5
movq -0x7010(%rbp,%r10,8), %r15
movq -0x50d0(%rbp,%r10,8), %rax
xorl %ecx, %ecx
movl (%r15,%rcx,4), %edi
movl %edi, (%r9,%rcx,4)
movb (%rax,%rcx), %dil
movb %dil, (%r8,%rcx)
incq %rcx
cmpq %rcx, %r11
jne 0x458f5
leaq 0x1(%r10), %rax
movq %rax, -0xd8(%rbp)
cmpq -0xa0(%rbp), %rax
jge 0x45bbc
leaq (%r8,%r11), %rdi
leaq (%r9,%r11,4), %r12
movq -0xe0(%rbp), %rax
movq %r10, -0x90(%rbp)
movq %r11, -0x70(%rbp)
movq %r15, -0x88(%rbp)
movq %rdi, -0x60(%rbp)
movq %r12, -0xd0(%rbp)
movl -0x1250(%rbp,%rax,4), %ecx
movq %rcx, -0xa8(%rbp)
testl %ecx, %ecx
jle 0x45ba8
movq -0x7010(%rbp,%rax,8), %rbx
movq %rax, -0x68(%rbp)
movq -0x50d0(%rbp,%rax,8), %rax
xorl %r13d, %r13d
movq -0xa8(%rbp), %r10
movl (%rbx,%r13,4), %ecx
movl %ecx, (%r12,%r13,4)
movb (%rax,%r13), %cl
movb %cl, (%rdi,%r13)
incq %r13
cmpq %r13, %r10
jne 0x45985
movq %rbx, -0x98(%rbp)
addq %r11, %r13
subq $0x8, %rsp
movq -0xc0(%rbp), %rdi
movq -0xf0(%rbp), %rbx
movq %rbx, %rcx
pushq %r13
callq 0x46d5f
addq $0x10, %rsp
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, -0x80(%rbp)
movl %eax, %edx
movq -0x108(%rbp), %rcx
movl 0x60(%rbp), %r8d
callq 0x46deb
xorl %r15d, %r15d
movq -0x100(%rbp), %rbx
movq %r14, %r12
movq -0xf8(%rbp), %r14
movq -0x40(%rbp), %rax
movq (%rax,%r15,8), %rdi
movl %r13d, %esi
movq -0x38(%rbp), %rdx
movq -0xc0(%rbp), %rcx
movq -0x58(%rbp), %r8
movq -0x50(%rbp), %r9
pushq %r14
pushq %rbx
pushq -0x80(%rbp)
pushq %r12
callq 0x47d24
addq $0x20, %rsp
incq %r15
cmpq $0x3e8, %r15            # imm = 0x3E8
jne 0x459f7
movq -0x80(%rbp), %r15
movq -0x90(%rbp), %rax
movq -0x3190(%rbp,%rax,8), %rdx
movq -0x68(%rbp), %rax
movq -0x3190(%rbp,%rax,8), %rcx
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
leaq 0x17e00(%rip), %rsi     # 0x5d85f
xorl %eax, %eax
callq 0x21a0
movl 0x60(%rbp), %eax
cmpl $0x2, %eax
jl 0x45a82
movq %rbx, %rdi
leaq 0x17df0(%rip), %rsi     # 0x5d868
movl %r15d, %edx
xorl %eax, %eax
callq 0x21a0
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2140
movq -0x88(%rbp), %rdi
movq -0x70(%rbp), %r12
movl %r12d, %esi
movq -0x98(%rbp), %rdx
movq -0xa8(%rbp), %r15
movl %r15d, %ecx
callq 0x49641
movq %rbx, %rdi
leaq 0x17db6(%rip), %rsi     # 0x5d873
movl %r12d, %edx
movl %r15d, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x21a0
cmpl $0x0, -0x30(%rbp)
movq -0x40(%rbp), %rdx
movl 0x50(%rbp), %r8d
movq 0x38(%rbp), %rax
movq -0xb0(%rbp), %r12
jle 0x45b6a
xorl %r14d, %r14d
movq -0xe8(%rbp), %rbx
movq -0x110(%rbp), %rcx
movq (%rcx,%r14,8), %rcx
subq $0x8, %rsp
movq %rbx, %rdi
movq %r12, %rsi
movl %r8d, %r15d
movq -0x38(%rbp), %r9
pushq %rax
pushq %r13
pushq -0x70(%rbp)
pushq $0x3e8                  # imm = 0x3E8
pushq %rdx
callq 0x4793b
addq $0x30, %rsp
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rbx), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x14(%rbx), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x10(%rbx), %xmm2
movq -0x48(%rbp), %rdi
leaq 0x17c5d(%rip), %rsi     # 0x5d7a5
movb $0x3, %al
callq 0x21a0
movq -0x78(%rbp), %rcx
movq 0x38(%rbp), %rax
movl %r15d, %r8d
movq -0x40(%rbp), %rdx
addq $0x28, %rbx
incq %r14
cmpq %r14, %rcx
jne 0x45af4
movl $0xa, %edi
movq -0x48(%rbp), %rbx
movq %rbx, %rsi
callq 0x2140
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0xb8(%rbp), %r14
movq -0x38(%rbp), %r9
movq -0xc8(%rbp), %r8
movq -0x70(%rbp), %r11
movq -0x60(%rbp), %rdi
movq -0xd0(%rbp), %r12
movq -0x68(%rbp), %rax
incq %rax
cmpq -0xa0(%rbp), %rax
jne 0x45951
movq -0x40(%rbp), %r12
movq -0xd8(%rbp), %rax
jmp 0x45bcb
incq %r10
movq %r10, %rax
incq -0xe0(%rbp)
movq %rax, %r10
cmpq -0xa0(%rbp), %rax
jne 0x458d2
movq %rbx, %rdi
callq 0x20c0
xorl %ebx, %ebx
movq (%r12,%rbx,8), %rdi
callq 0x2050
incq %rbx
cmpq $0x3e8, %rbx            # imm = 0x3E8
jne 0x45bec
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq