// File: /workspace/github_c_makefile_star2_O1/yhg926[P]public_kssd/command_composite.c
// Function: get_species_abundance
int get_species_abundance (composite_opt_t * composite_opt) {
 if ( composite_opt->refdir[0] == '\0' || composite_opt->qrydir[0] == '\0' || strcmp (composite_opt->refdir, composite_opt->qrydir) == 0 )
  err(errno, "get_species_abundance(): refdir or qrydir is not initialized\n" );
 const char *ref_dstat_fpath = test_get_fullpath(composite_opt->refdir,co_dstat);
 if (ref_dstat_fpath == NULL) err(errno,"cannot find %s under %s ",co_dstat, ref_dstat_fpath);
  const char *qry_dstat_fpath = test_get_fullpath(composite_opt->qrydir,co_dstat);
 if (qry_dstat_fpath == NULL) err(errno,"cannot find %s under %s ",co_dstat, qry_dstat_fpath);
 FILE *ref_dstat_fp, *qry_dstat_fp ;
 if( (ref_dstat_fp = fopen(ref_dstat_fpath,"rb")) == NULL ) err(errno, "get_species_abundance():%s",ref_dstat_fpath);
 if( (qry_dstat_fp = fopen(qry_dstat_fpath,"rb")) == NULL ) err(errno, "get_species_abundance():%s",qry_dstat_fpath);
 co_dstat_t ref_dstat, qry_dstat ;
 fread( &ref_dstat, sizeof(co_dstat_t),1,ref_dstat_fp);
 fread( &qry_dstat, sizeof(co_dstat_t),1,qry_dstat_fp);
 if(!qry_dstat.koc) err(errno, "get_species_abundance(): query has not abundance");
 if(qry_dstat.shuf_id != ref_dstat.shuf_id)
  printf("get_species_abundance(): qry shuf_id %u not match ref shuf_id: %u\n",qry_dstat.shuf_id, ref_dstat.shuf_id);
 ctx_obj_ct_t* tmp_ct_list = malloc(sizeof(ctx_obj_ct_t) * ref_dstat.infile_num);
  fread(tmp_ct_list,sizeof(ctx_obj_ct_t),ref_dstat.infile_num,ref_dstat_fp);
 char (*refname)[PATHLEN] = malloc(PATHLEN * ref_dstat.infile_num);
  fread(refname,PATHLEN,ref_dstat.infile_num,ref_dstat_fp);
  fread(tmp_ct_list,sizeof(ctx_obj_ct_t),qry_dstat.infile_num,qry_dstat_fp);
  free(tmp_ct_list);
  char (*qryname)[PATHLEN] = malloc(PATHLEN * qry_dstat.infile_num);
  fread(qryname,PATHLEN,qry_dstat.infile_num, qry_dstat_fp);
 char tmpfname[PATHLEN];
 struct stat tmpstat;
 FILE *tmpfp;
#define REALLOC_US 8
 ref_abund = (int **)malloc(ref_dstat.infile_num* sizeof(int *));
 for (int i = 0; i < ref_dstat.infile_num; i++) ref_abund[i] = (int *)malloc(REALLOC_US *sizeof(int));
 binVec_t* binVec = malloc(ref_dstat.infile_num* sizeof(binVec_t));
 for(int qn = 0; qn < qry_dstat.infile_num; qn++) {
  for (int i = 0; i < ref_dstat.infile_num; i++) ref_abund[i][0] = 0 ;
  for(int c = 0; c < ref_dstat.comp_num; c++){
   sprintf(tmpfname,"%s/%s.%d",composite_opt->refdir,skch_prefix,c);
   if( (tmpfp = fopen(tmpfname,"rb"))==NULL) err(errno,"get_species_abundance():%s",tmpfname);
   stat(tmpfname, &tmpstat);
   unsigned int *ref_combco = malloc(tmpstat.st_size);
   fread(ref_combco, tmpstat.st_size, 1, tmpfp);
   fclose(tmpfp);
   sprintf(tmpfname,"%s/%s.%d",composite_opt->refdir,idx_prefix,c);
   if( (tmpfp = fopen(tmpfname,"rb"))==NULL) err(errno,"get_species_abundance():%s",tmpfname);
   stat(tmpfname, &tmpstat);
   size_t *ref_index_combco = malloc(tmpstat.st_size);
   fread(ref_index_combco,tmpstat.st_size, 1, tmpfp);
   fclose(tmpfp);
   sprintf(tmpfname,"%s/%s.%d",composite_opt->qrydir,skch_prefix,c);
   if( (tmpfp = fopen(tmpfname,"rb"))==NULL) err(errno,"get_species_abundance():%s",tmpfname);
   stat(tmpfname, &tmpstat);
   unsigned int *qry_combco = malloc(tmpstat.st_size);
   fread(qry_combco, tmpstat.st_size, 1, tmpfp);
   fclose(tmpfp);
     sprintf(tmpfname,"%s/%s.%d",composite_opt->qrydir,idx_prefix,c);
     if( (tmpfp = fopen(tmpfname,"rb"))==NULL) err(errno,"get_species_abundance():%s",tmpfname);
     stat(tmpfname, &tmpstat);
     size_t *qry_index_combco = malloc(tmpstat.st_size);
     fread(qry_index_combco,tmpstat.st_size, 1, tmpfp);
     fclose(tmpfp);
   sprintf(tmpfname,"%s/%s.%d.a",composite_opt->qrydir,skch_prefix,c);
   if( (tmpfp = fopen(tmpfname,"rb"))==NULL) err(errno,"get_species_abundance():%s",tmpfname);
   stat(tmpfname, &tmpstat);
   unsigned short* qry_abund = malloc(tmpstat.st_size);
   fread(qry_abund, tmpstat.st_size, 1, tmpfp);
   fclose(tmpfp);
   int hash_sz = nextPrime( (int)((double)(qry_index_combco[qn+1] - qry_index_combco[qn]) / LD_FCTR) );
   size_t *km2abund_idx = calloc( hash_sz, sizeof(size_t) ) ;
   for (size_t idx = qry_index_combco[qn] ; idx < qry_index_combco[qn+1]; idx++){
    for(int i = 0; i< hash_sz; i++){
     unsigned int tmphv = HASH(qry_combco[idx],i, hash_sz);
     if(km2abund_idx[tmphv] == 0) {
      km2abund_idx[tmphv] = idx + 1;
      break;
     }
    }
   }
#pragma omp parallel for num_threads(composite_opt->p) schedule(guided)
   for(int rn = 0; rn < ref_dstat.infile_num; rn++) {
    for( size_t ri = ref_index_combco[rn]; ri < ref_index_combco[rn+1]; ri++){
     for (int i = 0; i< hash_sz; i++) {
      unsigned int hv = HASH(ref_combco[ri],i, hash_sz);
      if(km2abund_idx[hv] == 0) break;
      else if( qry_combco[km2abund_idx[hv] - 1] == ref_combco[ri] ){
       ref_abund[rn][0]++;
       ref_abund[rn][ref_abund[rn][0]] = qry_abund[km2abund_idx[hv] - 1];
       if (ref_abund[rn][0] % REALLOC_US == REALLOC_US - 1) {
              int newsize = ( (ref_abund[rn][0] / REALLOC_US) + 2 ) * REALLOC_US ;
              ref_abund[rn] = (int*)realloc( ref_abund[rn] , newsize * sizeof(int) );
       }
       break;
      }
     }
    }
   }
   free(km2abund_idx);
   free(ref_combco);
   free(ref_index_combco);
    free(qry_combco);
     free(qry_index_combco);
   free(qry_abund);
  }
#ifndef MIN_KM_S
#define MIN_KM_S 6
#endif
#define ST_PCTL (0.98)
#define ED_PCTL (0.99)
  int *sort_ref = malloc(ref_dstat.infile_num* sizeof(int));
   for(int i = 0; i< ref_dstat.infile_num; i++) sort_ref[i] = i;
  qsort(sort_ref, ref_dstat.infile_num, sizeof(sort_ref[0]), comparator_idx);
  if(composite_opt->b){
   if(strlen(composite_opt->outdir) < 3)
    sprintf(tmpfname,"%s/%s",composite_opt->refdir,binVec_dirname);
   else strcpy(tmpfname,composite_opt->outdir);
   mkdir(tmpfname,0777);
   sprintf(tmpfname,"%s/%s.%s",tmpfname,basename(qryname[qn]),binVec_suffix);
   if( (tmpfp = fopen(tmpfname,"wb"))==NULL) err(errno,"get_species_abundance():%s",tmpfname);
  }
  int num_pass = 0;
  float binVecsum = 0;
  for ( int i = 0; i< ref_dstat.infile_num; i++ ){
   int kmer_num = ref_abund[sort_ref[i]][0];
   if (kmer_num < MIN_KM_S) break;
   qsort(ref_abund[sort_ref[i]] + 1, kmer_num, sizeof(int),comparator);
   int sum = 0;
   for(int n = 1; n <= kmer_num; n++) sum += ref_abund[sort_ref[i]][n];
   int median_idx = kmer_num /2;
   int pct09_idx = kmer_num * ST_PCTL ;
   int lastsum = 0; int lastn = 0;
      for(int n = pct09_idx ; n <= kmer_num*ED_PCTL; n++) {
    lastsum += ref_abund[sort_ref[i]][n];
    lastn++;
   }
   if(composite_opt->b){
    if (ref_abund[sort_ref[i]][median_idx] > 1 && kmer_num > MIN_KM_S + 1){
     binVec[num_pass].ref_idx = sort_ref[i];
     binVec[num_pass].pct = (float)lastsum/lastn;
     binVecsum += binVec[num_pass].pct;
     num_pass++;
    }
   }
   else{
    printf("%s\t%s\t%d\t%f\t%f\t%d\t%d\n",qryname[qn],refname[sort_ref[i]], kmer_num, (float)sum/kmer_num,(float)lastsum/lastn,ref_abund[sort_ref[i]][median_idx], ref_abund[sort_ref[i]][kmer_num]);
   }
  }
  if(composite_opt->b){
   for(int i = 0; i< num_pass;i++){
    binVec[i].pct = ( binVec[i].pct - 1)*100/(binVecsum - num_pass) ;
   }
   fwrite(binVec,sizeof(binVec_t),num_pass,tmpfp);
   fclose(tmpfp);
  }
  free(sort_ref);
 }
 for (int i = 0; i < ref_dstat.infile_num; i++) free(ref_abund[i]);
  free(ref_abund) ;
 free(binVec);
 free(refname);
 free(qryname);
 return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
cmpb $0x0, 0x14(%rdi)
je 0x5430
movq %rdi, %rbx
cmpb $0x0, 0x114(%rdi)
je 0x5430
leaq 0x14(%rbx), %r13
leaq 0x114(%rbx), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x32b0
testl %eax, %eax
je 0x5430
movq %rbx, 0x20(%rsp)
leaq 0x10df5(%rip), %rsi     # 0x15760
movq %r13, %rdi
callq 0x6bcc
testq %rax, %rax
je 0x5440
movq %rax, %rbx
leaq 0x10dda(%rip), %rsi     # 0x15760
movq %rbp, %rdi
callq 0x6bcc
testq %rax, %rax
je 0x5440
movq %rax, %r14
leaq 0x106c6(%rip), %rsi     # 0x15067
movq %rbx, %rdi
callq 0x33a0
testq %rax, %rax
je 0x545e
movq %rax, %r15
leaq 0x106ab(%rip), %rsi     # 0x15067
movq %r14, %rdi
callq 0x33a0
testq %rax, %rax
je 0x5471
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
movl $0x20, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x30c0
leaq 0xb0(%rsp), %r14
movl $0x20, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x30c0
cmpb $0x0, 0x4(%r14)
je 0x5484
movl 0xb0(%rsp), %esi
movl 0x90(%rsp), %edx
cmpl %edx, %esi
je 0x4a32
leaq 0x10a56(%rip), %rdi     # 0x15481
xorl %eax, %eax
callq 0x3170
movslq 0xa4(%rsp), %r14
leaq (,%r14,4), %rdi
callq 0x3340
movq %rax, %r12
movl $0x4, %esi
movq %rax, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x30c0
movq %r14, %rdi
shlq $0x8, %rdi
callq 0x3340
movl $0x100, %esi            # imm = 0x100
movq %rax, 0x50(%rsp)
movq %rax, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x30c0
movslq 0xc4(%rsp), %r15
movl $0x4, %esi
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x30c0
movq %r12, %rdi
callq 0x3040
movq %r15, %rdi
shlq $0x8, %rdi
callq 0x3340
movl $0x100, %esi            # imm = 0x100
movq %rax, 0x30(%rsp)
movq %rax, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x30c0
leaq (,%r14,8), %rbx
movq %rbx, %rdi
callq 0x3340
movq %rax, 0x199f1(%rip)     # 0x1e4d0
testq %r14, %r14
jle 0x4b04
xorl %r15d, %r15d
movl $0x20, %edi
callq 0x3340
movq 0x199d8(%rip), %rcx     # 0x1e4d0
movq %rax, (%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x4ae7
movq %rbx, %rdi
callq 0x3340
movq %rax, 0x38(%rsp)
cmpl $0x0, 0xc4(%rsp)
movq 0x20(%rsp), %rax
jle 0x53aa
addq $0x214, %rax            # imm = 0x214
movq %rax, 0x78(%rsp)
leaq 0x10528(%rip), %r12     # 0x1505e
leaq 0x160(%rsp), %r15
movq $0x0, 0x18(%rsp)
movq %rbp, 0x80(%rsp)
movq %r13, 0x58(%rsp)
movq %rbx, 0x40(%rsp)
movslq 0xa4(%rsp), %rsi
testq %rsi, %rsi
jle 0x4b81
movq 0x19963(%rip), %rax     # 0x1e4d0
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movl $0x0, (%rdx)
incq %rcx
cmpq %rcx, %rsi
jne 0x4b6f
movq %rsi, 0x8(%rsp)
movl 0xa0(%rsp), %eax
movl %eax, 0x4c(%rsp)
testl %eax, %eax
jle 0x5042
xorl %r14d, %r14d
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
leaq 0x123d0(%rip), %rcx     # 0x16f7c
movl %r14d, %r8d
xorl %eax, %eax
callq 0x3430
movq %r15, %rdi
leaq 0x104a7(%rip), %rsi     # 0x15067
callq 0x33a0
testq %rax, %rax
je 0x5413
movq %rax, %rbx
movq %r15, %rdi
movq %r13, %rbp
leaq 0xd0(%rsp), %rsi
callq 0x32e0
movl %r14d, 0x14(%rsp)
movq 0x100(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movl $0x1, %edx
movq %rax, 0x68(%rsp)
movq %rax, %rdi
movq %r14, %rsi
movl 0x14(%rsp), %r13d
movq %rbx, %rcx
callq 0x30c0
movq %rbx, %rdi
callq 0x3100
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
leaq 0x12355(%rip), %rcx     # 0x16f83
movl %r13d, %r8d
xorl %eax, %eax
callq 0x3430
movq %r15, %rdi
leaq 0x10425(%rip), %rsi     # 0x15067
callq 0x33a0
testq %rax, %rax
je 0x5413
movq %rax, %rbx
movq %r15, %rdi
leaq 0xd0(%rsp), %rsi
callq 0x32e0
movq 0x100(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movl $0x1, %edx
movq %rax, 0x60(%rsp)
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x30c0
movq %rbx, %rdi
callq 0x3100
movq %r15, %rdi
movq %r12, %rsi
movq 0x80(%rsp), %rbp
movq %rbp, %rdx
leaq 0x122d1(%rip), %rcx     # 0x16f7c
movl %r13d, %r8d
xorl %eax, %eax
callq 0x3430
movq %r15, %rdi
leaq 0x103a8(%rip), %rsi     # 0x15067
callq 0x33a0
testq %rax, %rax
je 0x5413
movq %rax, %r14
movq %r15, %rdi
leaq 0xd0(%rsp), %rsi
callq 0x32e0
movq 0x100(%rsp), %r15
movq %r15, %rdi
callq 0x3340
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
leaq 0x160(%rsp), %r15
movq %r14, %rcx
callq 0x30c0
movq %r14, %rdi
callq 0x3100
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
leaq 0x1225d(%rip), %rcx     # 0x16f83
movl %r13d, %r8d
xorl %eax, %eax
callq 0x3430
movq %r15, %rdi
leaq 0x1032d(%rip), %r13     # 0x15067
movq %r13, %rsi
callq 0x33a0
testq %rax, %rax
je 0x5413
movq %rax, %r14
movq %rbp, %r12
movq %r13, %rbp
movq %r15, %rdi
leaq 0xd0(%rsp), %rsi
callq 0x32e0
movq 0x100(%rsp), %r15
movq %r15, %rdi
callq 0x3340
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
leaq 0x160(%rsp), %r15
movq %r14, %rcx
callq 0x30c0
movq %r14, %rdi
callq 0x3100
movq %r15, %rdi
leaq 0x10720(%rip), %rsi     # 0x154c4
movq %r12, %rdx
leaq 0x121ce(%rip), %rcx     # 0x16f7c
movl 0x14(%rsp), %r8d
xorl %eax, %eax
callq 0x3430
movq %r15, %rdi
movq %rbp, %rsi
callq 0x33a0
testq %rax, %rax
leaq 0xd0(%rsp), %rsi
je 0x5413
movq %rax, %r12
movq %r15, %rdi
callq 0x32e0
movq 0x100(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movl $0x1, %edx
movq %rax, 0x70(%rsp)
movq %rax, %rdi
movq %r14, %rsi
movq %r12, %rcx
callq 0x30c0
movq %r12, 0x40(%rsp)
movq %r12, %rdi
callq 0x3100
movq 0x18(%rsp), %rax
movq (%r13,%rax,8), %r12
movq %r13, %r15
movq 0x8(%r13,%rax,8), %r13
movq %r13, %rax
subq %r12, %rax
movq %rax, %xmm0
punpckldq 0x101f5(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x101fd(%rip), %xmm0    # 0x15040
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0x10399(%rip), %xmm1    # 0x151f0
cvttsd2si %xmm1, %edi
callq 0x120cc
movq %rax, 0x28(%rsp)
movslq %eax, %r14
movl $0x8, %esi
movq %r14, %rdi
callq 0x32a0
movq %rax, %rbp
cmpq %r12, %r13
movq 0x68(%rsp), %r10
movq %r15, %r11
jbe 0x4ee2
movq 0x28(%rsp), %rax
leal -0x1(%rax), %edi
cmpl $0x0, 0x28(%rsp)
jle 0x4eda
movl (%rbx,%r12,4), %esi
xorl %r8d, %r8d
movl %esi, %eax
xorl %edx, %edx
divl %r14d
movl %edx, %ecx
movl %esi, %eax
xorl %edx, %edx
divl %edi
movl %edx, %esi
incl %esi
movl %r14d, %r9d
movl %esi, %eax
imull %r8d, %eax
addl %ecx, %eax
xorl %edx, %edx
divl %r14d
cmpq $0x0, (%rbp,%rdx,8)
je 0x4ed0
incl %r8d
decl %r9d
jne 0x4eb1
jmp 0x4eda
leaq 0x1(%r12), %rax
movq %rax, (%rbp,%rdx,8)
incq %r12
cmpq %r13, %r12
jne 0x4e8d
movq %r11, 0x88(%rsp)
cmpl $0x0, 0x8(%rsp)
movq 0x28(%rsp), %r11
jle 0x4fdf
leal -0x1(%r11), %eax
movl %eax, 0x4(%rsp)
xorl %r12d, %r12d
movq 0x60(%rsp), %rax
movq (%rax,%r12,8), %r13
movq 0x8(%rax,%r12,8), %r15
cmpq %r15, %r13
jae 0x4fd1
testl %r11d, %r11d
jle 0x4fc5
movl (%r10,%r13,4), %ecx
xorl %r8d, %r8d
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
movl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl 0x4(%rsp)
movl %edx, %edi
incl %edi
movl %r14d, %r9d
movl %edi, %eax
imull %r8d, %eax
addl %esi, %eax
xorl %edx, %edx
divl %r14d
movq (%rbp,%rdx,8), %rax
testq %rax, %rax
je 0x4fc5
cmpl %ecx, -0x4(%rbx,%rax,4)
je 0x4f6b
incl %r8d
decl %r9d
jne 0x4f44
jmp 0x4fc5
movq 0x1955e(%rip), %rcx     # 0x1e4d0
movq (%rcx,%r12,8), %rdi
movslq (%rdi), %rcx
leaq 0x1(%rcx), %rdx
movl %edx, (%rdi)
movq 0x70(%rsp), %rdx
movzwl -0x2(%rdx,%rax,2), %eax
movl %eax, 0x4(%rdi,%rcx,4)
movl (%rdi), %eax
movl %eax, %ecx
andl $0x80000007, %ecx       # imm = 0x80000007
cmpl $0x7, %ecx
jne 0x4fc5
andl $0x7ffffff8, %eax       # imm = 0x7FFFFFF8
addl $0x10, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
callq 0x3350
movq 0x28(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x1950f(%rip), %rcx     # 0x1e4d0
movq %rax, (%rcx,%r12,8)
incq %r13
cmpq %r15, %r13
jne 0x4f1c
incq %r12
cmpq 0x8(%rsp), %r12
jne 0x4f05
movq %rbp, %rdi
movq %r10, %r14
callq 0x3040
movq %r14, %rdi
callq 0x3040
movq 0x60(%rsp), %rdi
callq 0x3040
movq %rbx, %rdi
callq 0x3040
movq 0x88(%rsp), %rdi
callq 0x3040
movq 0x70(%rsp), %rdi
callq 0x3040
movl 0x14(%rsp), %r14d
incl %r14d
cmpl 0x4c(%rsp), %r14d
movq 0x58(%rsp), %r13
leaq 0x1002a(%rip), %r12     # 0x1505e
leaq 0x160(%rsp), %r15
jne 0x4b9c
movq 0x8(%rsp), %rbx
leaq (,%rbx,4), %rdi
callq 0x3340
movq %rbx, %rsi
movq %rax, %r15
testl %esi, %esi
jle 0x506c
xorl %eax, %eax
movl %eax, (%r15,%rax,4)
incq %rax
cmpq %rax, %rsi
jne 0x5060
movl $0x4, %edx
movq %r15, %rdi
leaq 0x139d(%rip), %rcx      # 0x6418
callq 0x30b0
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax)
movq 0x78(%rsp), %rbx
leaq 0x139e(%rip), %rbp      # 0x6432
je 0x5130
movq %rbx, %rdi
callq 0x3130
leaq 0x160(%rsp), %r14
movq %r14, %rdi
cmpq $0x2, %rax
ja 0x50cd
leaq 0x102d9(%rip), %rsi     # 0x15393
movq %r13, %rdx
leaq 0x101b6(%rip), %rcx     # 0x1527a
xorl %eax, %eax
callq 0x3430
jmp 0x50d5
movq %rbx, %rsi
callq 0x3080
movq %r14, %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x3090
movq 0x18(%rsp), %rdi
shlq $0x8, %rdi
addq 0x30(%rsp), %rdi
callq 0x3300
movq %r14, %rdi
leaq 0x10278(%rip), %rsi     # 0x15377
movq %r14, %rdx
movq %rax, %rcx
leaq 0x1015c(%rip), %r8      # 0x15268
xorl %eax, %eax
callq 0x3430
movq %r14, %rdi
leaq 0xff4d(%rip), %rsi      # 0x1506a
callq 0x33a0
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x5413
movq 0x8(%rsp), %rdx
testl %edx, %edx
jle 0x52f8
movq 0x18(%rsp), %rbx
shlq $0x8, %rbx
addq 0x30(%rsp), %rbx
xorl %r13d, %r13d
xorps %xmm3, %xmm3
xorl %r12d, %r12d
movq 0x19375(%rip), %rax     # 0x1e4d0
movslq (%r15,%r13,4), %rcx
movq (%rax,%rcx,8), %rdi
movl (%rdi), %r14d
cmpl $0x6, %r14d
jl 0x52e4
movss %xmm3, 0x4(%rsp)
addq $0x4, %rdi
movl $0x4, %edx
movq %r14, %rsi
movq %rbp, %rcx
callq 0x30b0
movq 0x1933f(%rip), %rax     # 0x1e4d0
movslq (%r15,%r13,4), %rcx
movq (%rax,%rcx,8), %rcx
leaq 0x1(%r14), %rdx
xorl %eax, %eax
movl $0x1, %esi
addl (%rcx,%rsi,4), %eax
incq %rsi
cmpq %rsi, %rdx
jne 0x51a4
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movapd %xmm0, %xmm3
mulsd 0x10035(%rip), %xmm3    # 0x151f8
mulsd 0x10035(%rip), %xmm0    # 0x15200
cvttpd2dq %xmm3, %xmm1
cvtdq2pd %xmm1, %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm2, %xmm0
xorpd %xmm2, %xmm2
jb 0x522b
cvttsd2si %xmm3, %ecx
movq 0x192e4(%rip), %rsi     # 0x1e4d0
movslq (%r15,%r13,4), %rdi
movslq %ecx, %rcx
leaq (,%rcx,4), %rdx
addq (%rsi,%rdi,8), %rdx
incl %ecx
xorl %esi, %esi
xorl %edi, %edi
leal (%rcx,%rsi), %r8d
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
addl (%rdx,%rsi,4), %edi
incq %rsi
ucomisd %xmm1, %xmm0
jae 0x5205
xorps %xmm1, %xmm1
cvtsi2ss %edi, %xmm1
xorps %xmm2, %xmm2
cvtsi2ss %esi, %xmm2
movl %r14d, %ecx
shrl %ecx
movq 0x20(%rsp), %rdx
cmpl $0x0, (%rdx)
movl %ecx, %ecx
je 0x5286
cmpl $0x8, %r14d
jl 0x52d9
movq 0x19283(%rip), %rdx     # 0x1e4d0
movslq (%r15,%r13,4), %rax
movq (%rdx,%rax,8), %rdx
cmpl $0x2, (%rdx,%rcx,4)
movq 0x8(%rsp), %rdx
movss 0x4(%rsp), %xmm3
jl 0x52e4
movslq %r12d, %r12
movq 0x38(%rsp), %rcx
movl %eax, (%rcx,%r12,8)
divss %xmm2, %xmm1
movss %xmm1, 0x4(%rcx,%r12,8)
addss %xmm1, %xmm3
incl %r12d
jmp 0x52e4
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movslq (%r15,%r13,4), %rdx
movq 0x19238(%rip), %rax     # 0x1e4d0
movq (%rax,%rdx,8), %rax
xorps %xmm3, %xmm3
cvtsi2ss %r14d, %xmm3
shlq $0x8, %rdx
addq 0x50(%rsp), %rdx
divss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
movl (%rax,%rcx,4), %r8d
movl (%rax,%r14,4), %r9d
leaq 0x10203(%rip), %rdi     # 0x154cf
movq %rbx, %rsi
movl %r14d, %ecx
movb $0x2, %al
callq 0x3170
movq 0x8(%rsp), %rdx
movss 0x4(%rsp), %xmm3
cmpl $0x6, %r14d
jl 0x52fe
incq %r13
cmpq %rdx, %r13
jb 0x5154
jmp 0x52fe
xorps %xmm3, %xmm3
xorl %r12d, %r12d
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax)
movq 0x38(%rsp), %rdi
movq 0x58(%rsp), %r13
movq 0x40(%rsp), %rbx
je 0x5375
testl %r12d, %r12d
movss 0xfeee(%rip), %xmm1     # 0x15210
movss 0xfeea(%rip), %xmm2     # 0x15214
jle 0x535d
xorps %xmm0, %xmm0
cvtsi2ss %r12d, %xmm0
subss %xmm0, %xmm3
movl %r12d, %eax
xorl %ecx, %ecx
movss 0x4(%rdi,%rcx,8), %xmm0
addss %xmm1, %xmm0
mulss %xmm2, %xmm0
divss %xmm3, %xmm0
movss %xmm0, 0x4(%rdi,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x533d
movslq %r12d, %rdx
movl $0x8, %esi
movq %rbx, %rcx
callq 0x3450
movq %rbx, %rdi
callq 0x3100
movq %r15, %rdi
callq 0x3040
movq 0x18(%rsp), %rdx
incq %rdx
movslq 0xc4(%rsp), %rax
movq %rdx, 0x18(%rsp)
cmpq %rax, %rdx
leaq 0xfcc2(%rip), %r12      # 0x1505e
leaq 0x160(%rsp), %r15
jl 0x4b54
movslq 0xa4(%rsp), %rbx
testq %rbx, %rbx
jle 0x53d2
xorl %r14d, %r14d
movq 0x1910f(%rip), %rax     # 0x1e4d0
movq (%rax,%r14,8), %rdi
callq 0x3040
incq %r14
cmpq %r14, %rbx
jne 0x53ba
movq 0x190f7(%rip), %rdi     # 0x1e4d0
callq 0x3040
movq 0x38(%rsp), %rdi
callq 0x3040
movq 0x50(%rsp), %rdi
callq 0x3040
movq 0x30(%rsp), %rdi
callq 0x3040
movl $0x1, %eax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3060
movl (%rax), %edi
leaq 0x10014(%rip), %rsi     # 0x15435
leaq 0x160(%rsp), %rdx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0xffb9(%rip), %rsi      # 0x153f7
jmp 0x5492
callq 0x3060
movl (%rax), %edi
leaq 0xff7f(%rip), %rsi      # 0x153cd
leaq 0x1030b(%rip), %rdx     # 0x15760
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0xffc9(%rip), %rsi      # 0x15435
movq %rbx, %rdx
jmp 0x5429
callq 0x3060
movl (%rax), %edi
leaq 0xffb6(%rip), %rsi      # 0x15435
movq %r14, %rdx
jmp 0x5429
callq 0x3060
movl (%rax), %edi
leaq 0xffbe(%rip), %rsi      # 0x15450
xorl %eax, %eax
callq 0x3330