// File: /workspace/github_c_makefile_star2_O3/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 0x54b3
movq %rdi, %rbx
cmpb $0x0, 0x114(%rdi)
je 0x54b3
leaq 0x14(%rbx), %r15
leaq 0x114(%rbx), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x32b0
testl %eax, %eax
je 0x54b3
movq %rbx, 0x20(%rsp)
leaq 0x10e24(%rip), %rsi     # 0x157b0
movq %r15, %rdi
callq 0x6d79
testq %rax, %rax
je 0x54c3
movq %rax, %r14
movq %r15, 0x58(%rsp)
leaq 0x10e04(%rip), %rsi     # 0x157b0
movq %r13, %rdi
callq 0x6d79
testq %rax, %rax
je 0x54c3
movq %rax, %rbx
leaq 0x106a0(%rip), %rsi     # 0x15067
movq %r14, %rdi
callq 0x33a0
testq %rax, %rax
je 0x54e1
movq %rax, %r15
leaq 0x10685(%rip), %rsi     # 0x15067
movq %rbx, %rdi
callq 0x33a0
testq %rax, %rax
je 0x54f4
movq %rax, %r14
leaq 0x90(%rsp), %rdi
movl $0x20, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x30c0
leaq 0xb0(%rsp), %rbx
movl $0x20, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rcx
callq 0x30c0
cmpb $0x0, 0x4(%rbx)
je 0x5507
movl 0xb0(%rsp), %esi
movl 0x90(%rsp), %edx
cmpl %edx, %esi
je 0x4a57
leaq 0x10a81(%rip), %rdi     # 0x154d1
xorl %eax, %eax
callq 0x3170
movslq 0xa4(%rsp), %rbx
leaq (,%rbx,4), %rdi
callq 0x3340
movq %rax, %r12
movl $0x4, %esi
movq %rax, %rdi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x30c0
movq %rbx, %rdi
shlq $0x8, %rdi
callq 0x3340
movl $0x100, %esi            # imm = 0x100
movq %rax, 0x50(%rsp)
movq %rax, %rdi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x30c0
movl 0xc4(%rsp), %eax
movl %eax, 0xc(%rsp)
movslq %eax, %r15
movl $0x4, %esi
movq %r12, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x30c0
movq %r12, %rdi
callq 0x3040
movq %r15, %rdi
shlq $0x8, %rdi
callq 0x3340
movl $0x100, %esi            # imm = 0x100
movq %rax, 0x38(%rsp)
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x30c0
leaq (,%rbx,8), %r14
movq %r14, %rdi
callq 0x3340
movq %rax, 0x199c6(%rip)     # 0x1e4d0
testq %rbx, %rbx
jle 0x4b2f
xorl %r15d, %r15d
movl $0x20, %edi
callq 0x3340
movq 0x199ad(%rip), %rcx     # 0x1e4d0
movq %rax, (%rcx,%r15,8)
incq %r15
cmpq %r15, %rbx
jne 0x4b12
movq %r14, %rdi
callq 0x3340
movq %rax, 0x18(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x5434
movq 0x20(%rsp), %rax
leaq 0x214(%rax), %rbx
leaq 0x10504(%rip), %r12     # 0x1505e
leaq 0x1246b(%rip), %rbp     # 0x16fcc
movq $0x0, 0x10(%rsp)
movq %r13, 0x80(%rsp)
movq %rbx, 0x78(%rsp)
movslq 0xa4(%rsp), %rsi
testq %rsi, %rsi
jle 0x4b9f
movq 0x19945(%rip), %rax     # 0x1e4d0
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movl $0x0, (%rdx)
incq %rcx
cmpq %rcx, %rsi
jne 0x4b8d
movq %rsi, 0x28(%rsp)
movl 0xa0(%rsp), %eax
movl %eax, 0x4c(%rsp)
testl %eax, %eax
jle 0x5067
xorl %r14d, %r14d
leaq 0xd0(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq 0x58(%rsp), %r15
movq %r15, %rdx
movq %rbp, %rcx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x3430
movq %r13, %rdi
leaq 0x10480(%rip), %rbp     # 0x15067
movq %rbp, %rsi
callq 0x33a0
testq %rax, %rax
je 0x5496
movq %rax, %rbx
movq %r13, %rdi
movq %r12, %r13
leaq 0x1d8(%rsp), %r12
movq %r12, %rsi
callq 0x32e0
movl %r14d, 0x8(%rsp)
movq 0x208(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movl $0x1, %edx
movq %rax, 0x68(%rsp)
movq %rax, %rdi
movq %r14, %rsi
movl 0x8(%rsp), %r14d
movq %rbx, %rcx
callq 0x30c0
movq %rbx, %rdi
callq 0x3100
leaq 0xd0(%rsp), %rdi
movq %r13, %rsi
leaq 0xd0(%rsp), %r13
movq %r15, %rdx
leaq 0x1236b(%rip), %rcx     # 0x16fd3
movl %r14d, %r8d
xorl %eax, %eax
callq 0x3430
movq %r13, %rdi
movq %rbp, %rsi
callq 0x33a0
testq %rax, %rax
je 0x5496
movq %rax, %rbx
movq %r13, %rdi
movq %r12, %rsi
callq 0x32e0
movl %r14d, %r15d
movq 0x208(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movl $0x1, %edx
movq %rax, 0x40(%rsp)
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x30c0
movq %rbx, %rdi
callq 0x3100
movq %r13, %rdi
leaq 0x1038d(%rip), %rsi     # 0x1505e
movq 0x80(%rsp), %rbp
movq %rbp, %rdx
leaq 0x122e9(%rip), %rcx     # 0x16fcc
movl %r15d, %r8d
xorl %eax, %eax
callq 0x3430
movq %r13, %rdi
leaq 0x10370(%rip), %rsi     # 0x15067
callq 0x33a0
testq %rax, %rax
je 0x5496
movq %rax, %r14
movq %r13, %rdi
movq %r12, %rsi
callq 0x32e0
movq 0x208(%rsp), %r15
movq %r15, %rdi
callq 0x3340
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x30c0
movq %r14, %rdi
callq 0x3100
movq %r13, %rdi
leaq 0x10313(%rip), %rsi     # 0x1505e
movq %rbp, %rdx
leaq 0x1227e(%rip), %rcx     # 0x16fd3
movl 0x8(%rsp), %r8d
xorl %eax, %eax
callq 0x3430
movq %r13, %rdi
leaq 0x102fc(%rip), %rsi     # 0x15067
callq 0x33a0
testq %rax, %rax
je 0x5496
movq %rax, %r14
movq %r13, %rdi
movq %r12, %rsi
callq 0x32e0
movq 0x208(%rsp), %r15
movq %r15, %rdi
callq 0x3340
movl $0x1, %edx
movq %rax, %r13
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x30c0
movq %r14, %rdi
callq 0x3100
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
leaq 0x1074d(%rip), %rsi     # 0x15514
movq %rbp, %rdx
leaq 0x121fb(%rip), %rcx     # 0x16fcc
movl 0x8(%rsp), %r8d
xorl %eax, %eax
callq 0x3430
movq %r15, %r14
movq %r15, %rdi
leaq 0x1027d(%rip), %rsi     # 0x15067
callq 0x33a0
testq %rax, %rax
je 0x5496
movq %rax, %r15
movq %r14, %rdi
movq %r12, %rsi
callq 0x32e0
movq 0x208(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movl $0x1, %edx
movq %rax, 0x70(%rsp)
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rcx
callq 0x30c0
movq %r15, 0x60(%rsp)
movq %r15, %rdi
callq 0x3100
movq 0x10(%rsp), %rax
movq %r13, %rbp
movq (%r13,%rax,8), %r13
movq 0x8(%rbp,%rax,8), %r15
movq %r15, %rax
subq %r13, %rax
movq %rax, %xmm0
punpckldq 0x101d0(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x101d8(%rip), %xmm0    # 0x15040
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0x103c4(%rip), %xmm1    # 0x15240
cvttsd2si %xmm1, %edi
callq 0x12a04
movq %rax, 0x30(%rsp)
movslq %eax, %r14
movl $0x8, %esi
movq %r14, %rdi
callq 0x32a0
movq %rax, %r12
cmpq %r13, %r15
movq 0x28(%rsp), %r10
movq %rbp, %r11
jbe 0x4f04
movq 0x30(%rsp), %rax
leal -0x1(%rax), %edi
cmpl $0x0, 0x30(%rsp)
jle 0x4efc
movl (%rbx,%r13,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, (%r12,%rdx,8)
je 0x4ef4
incl %r8d
decl %r9d
jne 0x4ed6
jmp 0x4efc
leaq 0x1(%r13), %rax
movq %rax, (%r12,%rdx,8)
incq %r13
cmpq %r15, %r13
jne 0x4eb2
movq %r11, 0x88(%rsp)
testl %r10d, %r10d
movq 0x68(%rsp), %r10
movq 0x30(%rsp), %r11
jle 0x500a
leal -0x1(%r11), %eax
movl %eax, 0x4(%rsp)
movq 0x40(%rsp), %rax
movq (%rax), %r15
xorl %r13d, %r13d
movq %r15, %rbp
movq 0x40(%rsp), %rax
movq 0x8(%rax,%r13,8), %r15
cmpq %r15, %rbp
jae 0x4ffc
testl %r11d, %r11d
jle 0x4ff0
movl (%r10,%rbp,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 (%r12,%rdx,8), %rax
testq %rax, %rax
je 0x4ff0
cmpl %ecx, -0x4(%rbx,%rax,4)
je 0x4f96
incl %r8d
decl %r9d
jne 0x4f70
jmp 0x4ff0
movq 0x19533(%rip), %rcx     # 0x1e4d0
movq (%rcx,%r13,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 0x4ff0
andl $0x7ffffff8, %eax       # imm = 0x7FFFFFF8
addl $0x10, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
callq 0x3350
movq 0x30(%rsp), %r11
movq 0x68(%rsp), %r10
movq 0x194e4(%rip), %rcx     # 0x1e4d0
movq %rax, (%rcx,%r13,8)
incq %rbp
cmpq %r15, %rbp
jne 0x4f48
incq %r13
cmpq 0x28(%rsp), %r13
jne 0x4f32
movq %r12, %rdi
movq %r10, %r14
callq 0x3040
movq %r14, %rdi
callq 0x3040
movq 0x40(%rsp), %rdi
callq 0x3040
movq %rbx, %rdi
callq 0x3040
movq 0x88(%rsp), %rdi
callq 0x3040
movq 0x70(%rsp), %rdi
callq 0x3040
movl 0x8(%rsp), %r14d
incl %r14d
cmpl 0x4c(%rsp), %r14d
leaq 0x10004(%rip), %r12     # 0x1505e
leaq 0x11f6b(%rip), %rbp     # 0x16fcc
jne 0x4bba
movq 0x28(%rsp), %rbp
leaq (,%rbp,4), %rdi
callq 0x3340
movq %rax, %r15
testl %ebp, %ebp
movq 0x20(%rsp), %rbx
leaq 0xd0(%rsp), %r12
movdqa 0x1015d(%rip), %xmm5    # 0x151f0
pcmpeqd %xmm6, %xmm6
movdqa 0x10161(%rip), %xmm7    # 0x15200
jle 0x511b
leal 0x1(%rbp), %eax
andl $-0x2, %eax
leaq -0x1(%rbp), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
pxor %xmm5, %xmm0
xorl %ecx, %ecx
movdqa 0x1011d(%rip), %xmm1    # 0x151e0
movdqa %xmm1, %xmm2
pxor %xmm5, %xmm2
movdqa %xmm2, %xmm3
pcmpgtd %xmm0, %xmm3
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm4     # xmm4 = xmm2[1,1,3,3]
pand %xmm3, %xmm4
pshufd $0xf5, %xmm3, %xmm2     # xmm2 = xmm3[1,1,3,3]
por %xmm4, %xmm2
movd %xmm2, %edx
notl %edx
testb $0x1, %dl
je 0x50f8
movl %ecx, (%r15,%rcx,4)
pxor %xmm6, %xmm2
pextrw $0x4, %xmm2, %edx
testb $0x1, %dl
je 0x510e
leal 0x1(%rcx), %edx
movl %edx, 0x4(%r15,%rcx,4)
addq $0x2, %rcx
paddq %xmm7, %xmm1
cmpq %rcx, %rax
jne 0x50c3
movl $0x4, %edx
movq %r15, %rdi
movq %rbp, %rsi
leaq 0x14a8(%rip), %rcx      # 0x65d5
callq 0x30b0
cmpl $0x0, (%rbx)
je 0x51d0
movq 0x78(%rsp), %r14
movq %r14, %rdi
callq 0x3130
movq %r12, %rdi
cmpq $0x2, %rax
ja 0x516d
leaq 0x1028b(%rip), %rsi     # 0x153e3
movq 0x58(%rsp), %rdx
leaq 0x10166(%rip), %rcx     # 0x152ca
xorl %eax, %eax
callq 0x3430
jmp 0x5175
movq %r14, %rsi
callq 0x3080
movq %r12, %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x3090
movq 0x10(%rsp), %rdi
shlq $0x8, %rdi
addq 0x38(%rsp), %rdi
callq 0x3300
movq %r12, %rdi
leaq 0x10228(%rip), %rsi     # 0x153c7
movq %r12, %rdx
movq %rax, %rcx
leaq 0x1010c(%rip), %r8      # 0x152b8
xorl %eax, %eax
callq 0x3430
movq %r12, %rdi
leaq 0xfead(%rip), %rsi      # 0x1506a
callq 0x33a0
movq %rax, 0x60(%rsp)
testq %rax, %rax
je 0x5496
testl %ebp, %ebp
jle 0x53c7
movq 0x10(%rsp), %rbx
shlq $0x8, %rbx
addq 0x38(%rsp), %rbx
xorl %r13d, %r13d
pxor %xmm3, %xmm3
movq 0x192dc(%rip), %rax     # 0x1e4d0
xorl %r12d, %r12d
movslq (%r15,%r13,4), %rcx
movq (%rax,%rcx,8), %rdi
movl (%rdi), %r14d
cmpl $0x6, %r14d
jl 0x536c
movd %xmm3, 0x4(%rsp)
addq $0x4, %rdi
movl $0x4, %edx
movq %r14, %rsi
leaq 0x13ca(%rip), %rcx      # 0x65ef
callq 0x30b0
movq 0x1929f(%rip), %rax     # 0x1e4d0
movl (%r15,%r13,4), %esi
movslq %esi, %rdx
movq (%rax,%rdx,8), %rcx
leal 0x1(%r14), %r8d
xorl %edi, %edi
movl $0x1, %r9d
addl (%rcx,%r9,4), %edi
incq %r9
cmpq %r9, %r8
jne 0x5248
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movapd %xmm0, %xmm3
mulsd 0xffe0(%rip), %xmm3     # 0x15248
mulsd 0xffe0(%rip), %xmm0     # 0x15250
cvttpd2dq %xmm3, %xmm1
cvtdq2pd %xmm1, %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm2, %xmm0
xorpd %xmm2, %xmm2
jb 0x52c8
cvttsd2si %xmm3, %r8d
movslq %r8d, %r8
leaq (%rcx,%r8,4), %r9
incl %r8d
xorl %r10d, %r10d
xorl %r11d, %r11d
leal (%r8,%r10), %ebp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
addl (%r9,%r10,4), %r11d
incq %r10
ucomisd %xmm1, %xmm0
jae 0x529b
xorps %xmm1, %xmm1
cvtsi2ss %r11d, %xmm1
xorps %xmm2, %xmm2
cvtsi2ss %r10d, %xmm2
movq 0x28(%rsp), %rbp
movl %r14d, %r8d
shrl %r8d
movq 0x20(%rsp), %r9
cmpl $0x0, (%r9)
je 0x530c
cmpl $0x8, %r14d
jl 0x535a
cmpl $0x2, (%rcx,%r8,4)
movss 0x4(%rsp), %xmm3
jl 0x5360
movslq %r12d, %r12
movq 0x18(%rsp), %rcx
movl %esi, (%rcx,%r12,8)
divss %xmm2, %xmm1
movss %xmm1, 0x4(%rcx,%r12,8)
addss %xmm1, %xmm3
incl %r12d
jmp 0x5360
xorps %xmm0, %xmm0
cvtsi2ss %edi, %xmm0
shlq $0x8, %rdx
xorps %xmm3, %xmm3
cvtsi2ss %r14d, %xmm3
addq 0x50(%rsp), %rdx
divss %xmm3, %xmm0
cvtss2sd %xmm0, %xmm0
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
movl %r8d, %eax
movl (%rcx,%rax,4), %r8d
movl (%rcx,%r14,4), %r9d
leaq 0x101d9(%rip), %rdi     # 0x1551f
movq %rbx, %rsi
movl %r14d, %ecx
movb $0x2, %al
callq 0x3170
movq 0x19176(%rip), %rax     # 0x1e4d0
movss 0x4(%rsp), %xmm3
incq %r13
cmpq %rbp, %r13
jne 0x51f7
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax)
je 0x53fc
testl %r12d, %r12d
jle 0x53cf
xorps %xmm0, %xmm0
cvtsi2ss %r12d, %xmm0
subss %xmm0, %xmm3
movl %r12d, %eax
xorl %ecx, %ecx
movq 0x18(%rsp), %rdx
movss 0xfec3(%rip), %xmm1     # 0x15260
movss 0xfebf(%rip), %xmm2     # 0x15264
movss 0x4(%rdx,%rcx,8), %xmm0
addss %xmm1, %xmm0
mulss %xmm2, %xmm0
divss %xmm3, %xmm0
movss %xmm0, 0x4(%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x53a5
jmp 0x53cf
xorl %r12d, %r12d
cmpl $0x0, (%rbx)
je 0x53fc
movslq %r12d, %rdx
movl $0x8, %esi
movq 0x18(%rsp), %rdi
movq 0x60(%rsp), %r14
movq %r14, %rcx
callq 0x3450
movq %r14, %rdi
callq 0x3100
movl 0xc4(%rsp), %eax
movl %eax, 0xc(%rsp)
movq %r15, %rdi
callq 0x3040
movq 0x10(%rsp), %rdx
incq %rdx
movslq 0xc(%rsp), %rax
movq %rdx, 0x10(%rsp)
cmpq %rax, %rdx
leaq 0xfc3e(%rip), %r12      # 0x1505e
leaq 0x11ba5(%rip), %rbp     # 0x16fcc
jl 0x4b77
movl 0xa4(%rsp), %ebx
testl %ebx, %ebx
jle 0x5455
movl %ebx, %ebx
xorl %r14d, %r14d
movq 0x1908c(%rip), %rax     # 0x1e4d0
movq (%rax,%r14,8), %rdi
callq 0x3040
incq %r14
cmpq %r14, %rbx
jne 0x543d
movq 0x19074(%rip), %rdi     # 0x1e4d0
callq 0x3040
movq 0x18(%rsp), %rdi
callq 0x3040
movq 0x50(%rsp), %rdi
callq 0x3040
movq 0x38(%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 0xffe1(%rip), %rsi      # 0x15485
leaq 0xd0(%rsp), %rdx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0xff86(%rip), %rsi      # 0x15447
jmp 0x5515
callq 0x3060
movl (%rax), %edi
leaq 0xff4c(%rip), %rsi      # 0x1541d
leaq 0x102d8(%rip), %rdx     # 0x157b0
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0xff96(%rip), %rsi      # 0x15485
movq %r14, %rdx
jmp 0x54ac
callq 0x3060
movl (%rax), %edi
leaq 0xff83(%rip), %rsi      # 0x15485
movq %rbx, %rdx
jmp 0x54ac
callq 0x3060
movl (%rax), %edi
leaq 0xff8b(%rip), %rsi      # 0x154a0
xorl %eax, %eax
callq 0x3330