// File: /workspace/github_c_makefile_star2_O2/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 $0x288, %rsp            # imm = 0x288
cmpb $0x0, 0x14(%rdi)
je 0x5236
movq %rdi, %rax
cmpb $0x0, 0x114(%rdi)
je 0x5236
leaq 0x14(%rax), %rbp
leaq 0x114(%rax), %rsi
movq %rbp, %rdi
movq %rsi, 0x68(%rsp)
movq %rax, 0x20(%rsp)
callq 0x32b0
testl %eax, %eax
je 0x5236
leaq 0xffbc(%rip), %rsi      # 0x14760
movq %rbp, %rdi
callq 0x68a5
testq %rax, %rax
je 0x5246
movq %rax, %rbx
leaq 0xffa1(%rip), %rsi      # 0x14760
movq 0x68(%rsp), %rdi
callq 0x68a5
testq %rax, %rax
je 0x5246
movq %rax, %r15
leaq 0xf88b(%rip), %rsi      # 0x14067
movq %rbx, %rdi
callq 0x33a0
testq %rax, %rax
je 0x5264
movq %rax, %r14
leaq 0xf870(%rip), %rsi      # 0x14067
movq %r15, %rdi
callq 0x33a0
testq %rax, %rax
je 0x5277
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
pushq $0x20
popq %r15
pushq $0x1
popq %r13
movq %r15, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x30c0
leaq 0xd0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x30c0
cmpb $0x0, 0x4(%r12)
je 0x528a
movl 0xd0(%rsp), %esi
movl 0xb0(%rsp), %edx
cmpl %edx, %esi
je 0x486e
leaq 0xfc1a(%rip), %rdi      # 0x14481
xorl %eax, %eax
callq 0x3170
movslq 0xc4(%rsp), %r15
leaq (,%r15,4), %rdi
callq 0x3340
movq %rax, %r12
pushq $0x4
popq %r13
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x30c0
movq %r15, %rdi
shlq $0x8, %rdi
callq 0x3340
movl $0x100, %esi            # imm = 0x100
movq %rax, 0x60(%rsp)
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x30c0
movl 0xe4(%rsp), %eax
movl %eax, 0x1c(%rsp)
movslq %eax, %r14
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x30c0
movq %r12, %rdi
callq 0x3040
movq %r14, %rdi
shlq $0x8, %rdi
callq 0x3340
movl $0x100, %esi            # imm = 0x100
movq %rax, 0x38(%rsp)
movq %rax, %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x30c0
movq %r15, %rbx
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x3340
movq %rax, 0x18bb0(%rip)     # 0x1d4d0
xorl %r12d, %r12d
testl %r15d, %r15d
movl $0x0, %r13d
cmovgl %r15d, %r13d
pushq $0x20
popq %r14
cmpq %r12, %r13
je 0x4951
movq %r14, %rdi
callq 0x3340
movq 0x18b88(%rip), %rcx     # 0x1d4d0
movq %rax, (%rcx,%r12,8)
incq %r12
jmp 0x4934
movq %rbx, %rdi
callq 0x3340
movq %rax, 0x40(%rsp)
movq 0x20(%rsp), %rax
addq $0x214, %rax            # imm = 0x214
movq %rax, 0x88(%rsp)
leaq 0xf6e6(%rip), %r13      # 0x1405e
xorl %ebx, %ebx
movq %rbp, 0x70(%rsp)
movslq 0x1c(%rsp), %rax
movslq 0xc4(%rsp), %r14
cmpq %rax, %rbx
jge 0x51be
movq 0x18b34(%rip), %rax     # 0x1d4d0
testl %r14d, %r14d
movl $0x0, %ecx
movq %r14, 0x58(%rsp)
cmovgl %r14d, %ecx
movq %rcx, 0x30(%rsp)
xorl %ecx, %ecx
cmpq %rcx, 0x30(%rsp)
je 0x49c7
movq (%rax,%rcx,8), %rdx
andl $0x0, (%rdx)
incq %rcx
jmp 0x49b4
movq %rbx, 0x28(%rsp)
movl 0xc0(%rsp), %eax
xorl %r14d, %r14d
testl %eax, %eax
cmovlel %r14d, %eax
movl %eax, 0x54(%rsp)
cmpl 0x54(%rsp), %r14d
je 0x4ea2
leaq 0x180(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
leaq 0x11579(%rip), %rcx     # 0x15f7c
movl %r14d, %r8d
xorl %eax, %eax
callq 0x3430
movq %r15, %rdi
leaq 0xf650(%rip), %r12      # 0x14067
movq %r12, %rsi
callq 0x33a0
testq %rax, %rax
je 0x5219
movq %rax, %rbx
movq %r15, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x32e0
movl %r14d, 0xc(%rsp)
movq 0x120(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rax, 0x80(%rsp)
movq %rax, %rdi
movq %r14, %rsi
movq %rbp, %r14
pushq $0x1
popq %rbp
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x30c0
movq %rbx, %rdi
callq 0x3100
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
leaq 0x114fc(%rip), %rcx     # 0x15f83
movl 0xc(%rsp), %r8d
xorl %eax, %eax
callq 0x3430
movq %r15, %rdi
movq %r12, %rsi
callq 0x33a0
testq %rax, %rax
je 0x5219
movq %rax, %rbx
leaq 0x180(%rsp), %r12
movq %r12, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x32e0
movq 0x120(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rax, 0x78(%rsp)
movq %rax, %rdi
movq %r14, %rsi
movq %r13, %r14
movl 0xc(%rsp), %r13d
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x30c0
movq %rbx, %rdi
callq 0x3100
movq %r12, %rdi
movq %r14, %rsi
movq 0x68(%rsp), %r15
movq %r15, %rdx
leaq 0x1146f(%rip), %rcx     # 0x15f7c
movl %r13d, %r8d
xorl %eax, %eax
callq 0x3430
movq %r12, %rdi
leaq 0xf546(%rip), %rsi      # 0x14067
callq 0x33a0
testq %rax, %rax
je 0x5219
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x32e0
movq 0x120(%rsp), %r12
movq %r12, %rdi
callq 0x3340
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x30c0
movq %rbx, %rdi
callq 0x3100
leaq 0x180(%rsp), %rbx
movq %rbx, %rdi
leaq 0xf4d9(%rip), %rsi      # 0x1405e
movq %r15, %rdx
leaq 0x113f4(%rip), %rcx     # 0x15f83
movl %r13d, %r8d
xorl %eax, %eax
callq 0x3430
movq %rbx, %rdi
leaq 0xf4c4(%rip), %rsi      # 0x14067
callq 0x33a0
testq %rax, %rax
je 0x5219
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x32e0
movq 0x120(%rsp), %r12
movq %r12, %rdi
callq 0x3340
movq %rax, %rbp
movq %rax, %rdi
movq %r12, %rsi
pushq $0x1
popq %r12
movq %r12, %rdx
movq %rbx, %rcx
callq 0x30c0
movq %rbx, %rdi
callq 0x3100
leaq 0x180(%rsp), %rbx
movq %rbx, %rdi
leaq 0xf8b9(%rip), %rsi      # 0x144c4
movq %r15, %rdx
leaq 0x11367(%rip), %rcx     # 0x15f7c
movl %r13d, %r8d
xorl %eax, %eax
callq 0x3430
movq %rbx, %rdi
leaq 0xf43e(%rip), %rsi      # 0x14067
callq 0x33a0
testq %rax, %rax
je 0x5219
movq %rax, %r15
leaq 0x180(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x32e0
movq 0x120(%rsp), %rbx
movq %rbx, %rdi
callq 0x3340
movq %rax, 0x10(%rsp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x30c0
movq %r15, 0x48(%rsp)
movq %r15, %rdi
callq 0x3100
movq 0x28(%rsp), %rax
movq %rbp, %r15
movq (%rbp,%rax,8), %r13
movq 0x8(%rbp,%rax,8), %rbp
movq %rbp, %rax
subq %r13, %rax
movq %rax, %xmm0
punpckldq 0xf389(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xf391(%rip), %xmm0     # 0x14040
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0xf52d(%rip), %xmm1     # 0x141f0
cvttsd2si %xmm1, %edi
callq 0x11439
movl %eax, %r12d
movslq %eax, %rbx
movq %rbx, %rdi
pushq $0x8
popq %rsi
callq 0x32a0
movq %rbp, %r10
movq %r13, %r9
movq %rax, %rbp
leal -0x1(%rbx), %r13d
testl %ebx, %ebx
movl $0x0, %eax
cmovlel %eax, %ebx
movq 0x80(%rsp), %r8
cmpq %r10, %r9
jae 0x4d41
xorl %edi, %edi
cmpl %edi, %ebx
je 0x4d3c
movl (%r14,%r9,4), %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r12d
movl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %r13d
leal 0x1(%rdx), %eax
imull %edi, %eax
addl %esi, %eax
xorl %edx, %edx
divl %r12d
incl %edi
cmpq $0x0, (%rbp,%rdx,8)
jne 0x4d03
incq %r9
movq %r9, (%rbp,%rdx,8)
jmp 0x4cfc
incq %r9
jmp 0x4cfc
xorl %r9d, %r9d
movq %r15, 0x90(%rsp)
cmpq 0x30(%rsp), %r9
je 0x4e4d
movq 0x78(%rsp), %rax
movq (%rax,%r9,8), %r15
movq 0x8(%rax,%r9,8), %r10
leaq 0x1(%r9), %rax
movq %rax, 0x98(%rsp)
movq %r9, 0xa8(%rsp)
movq %r10, 0xa0(%rsp)
cmpq %r10, %r15
jae 0x4e38
xorl %edi, %edi
cmpl %edi, %ebx
je 0x4e30
movl (%r8,%r15,4), %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r12d
movl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %r13d
leal 0x1(%rdx), %eax
imull %edi, %eax
addl %esi, %eax
xorl %edx, %edx
divl %r12d
movq (%rbp,%rdx,8), %rax
testq %rax, %rax
je 0x4e30
incl %edi
cmpl %ecx, -0x4(%r14,%rax,4)
jne 0x4d8c
movq 0x18701(%rip), %rcx     # 0x1d4d0
movq (%rcx,%r9,8), %rdi
movslq (%rdi), %rcx
leaq 0x1(%rcx), %rdx
movl %edx, (%rdi)
movq 0x10(%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 0x4e30
andl $0x7ffffff8, %eax       # imm = 0x7FFFFFF8
addl $0x10, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
callq 0x3350
movq 0xa0(%rsp), %r10
movq 0xa8(%rsp), %r9
movq 0x80(%rsp), %r8
movq 0x186a4(%rip), %rcx     # 0x1d4d0
movq %rax, (%rcx,%r9,8)
incq %r15
jmp 0x4d81
movq 0x98(%rsp), %r9
movq 0x90(%rsp), %r15
jmp 0x4d4c
movq %rbp, %rdi
movq %r8, %rbx
callq 0x3040
movq %rbx, %rdi
callq 0x3040
movq 0x78(%rsp), %rdi
callq 0x3040
movq %r14, %rdi
callq 0x3040
movq %r15, %rdi
callq 0x3040
movq 0x10(%rsp), %rdi
callq 0x3040
movl 0xc(%rsp), %r14d
incl %r14d
movq 0x70(%rsp), %rbp
leaq 0xf1c6(%rip), %r13      # 0x1405e
movq 0x48(%rsp), %r12
jmp 0x49e0
movq 0x58(%rsp), %rax
leaq (,%rax,4), %rdi
callq 0x3340
movq %rax, %r15
xorl %eax, %eax
movq 0x88(%rsp), %rbx
cmpq %rax, 0x30(%rsp)
je 0x4ed1
movl %eax, (%r15,%rax,4)
incq %rax
jmp 0x4ec1
movq %r15, %rdi
movq 0x58(%rsp), %rsi
pushq $0x4
popq %rdx
leaq 0x1248(%rip), %rcx      # 0x612b
callq 0x30b0
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax)
je 0x4f95
movq %rbx, %rdi
callq 0x3130
cmpq $0x2, %rax
ja 0x4f29
leaq 0x180(%rsp), %rdi
leaq 0xf480(%rip), %rsi      # 0x14393
movq %rbp, %rdx
movq %rdi, %r14
leaq 0xf35a(%rip), %rcx      # 0x1427a
xorl %eax, %eax
callq 0x3430
jmp 0x4f3c
leaq 0x180(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3080
movq %r14, %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x3090
movq 0x28(%rsp), %rdi
shlq $0x8, %rdi
addq 0x38(%rsp), %rdi
callq 0x3300
movq %r14, %rdi
leaq 0xf411(%rip), %rsi      # 0x14377
movq %r14, %rdx
movq %rax, %rcx
leaq 0xf2f5(%rip), %r8       # 0x14268
xorl %eax, %eax
callq 0x3430
movq %r14, %rdi
leaq 0xf0e6(%rip), %rsi      # 0x1406a
callq 0x33a0
movq %rax, %r12
testq %rax, %rax
je 0x5219
movq %r12, 0x48(%rsp)
movq 0x28(%rsp), %rbx
shlq $0x8, %rbx
addq 0x38(%rsp), %rbx
xorps %xmm3, %xmm3
xorl %ebp, %ebp
xorl %r13d, %r13d
movslq %r13d, %r14
cmpq 0x30(%rsp), %rbp
je 0x511f
movq 0x1850b(%rip), %rax     # 0x1d4d0
movslq (%r15,%rbp,4), %rcx
movq (%rax,%rcx,8), %rdi
movl (%rdi), %r12d
cmpl $0x6, %r12d
jl 0x511f
movss %xmm3, 0x10(%rsp)
addq $0x4, %rdi
movq %r12, %rsi
pushq $0x4
popq %rdx
leaq 0x1154(%rip), %rcx      # 0x6145
callq 0x30b0
movq 0x184d3(%rip), %rax     # 0x1d4d0
leal 0x1(%r12), %edx
movslq (%r15,%rbp,4), %rcx
movq (%rax,%rcx,8), %rsi
xorl %ecx, %ecx
pushq $0x1
popq %rdi
cmpq %rdi, %rdx
je 0x501c
addl (%rsi,%rdi,4), %ecx
incq %rdi
jmp 0x500f
cvtsi2sd %r12d, %xmm0
movapd %xmm0, %xmm1
mulsd 0xf1cb(%rip), %xmm1     # 0x141f8
cvttsd2si %xmm1, %edx
mulsd 0xf1c7(%rip), %xmm0     # 0x14200
movslq %edx, %r8
shlq $0x2, %r8
xorl %esi, %esi
xorl %edi, %edi
leal (%rdx,%rsi), %r9d
cvtsi2sd %r9d, %xmm1
ucomisd %xmm1, %xmm0
jb 0x5067
movslq (%r15,%rbp,4), %r9
movq (%rax,%r9,8), %r9
addq %r8, %r9
addl (%r9,%rsi,4), %edi
incq %rsi
jmp 0x5044
movl %r12d, %r8d
shrl %r8d
movq 0x20(%rsp), %rdx
cmpl $0x0, (%rdx)
movl (%r15,%rbp,4), %edx
movslq %edx, %r9
je 0x50c1
cmpl $0x8, %r12d
jl 0x5111
movq (%rax,%r9,8), %rax
cmpl $0x2, (%rax,%r8,4)
movss 0x10(%rsp), %xmm3
jl 0x5117
movq 0x40(%rsp), %rax
movl %edx, (%rax,%r14,8)
cvtsi2ss %edi, %xmm0
cvtsi2ss %esi, %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x4(%rax,%r14,8)
addss %xmm0, %xmm3
incl %r14d
movl %r14d, %r13d
jmp 0x5117
cvtsi2ss %ecx, %xmm0
movq %r9, %rdx
cvtsi2ss %r12d, %xmm1
shlq $0x8, %rdx
cvtsi2ss %edi, %xmm2
divss %xmm1, %xmm0
cvtsi2ss %esi, %xmm1
addq 0x60(%rsp), %rdx
cvtss2sd %xmm0, %xmm0
divss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm1
movq (%rax,%r9,8), %rax
movl %r8d, %ecx
movl (%rax,%rcx,4), %r8d
movl (%rax,%r12,4), %r9d
leaq 0xf3cb(%rip), %rdi      # 0x144cf
movq %rbx, %rsi
movl %r12d, %ecx
movb $0x2, %al
callq 0x3170
movss 0x10(%rsp), %xmm3
incq %rbp
jmp 0x4fb0
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax)
movq 0x70(%rsp), %rbp
movq 0x28(%rsp), %rbx
movq 0x48(%rsp), %r12
je 0x51a7
cvtsi2ss %r13d, %xmm0
subss %xmm0, %xmm3
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
xorl %eax, %eax
movq 0x40(%rsp), %rdi
movss 0xf0b4(%rip), %xmm1     # 0x14210
movss 0xf0b0(%rip), %xmm2     # 0x14214
cmpq %rax, %r13
je 0x5186
movss 0x4(%rdi,%rax,8), %xmm0
addss %xmm1, %xmm0
mulss %xmm2, %xmm0
divss %xmm3, %xmm0
movss %xmm0, 0x4(%rdi,%rax,8)
incq %rax
jmp 0x5164
pushq $0x8
popq %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x3450
movq %r12, %rdi
callq 0x3100
movl 0xe4(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq %r15, %rdi
callq 0x3040
incq %rbx
leaq 0xeea5(%rip), %r13      # 0x1405e
jmp 0x497f
xorl %ebx, %ebx
testl %r14d, %r14d
cmovlel %ebx, %r14d
movq 0x18302(%rip), %rdi     # 0x1d4d0
cmpq %rbx, %r14
je 0x51e1
movq (%rdi,%rbx,8), %rdi
callq 0x3040
incq %rbx
jmp 0x51c7
callq 0x3040
movq 0x40(%rsp), %rdi
callq 0x3040
movq 0x60(%rsp), %rdi
callq 0x3040
movq 0x38(%rsp), %rdi
callq 0x3040
pushq $0x1
popq %rax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3060
movl (%rax), %edi
leaq 0xf20e(%rip), %rsi      # 0x14435
leaq 0x180(%rsp), %rdx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0xf1b3(%rip), %rsi      # 0x143f7
jmp 0x5298
callq 0x3060
movl (%rax), %edi
leaq 0xf179(%rip), %rsi      # 0x143cd
leaq 0xf505(%rip), %rdx      # 0x14760
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0xf1c3(%rip), %rsi      # 0x14435
movq %rbx, %rdx
jmp 0x522f
callq 0x3060
movl (%rax), %edi
leaq 0xf1b0(%rip), %rsi      # 0x14435
movq %r15, %rdx
jmp 0x522f
callq 0x3060
movl (%rax), %edi
leaq 0xf1b8(%rip), %rsi      # 0x14450
xorl %eax, %eax
callq 0x3330