// File: /workspace/github_c_makefile_star2_O2/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 $0x6fb8, %rsp           # imm = 0x6FB8
movq %r9, -0x58(%rbp)
movq %r8, -0x38(%rbp)
movq %rcx, -0x68(%rbp)
movq %rdx, %r12
movq %rsi, -0x60(%rbp)
movq %rdi, -0x78(%rbp)
movl 0x70(%rbp), %r15d
movl 0x60(%rbp), %r14d
movq 0x78(%rbp), %rbx
movq 0x58(%rbp), %r13
leaq 0x1869d(%rip), %rdi     # 0x57bef
callq 0x2090
subq $0x8, %rsp
leaq -0x6fe0(%rbp), %rdi
leaq -0x1220(%rbp), %rsi
leaq -0x50a0(%rbp), %rdx
leaq -0x3160(%rbp), %rcx
leaq -0x280(%rbp), %r8
movl $0x3e8, %r9d            # imm = 0x3E8
pushq $0x1
pushq %r15
pushq 0x68(%rbp)
pushq %r14
pushq %r13
pushq %rbx
pushq 0x88(%rbp)
callq 0x428d5
addq $0x40, %rsp
movl %eax, %ebx
leaq 0x18031(%rip), %rdi     # 0x575d9
xorl %r15d, %r15d
movl %eax, %esi
xorl %eax, %eax
callq 0x20f0
movl %ebx, -0x3c(%rbp)
testl %ebx, %ebx
je 0x401bc
movq %rsp, %r9
addq $-0x30, %r9
movq %r9, %rsp
movq %rsp, %rcx
addq $-0x30, %rcx
movq %rcx, %rsp
movq %rsp, %rdx
addq $-0xd0, %rdx
movq %rdx, %rsp
testq %r12, %r12
je 0x3f60e
movq -0x60(%rbp), %rax
movq %rax, (%r9)
movq %r12, (%rcx)
movabsq $0x7974696c616e6f, %rax # imm = 0x7974696C616E6F
movq %rax, 0x7(%rdx)
movabsq $0x6f69746365726964, %rax # imm = 0x6F69746365726964
movq %rax, (%rdx)
pushq $0x1
popq %r15
movq %rdx, -0x48(%rbp)
movq %rcx, -0x90(%rbp)
movq 0x10(%rbp), %rax
movq -0x38(%rbp), %rsi
testq %rsi, %rsi
je 0x3f66e
movl %r15d, %ecx
leal (,%r15,8), %edx
movq -0x68(%rbp), %rdi
movq %rdi, (%r9,%rdx)
movq -0x90(%rbp), %r8
movq %rsi, (%r8,%rdx)
imulq $0x28, %rcx, %rcx
movabsq $0x6e6f6974616e69, %rdx # imm = 0x6E6F6974616E69
movq -0x48(%rbp), %r12
movq %rdx, 0x5(%r12,%rcx)
movabsq $0x616e6964726f6f63, %rdx # imm = 0x616E6964726F6F63
movq %rdx, (%r12,%rcx)
incl %r15d
jmp 0x3f679
movq -0x90(%rbp), %r8
movq -0x48(%rbp), %r12
movq 0x20(%rbp), %rcx
testq %rax, %rax
je 0x3f6b6
movl %r15d, %edx
leal (,%r15,8), %esi
movq -0x58(%rbp), %rdi
movq %rdi, (%r9,%rsi)
movq %rax, (%r8,%rsi)
imulq $0x28, %rdx, %rax
movabsq $0x74696d69786f7270, %rdx # imm = 0x74696D69786F7270
movq %rdx, (%r12,%rax)
movw $0x79, 0x8(%r12,%rax)
incl %r15d
movq 0x30(%rbp), %rax
testq %rcx, %rcx
je 0x3f6f4
movq 0x18(%rbp), %rdx
movl %r15d, %esi
leal (,%r15,8), %edi
movq %rdx, (%r9,%rdi)
movq %rcx, (%r8,%rdi)
imulq $0x28, %rsi, %rcx
movabsq $0x74616d726f666564, %rdx # imm = 0x74616D726F666564
movq %rdx, (%r12,%rcx)
movl $0x6e6f69, 0x8(%r12,%rcx) # imm = 0x6E6F69
incl %r15d
testq %rax, %rax
movq %r9, -0x50(%rbp)
je 0x3f732
movq 0x28(%rbp), %rcx
movl %r15d, %edx
leal (,%r15,8), %esi
movq %rcx, (%r9,%rsi)
movq %rax, (%r8,%rsi)
imulq $0x28, %rdx, %rax
movabsq $0x6e61697261766f63, %rcx # imm = 0x6E61697261766F63
movq %rcx, (%r12,%rax)
movl $0x65636e, 0x7(%r12,%rax) # imm = 0x65636E
incl %r15d
movq %rsp, %rax
addq $-0x1f40, %rax          # imm = 0xE0C0
movq %rax, -0x38(%rbp)
movq %rax, %rsp
movl 0x70(%rbp), %eax
movslq %eax, %rbx
shlq $0x3, %rbx
xorl %r14d, %r14d
cmpq $0x3e8, %r14            # imm = 0x3E8
je 0x3f76d
movq %rbx, %rdi
callq 0x21d0
movq -0x38(%rbp), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
jmp 0x3f74f
leaq 0x17eaf(%rip), %rsi     # 0x57623
leaq -0x1b0(%rbp), %rbx
movq %rbx, %rdi
movq 0x80(%rbp), %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x119bd(%rip), %rsi     # 0x51150
movq %rbx, %rdi
callq 0x2210
movq %rax, %r13
leaq 0xc502(%rip), %rdi      # 0x4bca7
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x17e82(%rip), %rsi     # 0x57638
leaq -0x280(%rbp), %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x2190
leaq 0x22a76(%rip), %rax     # 0x62244
movsbl (%rax), %edx
leaq 0x17e81(%rip), %rsi     # 0x57659
movq %r13, %rdi
xorl %eax, %eax
callq 0x2190
leaq 0x17e83(%rip), %rsi     # 0x5766c
movq %r13, %rdi
movl 0x50(%rbp), %edx
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %eax, %eax
callq 0x2190
leaq 0x17e84(%rip), %rdi     # 0x57686
pushq $0x13
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x2280
movl %r15d, %r14d
pushq $0x3
popq %rbx
movq %r14, -0x58(%rbp)
movq %r13, -0x30(%rbp)
subq $0x1, %r14
jb 0x3f8e9
leal 0x1(%rbx), %r8d
leal 0x2(%rbx), %r10d
movq %r13, %rdi
leaq 0x17e60(%rip), %rsi     # 0x5769a
movl %ebx, %edx
movq %r12, %rcx
movq %r12, %r9
xorl %eax, %eax
pushq %r12
pushq %r10
callq 0x2190
popq %rcx
popq %rdx
movq %r13, %r15
leal 0x3(%rbx), %r13d
cmpl $0x0, 0x36233(%rip)     # 0x75a90
je 0x3f883
leal 0x4(%rbx), %r8d
movq %r15, %rdi
leaq 0x17e58(%rip), %rsi     # 0x576c5
movl %r13d, %edx
movq %r12, %rcx
movq %r12, %r9
xorl %eax, %eax
callq 0x2190
addl $0x5, %ebx
movl %ebx, %r13d
leal 0x1(%r13), %r8d
leal 0x2(%r13), %r10d
movq %r15, %rdi
leaq 0x17e55(%rip), %rsi     # 0x576ea
movl %r13d, %edx
movq %r12, %rcx
movq %r12, %r9
xorl %eax, %eax
pushq %r12
pushq %r10
callq 0x2190
popq %rcx
popq %rdx
leal 0x3(%r13), %ebx
cmpl $0x0, 0x361da(%rip)     # 0x75a90
je 0x3f8dc
leal 0x4(%r13), %r8d
movq %r15, %rdi
leaq 0x17dff(%rip), %rsi     # 0x576c5
movl %ebx, %edx
movq %r12, %rcx
movq %r12, %r9
xorl %eax, %eax
callq 0x2190
addl $0x5, %r13d
movl %r13d, %ebx
addq $0x28, %r12
movq -0x30(%rbp), %r13
jmp 0x3f81e
pushq $0xa
popq %rdi
movq %r13, %rsi
callq 0x2140
movl 0x70(%rbp), %eax
movq %rax, %rsi
movl %esi, %eax
movq %rsp, %r8
leaq 0xf(%rax), %r9
andq $-0x10, %r9
subq %r9, %r8
movq %r8, %rsp
xorl %ecx, %ecx
testl %esi, %esi
movl $0x0, %edx
cmovgl %esi, %edx
movq 0x68(%rbp), %rsi
addq $0xc, %rsi
cmpq %rcx, %rdx
je 0x3f936
movb (%rsi), %dil
movb %dil, (%r8,%rcx)
incq %rcx
addq $0x20, %rsi
jmp 0x3f921
movq %rsp, %rcx
movq %r9, -0xb8(%rbp)
subq %r9, %rcx
movq %rcx, %rsp
movq %rsp, %rsi
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rsi
movq %rsi, %rsp
movq %rsp, %rdx
subq %rax, %rdx
movq %rdx, %rsp
movq %rsp, %rdi
movq %rax, -0xb0(%rbp)
subq %rax, %rdi
movq %rdi, %rsp
subq $0x8, %rsp
xorl %ebx, %ebx
movq %rdi, -0x68(%rbp)
movq %rsi, -0xe0(%rbp)
movq %rdx, -0xd8(%rbp)
movq %rcx, -0xd0(%rbp)
xorl %r9d, %r9d
movl 0x70(%rbp), %eax
pushq %rax
callq 0x412a7
popq %rcx
popq %rdx
movq %rsp, %rax
addq $-0xd0, %rax
movq %rax, -0xc8(%rbp)
movq %rax, %rsp
movl 0x50(%rbp), %edx
movl %edx, %eax
movq %rsp, %rsi
leaq 0xf(,%rax,4), %rcx
andq $-0x10, %rcx
subq %rcx, %rsi
movq %rsi, -0x98(%rbp)
movq %rsi, %rsp
testl %edx, %edx
movl $0x0, %esi
cmovgl %edx, %esi
movq -0x98(%rbp), %rdx
cmpq %rbx, %rsi
je 0x3f9f4
andl $0x0, (%rdx,%rbx,4)
incq %rbx
jmp 0x3f9e6
movq %rsi, -0x70(%rbp)
movq %rsp, %rdx
subq %rcx, %rdx
movq %rdx, -0x60(%rbp)
movq %rdx, %rsp
movq %rsp, %rdx
subq %rcx, %rdx
movq %rdx, -0xa8(%rbp)
movq %rdx, %rsp
movq %rsp, %rdx
subq %rcx, %rdx
movq %rdx, -0xa0(%rbp)
movq %rdx, %rsp
movq %rsp, %rcx
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xc0(%rbp)
movq %rcx, %rsp
movl -0x3c(%rbp), %eax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, -0x80(%rbp)
xorl %r12d, %r12d
cmpq -0x80(%rbp), %r12
je 0x3fc47
movl -0x1220(%rbp,%r12,4), %ebx
movq -0x6fe0(%rbp,%r12,8), %r14
movq -0x50a0(%rbp,%r12,8), %r8
subq $0x8, %rsp
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0xa8(%rbp), %rdx
movq -0xc0(%rbp), %r13
movq %r13, %rcx
movq %r14, %r9
pushq %rbx
callq 0x412a7
popq %rcx
popq %rdx
movl %eax, %r15d
movq -0xa0(%rbp), %rdi
movq %r13, %rsi
movl %eax, %edx
movq -0xd0(%rbp), %rcx
movl 0x60(%rbp), %r8d
callq 0x4132e
movq %r12, -0x88(%rbp)
movq -0x3160(%rbp,%r12,8), %rdx
movq -0x30(%rbp), %r12
movq %r12, %rdi
leaq 0x145e6(%rip), %rsi     # 0x540bd
xorl %eax, %eax
callq 0x2190
movq %r12, %rdi
leaq 0x17cfe(%rip), %rsi     # 0x577e6
movl %ebx, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2190
xorl %r13d, %r13d
cmpq $0x3e8, %r13            # imm = 0x3E8
je 0x3fb3e
movq -0x38(%rbp), %rax
movq (%rax,%r13,8), %rdi
movl %ebx, %esi
movq %r14, %rdx
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %r8
movq -0xa8(%rbp), %r9
pushq -0xd8(%rbp)
pushq -0xe0(%rbp)
pushq %r15
pushq -0xa0(%rbp)
callq 0x41eea
addq $0x20, %rsp
incq %r13
jmp 0x3faf7
xorl %r13d, %r13d
movq -0xc8(%rbp), %r15
cmpq %r13, -0x58(%rbp)
je 0x3fc2c
movq -0x50(%rbp), %rax
movq (%rax,%r13,8), %rdx
movq -0x90(%rbp), %rax
movq (%rax,%r13,8), %rcx
movq %r15, %rdi
movq -0x98(%rbp), %rsi
movl 0x50(%rbp), %r8d
movq %r14, %r9
pushq 0x38(%rbp)
pushq %rbx
pushq $0x3e8                  # imm = 0x3E8
pushq -0x38(%rbp)
callq 0x4174e
addq $0x20, %rsp
cvtss2sd (%r15), %xmm0
cvtss2sd 0x8(%r15), %xmm1
cvtss2sd 0x4(%r15), %xmm2
movq -0x30(%rbp), %r12
movq %r12, %rdi
leaq 0x17b6b(%rip), %rsi     # 0x57715
movb $0x3, %al
callq 0x2190
cmpl $0x0, 0x35ed8(%rip)     # 0x75a90
je 0x3fbd7
cvtss2sd 0x18(%r15), %xmm0
cvtss2sd 0x1c(%r15), %xmm1
movq %r12, %rdi
leaq 0x17b55(%rip), %rsi     # 0x57725
movb $0x2, %al
callq 0x2190
cvtss2sd 0xc(%r15), %xmm0
cvtss2sd 0x14(%r15), %xmm1
cvtss2sd 0x10(%r15), %xmm2
movq %r12, %rdi
leaq 0x17b22(%rip), %rsi     # 0x57715
movb $0x3, %al
callq 0x2190
cmpl $0x0, 0x35e8f(%rip)     # 0x75a90
je 0x3fc20
cvtss2sd 0x20(%r15), %xmm0
cvtss2sd 0x24(%r15), %xmm1
movq %r12, %rdi
leaq 0x17b0c(%rip), %rsi     # 0x57725
movb $0x2, %al
callq 0x2190
addq $0x28, %r15
incq %r13
jmp 0x3fb48
pushq $0xa
popq %rdi
movq -0x30(%rbp), %rsi
callq 0x2140
movq -0x88(%rbp), %r12
incq %r12
jmp 0x3fa51
movq -0x30(%rbp), %rdi
callq 0x20c0
leaq 0x17ad9(%rip), %rsi     # 0x57730
leaq -0x1b0(%rbp), %r14
movq %r14, %rdi
movq 0x80(%rbp), %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x114da(%rip), %rsi     # 0x51150
movq %r14, %rdi
callq 0x2210
movq %rax, %rbx
leaq 0xc01f(%rip), %rdi      # 0x4bca7
movq %r14, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x17aaf(%rip), %rdi     # 0x57748
pushq $0xd
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x2280
leaq 0x17aa8(%rip), %r14     # 0x57756
movq -0x48(%rbp), %r15
movq -0x58(%rbp), %r12
subq $0x1, %r12
jb 0x3fcd2
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2190
addq $0x28, %r15
jmp 0x3fcb6
pushq $0xa
popq %r14
movl %r14d, %edi
movq %rbx, %rsi
callq 0x2140
leaq 0x11afc(%rip), %r13     # 0x517e4
xorl %r15d, %r15d
movq -0x48(%rbp), %r12
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rdx
cmpq %rdx, %r15
je 0x3fdc4
andl $0x0, (%rax,%r15,4)
movq -0x98(%rbp), %rcx
movl (%rcx,%r15,4), %esi
testl %esi, %esi
je 0x3fdbc
js 0x3fd89
movl $0x1, (%rax,%r15,4)
movq %r15, %rax
shlq $0x5, %rax
movq 0x68(%rbp), %rcx
leaq (%rcx,%rax), %rdx
addq $0xd, %rdx
movsbl 0x6(%rdx), %ecx
movsbl -0x1(%rdx), %r8d
movq %rbx, %rdi
leaq 0x17a4e(%rip), %rsi     # 0x57796
xorl %eax, %eax
callq 0x2190
xorl %r12d, %r12d
cmpq %r12, -0x58(%rbp)
je 0x3fd78
movq -0x50(%rbp), %rax
movq (%rax,%r12,8), %rax
cvtss2sd (%rax,%r15,4), %xmm0
movq %rbx, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x2190
incq %r12
jmp 0x3fd52
movl %r14d, %edi
movq %rbx, %rsi
callq 0x2140
movq -0x48(%rbp), %r12
jmp 0x3fdb4
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 0x179af(%rip), %rdi     # 0x5775c
xorl %eax, %eax
callq 0x20f0
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rdx
incq %r15
jmp 0x3fcf7
movq %rbx, %rdi
callq 0x20c0
cmpl $0x1, -0x3c(%rbp)
jg 0x3fdf3
xorl %ebx, %ebx
cmpq $0x3e8, %rbx            # imm = 0x3E8
je 0x401bc
movq -0x38(%rbp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x2050
incq %rbx
jmp 0x3fdd4
leaq 0x179a5(%rip), %rsi     # 0x5779f
leaq -0x1b0(%rbp), %rbx
movq %rbx, %rdi
movq 0x80(%rbp), %rdx
xorl %eax, %eax
callq 0x2260
leaq 0xbe8e(%rip), %rdi      # 0x4bca7
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x11326(%rip), %rsi     # 0x51150
movq %rbx, %rdi
callq 0x2210
movq %rax, %rbx
leaq 0x177fc(%rip), %rsi     # 0x57638
leaq -0x280(%rbp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0x2190
leaq 0x223f0(%rip), %rax     # 0x62244
movsbl (%rax), %edx
leaq 0x177fb(%rip), %rsi     # 0x57659
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2190
leaq 0x177fd(%rip), %rsi     # 0x5766c
movq %rbx, %rdi
movl 0x50(%rbp), %edx
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %eax, %eax
callq 0x2190
leaq 0x1792a(%rip), %rdi     # 0x577b2
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, -0x30(%rbp)
movq %rbx, %rcx
callq 0x2280
movq -0x58(%rbp), %rax
leaq (%rax,%rax,2), %r14
leaq 0x17841(%rip), %rbx     # 0x576ea
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x3fee3
leaq 0x4(%r15), %rdx
leal 0x1(%rdx), %r8d
leal 0x2(%rdx), %r10d
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
movq %r12, %rcx
movq %r12, %r9
xorl %eax, %eax
pushq %r12
pushq %r10
callq 0x2190
addq $0x10, %rsp
addq $0x3, %r15
addq $0x28, %r12
jmp 0x3feac
pushq $0xa
popq %rdi
movq -0x30(%rbp), %rbx
movq %rbx, %rsi
callq 0x2140
movq %rsp, %r13
subq -0xb0(%rbp), %r13
movq %r13, %rsp
movq %rsp, %r8
subq -0xb8(%rbp), %r8
movq %r8, %rsp
movl -0x3c(%rbp), %eax
movq %rax, -0xb0(%rbp)
xorl %esi, %esi
movq %r8, -0xb8(%rbp)
cmpq -0xb0(%rbp), %rsi
je 0x40197
movslq -0x1220(%rbp,%rsi,4), %rax
movq %rax, -0x50(%rbp)
testq %rax, %rax
jle 0x4018f
movq -0x6fe0(%rbp,%rsi,8), %rax
movq %rax, -0x88(%rbp)
movq -0x50a0(%rbp,%rsi,8), %rax
xorl %ecx, %ecx
cmpq %rcx, -0x50(%rbp)
je 0x3ff7b
movq -0x88(%rbp), %rdx
movl (%rdx,%rcx,4), %edx
movl %edx, (%r13,%rcx,4)
movb (%rax,%rcx), %dl
movb %dl, (%r8,%rcx)
incq %rcx
jmp 0x3ff5a
movq %rsi, %rax
movq %rsi, -0x80(%rbp)
movq %rax, %rcx
incq %rax
cmpl %eax, -0x3c(%rbp)
jle 0x4018f
movl -0x121c(%rbp,%rcx,4), %edi
testl %edi, %edi
jle 0x3ff82
movq %rax, -0x78(%rbp)
movq -0x6fd8(%rbp,%rcx,8), %r15
movq %rcx, -0x48(%rbp)
movq -0x5098(%rbp,%rcx,8), %rax
movq -0x50(%rbp), %rbx
xorl %ecx, %ecx
cmpq %rcx, %rdi
je 0x3ffd7
movl (%r15,%rcx,4), %edx
movl %edx, (%r13,%rbx,4)
movb (%rax,%rcx), %dl
movb %dl, (%r8,%rbx)
incq %rbx
incq %rcx
jmp 0x3ffba
movq %rdi, -0x70(%rbp)
subq $0x8, %rsp
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0xa8(%rbp), %rdx
movq -0xc0(%rbp), %r14
movq %r14, %rcx
movq %r13, %r9
pushq %rbx
callq 0x412a7
popq %rcx
popq %rdx
movl %eax, %r12d
movq -0xa0(%rbp), %rdi
movq %r14, %rsi
movl %eax, %edx
movq -0xd0(%rbp), %rcx
movl 0x60(%rbp), %r8d
callq 0x4132e
xorl %r14d, %r14d
cmpq $0x3e8, %r14            # imm = 0x3E8
je 0x4006c
movq -0x38(%rbp), %rax
movq (%rax,%r14,8), %rdi
movl %ebx, %esi
movq %r13, %rdx
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %r8
movq -0xa8(%rbp), %r9
pushq -0xd8(%rbp)
pushq -0xe0(%rbp)
pushq %r12
pushq -0xa0(%rbp)
callq 0x41eea
addq $0x20, %rsp
incq %r14
jmp 0x40025
movq -0x80(%rbp), %rax
movq -0x3160(%rbp,%rax,8), %rdx
movq -0x48(%rbp), %rax
movq -0x3158(%rbp,%rax,8), %rcx
movq -0x30(%rbp), %r14
movq %r14, %rdi
leaq 0x1773d(%rip), %rsi     # 0x577cf
xorl %eax, %eax
callq 0x2190
movl 0x60(%rbp), %eax
cmpl $0x2, %eax
jl 0x400b5
movq %r14, %rdi
leaq 0x1772d(%rip), %rsi     # 0x577d8
movl %r12d, %edx
xorl %eax, %eax
callq 0x2190
pushq $0xa
popq %rdi
movq %r14, %rsi
callq 0x2140
movq -0x88(%rbp), %rdi
movq -0x50(%rbp), %r12
movl %r12d, %esi
movq %r15, %rdx
movq -0x70(%rbp), %r15
movl %r15d, %ecx
callq 0x436b6
movq %r14, %rdi
leaq 0x176fc(%rip), %rsi     # 0x577e3
movl %r12d, %edx
movl %r15d, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x2190
xorl %r15d, %r15d
movq -0xc8(%rbp), %r14
movq -0x90(%rbp), %r12
cmpq %r15, -0x58(%rbp)
je 0x4016c
movq (%r12,%r15,8), %rcx
subq $0x8, %rsp
movq %r14, %rdi
movq -0x98(%rbp), %rsi
movl 0x50(%rbp), %r8d
movq %r13, %r9
pushq 0x38(%rbp)
pushq %rbx
pushq -0x50(%rbp)
pushq $0x3e8                  # imm = 0x3E8
pushq -0x38(%rbp)
callq 0x41bf6
addq $0x30, %rsp
cvtss2sd 0xc(%r14), %xmm0
cvtss2sd 0x14(%r14), %xmm1
cvtss2sd 0x10(%r14), %xmm2
movq -0x30(%rbp), %rdi
leaq 0x175b9(%rip), %rsi     # 0x57715
movb $0x3, %al
callq 0x2190
addq $0x28, %r14
incq %r15
jmp 0x40108
pushq $0xa
popq %rdi
movq -0x30(%rbp), %rbx
movq %rbx, %rsi
callq 0x2140
movq -0xb8(%rbp), %r8
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rax
jmp 0x3ff82
incq %rsi
jmp 0x3ff1f
movq %rbx, %rdi
callq 0x20c0
xorl %ebx, %ebx
cmpq $0x3e8, %rbx            # imm = 0x3E8
je 0x401bc
movq -0x38(%rbp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x2050
incq %rbx
jmp 0x401a1
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq