// File: /workspace/github_c_makefile_star2_O0/yhg926[P]public_kssd/command_composite.c
// Function: index_abv
int index_abv (composite_opt_t *composite_opt){
 char* abv_dpath = malloc(PATHLEN);
 sprintf(abv_dpath,"%s/%s", composite_opt->refdir,binVec_dirname);
 DIR *abv_dir = opendir(abv_dpath);
 if(!abv_dir) err(errno, "index_abv(): %s does not exists! \n",abv_dpath);
 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, composite_opt->refdir);
 FILE *ref_dstat_fp;
 if( (ref_dstat_fp = fopen(ref_dstat_fpath,"rb")) == NULL ) err(errno, "index_abv():%s",ref_dstat_fpath);
 co_dstat_t ref_dstat;
 fread( &ref_dstat, sizeof(co_dstat_t),1,ref_dstat_fp);
 fclose(ref_dstat_fp);
 int *abunMtx_count = calloc(ref_dstat.infile_num,sizeof(int));
 binVec_t **abunMtx_dynamic = malloc(sizeof(binVec_t *) * ref_dstat.infile_num);
 for(int i =0; i< ref_dstat.infile_num;i++) abunMtx_dynamic[i] = malloc(sizeof(binVec_t));
 int abv_fcnt = 0;
 FILE *abvfh,*namefh,*abunMtx_idxfh,*abunMtx_fh,*y_l2n_fh;
 struct dirent *dirent;
 binVec_t binVec_tmp;
 char* abv_fpath = malloc(PATHLEN);
 sprintf(abv_fpath,"%s/%s.%s",composite_opt->refdir,binVec_dirname,abunMtx_name_suffix);
 if(( namefh = fopen(abv_fpath,"w") ) == NULL) err(errno, "index_abv():%s",abv_fpath);
 sprintf(abv_fpath,"%s/%s.%s",composite_opt->refdir,binVec_dirname,y_l2n_suffix);
 if(( y_l2n_fh = fopen(abv_fpath,"wb") ) == NULL) err(errno, "index_abv():%s",abv_fpath);
 while (( dirent = readdir(abv_dir)) != NULL){
  const char *ext = strrchr(dirent->d_name,'.');
  if(strcmp(ext + 1, binVec_suffix) == 0){
   sprintf(abv_fpath,"%s/%s",abv_dpath,dirent->d_name);
   if(( abvfh = fopen(abv_fpath,"rb") ) == NULL) err(errno, "index_abv():%s",abv_fpath);
   double y_l2n = 0;
   struct stat st;
   stat(abv_fpath, &st);
   int abv_len = st.st_size/sizeof(binVec_t) ;
   for(int i =0; i<abv_len ;i++){
    fread(&binVec_tmp , sizeof(binVec_t), 1,abvfh);
     y_l2n+= binVec_tmp.pct*binVec_tmp.pct;
    abunMtx_dynamic[binVec_tmp.ref_idx] = realloc((binVec_t *)abunMtx_dynamic[binVec_tmp.ref_idx], sizeof(binVec_t) * (abunMtx_count[binVec_tmp.ref_idx] + 1) );
        abunMtx_dynamic[binVec_tmp.ref_idx][abunMtx_count[binVec_tmp.ref_idx]].ref_idx = abv_fcnt ;
    abunMtx_dynamic[binVec_tmp.ref_idx][abunMtx_count[binVec_tmp.ref_idx]].pct = binVec_tmp.pct;
    abunMtx_count[binVec_tmp.ref_idx]++;
   }
   fclose(abvfh);
   sprintf(abv_fpath,"%s\n",dirent->d_name);
   fwrite(abv_fpath,strlen(abv_fpath),1,namefh);
   y_l2n = sqrt(y_l2n);
   fwrite(&y_l2n,sizeof(double),1,y_l2n_fh);
   abv_fcnt++;
  }
 };
 closedir(abv_dir);
 fclose(namefh);
 fclose(y_l2n_fh);
  sprintf(abv_fpath,"%s/%s.%s",composite_opt->refdir,binVec_dirname,abunMtx_suffix);
 if(( abunMtx_fh = fopen(abv_fpath,"wb") ) == NULL) err(errno, "index_abv():%s",abv_fpath);
 for(int i = 0 ;i < ref_dstat.infile_num;i++){
  if(abunMtx_count[i])
   fwrite( abunMtx_dynamic[i], sizeof(binVec_t), abunMtx_count[i],abunMtx_fh);
 }
 fclose(abunMtx_fh);
 for(int i = 1 ;i < ref_dstat.infile_num;i++)
  abunMtx_count[i] += abunMtx_count[i-1];
 sprintf(abv_fpath,"%s/%s.%s",composite_opt->refdir,binVec_dirname,abunMtx_idx_suffix);
 if(( abunMtx_idxfh = fopen(abv_fpath,"wb") ) == NULL) err(errno, "index_abv():%s",abv_fpath);
 fwrite(abunMtx_count,sizeof(int),ref_dstat.infile_num,abunMtx_idxfh);
 fclose(abunMtx_idxfh);
 free(abv_dpath);
 free(abv_fpath);
 free(abunMtx_count);
 free(abunMtx_dynamic);
 return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movl $0x100, %edi            # imm = 0x100
callq 0x3310
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0x14, %rdx
leaq 0x1624b(%rip), %rsi     # 0x1c32b
leaq 0x1612b(%rip), %rcx     # 0x1c212
movb $0x0, %al
callq 0x3400
movq -0x10(%rbp), %rdi
callq 0x30f0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x611b
callq 0x3050
movl (%rax), %edi
movq -0x10(%rbp), %rdx
leaq 0x16248(%rip), %rsi     # 0x1c35c
movb $0x0, %al
callq 0x3300
movq -0x8(%rbp), %rdi
addq $0x14, %rdi
leaq 0x165c6(%rip), %rsi     # 0x1c6f0
callq 0x8250
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x615e
callq 0x3050
movl (%rax), %edi
movq -0x8(%rbp), %rcx
addq $0x14, %rcx
leaq 0x1622f(%rip), %rsi     # 0x1c37f
leaq 0x16599(%rip), %rdx     # 0x1c6f0
movb $0x0, %al
callq 0x3300
movq -0x20(%rbp), %rdi
leaq 0x15eee(%rip), %rsi     # 0x1c057
callq 0x3370
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x6191
callq 0x3050
movl (%rax), %edi
movq -0x20(%rbp), %rdx
leaq 0x1620e(%rip), %rsi     # 0x1c398
movb $0x0, %al
callq 0x3300
movq -0x28(%rbp), %rcx
leaq -0x48(%rbp), %rdi
movl $0x20, %esi
movl $0x1, %edx
callq 0x30a0
movq -0x28(%rbp), %rdi
callq 0x30e0
movslq -0x34(%rbp), %rdi
movl $0x4, %esi
callq 0x3270
movq %rax, -0x50(%rbp)
movslq -0x34(%rbp), %rdi
shlq $0x3, %rdi
callq 0x3310
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x6207
movl $0x8, %edi
callq 0x3310
movq %rax, %rdx
movq -0x58(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x61db
movl $0x0, -0x60(%rbp)
movl $0x100, %edi            # imm = 0x100
callq 0x3310
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0x14, %rdx
leaq 0x160da(%rip), %rsi     # 0x1c30f
leaq 0x15fd6(%rip), %rcx     # 0x1c212
leaq 0x15fca(%rip), %r8      # 0x1c20d
movb $0x0, %al
callq 0x3400
movq -0xa0(%rbp), %rdi
leaq 0x1614f(%rip), %rsi     # 0x1c3a7
callq 0x3370
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
jne 0x6283
callq 0x3050
movl (%rax), %edi
movq -0xa0(%rbp), %rdx
leaq 0x1611c(%rip), %rsi     # 0x1c398
movb $0x0, %al
callq 0x3300
movq -0xa0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0x14, %rdx
leaq 0x16076(%rip), %rsi     # 0x1c30f
leaq 0x15f72(%rip), %rcx     # 0x1c212
leaq 0x15f79(%rip), %r8      # 0x1c220
movb $0x0, %al
callq 0x3400
movq -0xa0(%rbp), %rdi
leaq 0x15d9e(%rip), %rsi     # 0x1c05a
callq 0x3370
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
jne 0x62ea
callq 0x3050
movl (%rax), %edi
movq -0xa0(%rbp), %rdx
leaq 0x160b5(%rip), %rsi     # 0x1c398
movb $0x0, %al
callq 0x3300
jmp 0x62ec
movq -0x18(%rbp), %rdi
callq 0x32f0
movq %rax, -0x90(%rbp)
cmpq $0x0, %rax
je 0x6579
movq -0x90(%rbp), %rdi
addq $0x13, %rdi
movl $0x2e, %esi
callq 0x31b0
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
addq $0x1, %rdi
leaq 0x15ecc(%rip), %rsi     # 0x1c200
callq 0x3280
cmpl $0x0, %eax
jne 0x6574
movq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rdx
movq -0x90(%rbp), %rcx
addq $0x13, %rcx
leaq 0x15fcc(%rip), %rsi     # 0x1c32b
movb $0x0, %al
callq 0x3400
movq -0xa0(%rbp), %rdi
leaq 0x15ce3(%rip), %rsi     # 0x1c057
callq 0x3370
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
jne 0x639f
callq 0x3050
movl (%rax), %edi
movq -0xa0(%rbp), %rdx
leaq 0x16000(%rip), %rsi     # 0x1c398
movb $0x0, %al
callq 0x3300
xorps %xmm0, %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0xa0(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x32b0
movq -0x110(%rbp), %rax
shrq $0x3, %rax
movl %eax, -0x144(%rbp)
movl $0x0, -0x148(%rbp)
movl -0x148(%rbp), %eax
cmpl -0x144(%rbp), %eax
jge 0x64de
movq -0x68(%rbp), %rcx
leaq -0x98(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x30a0
movss -0x94(%rbp), %xmm0
mulss -0x94(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x58(%rbp), %rax
movslq -0x98(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x50(%rbp), %rax
movslq -0x98(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x3320
movq %rax, %rdx
movq -0x58(%rbp), %rax
movslq -0x98(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x60(%rbp), %edx
movq -0x58(%rbp), %rax
movslq -0x98(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x50(%rbp), %rcx
movslq -0x98(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,8)
movss -0x94(%rbp), %xmm0
movq -0x58(%rbp), %rax
movslq -0x98(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x50(%rbp), %rcx
movslq -0x98(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movss %xmm0, 0x4(%rax,%rcx,8)
movq -0x50(%rbp), %rax
movslq -0x98(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x148(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x148(%rbp)
jmp 0x63d8
movq -0x68(%rbp), %rdi
callq 0x30e0
movq -0xa0(%rbp), %rdi
movq -0x90(%rbp), %rdx
addq $0x13, %rdx
leaq 0x16f6a(%rip), %rsi     # 0x1d46a
movb $0x0, %al
callq 0x3400
movq -0xa0(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x3110
movq -0x158(%rbp), %rdi
movq %rax, %rsi
movq -0x70(%rbp), %rcx
movl $0x1, %edx
callq 0x3420
movsd -0xb0(%rbp), %xmm0
callq 0x3430
movsd %xmm0, -0xb0(%rbp)
movq -0x88(%rbp), %rcx
leaq -0xb0(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x3420
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x62ec
movq -0x18(%rbp), %rdi
callq 0x3220
movq -0x70(%rbp), %rdi
callq 0x30e0
movq -0x88(%rbp), %rdi
callq 0x30e0
movq -0xa0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0x14, %rdx
leaq 0x15d62(%rip), %rsi     # 0x1c30f
leaq 0x15c5e(%rip), %rcx     # 0x1c212
leaq 0x15c49(%rip), %r8      # 0x1c204
movb $0x0, %al
callq 0x3400
movq -0xa0(%rbp), %rdi
leaq 0x15a8a(%rip), %rsi     # 0x1c05a
callq 0x3370
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
jne 0x65fb
callq 0x3050
movl (%rax), %edi
movq -0xa0(%rbp), %rdx
leaq 0x15da4(%rip), %rsi     # 0x1c398
movb $0x0, %al
callq 0x3300
movl $0x0, -0x14c(%rbp)
movl -0x14c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x6660
movq -0x50(%rbp), %rax
movslq -0x14c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x664d
movq -0x58(%rbp), %rax
movslq -0x14c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x50(%rbp), %rax
movslq -0x14c(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
movq -0x80(%rbp), %rcx
movl $0x8, %esi
callq 0x3420
jmp 0x664f
movl -0x14c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14c(%rbp)
jmp 0x6605
movq -0x80(%rbp), %rdi
callq 0x30e0
movl $0x1, -0x150(%rbp)
movl -0x150(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x66b3
movq -0x50(%rbp), %rax
movl -0x150(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x50(%rbp), %rax
movslq -0x150(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x150(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x150(%rbp)
jmp 0x6673
movq -0xa0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0x14, %rdx
leaq 0x15c46(%rip), %rsi     # 0x1c30f
leaq 0x15b42(%rip), %rcx     # 0x1c212
leaq 0x15b31(%rip), %r8      # 0x1c208
movb $0x0, %al
callq 0x3400
movq -0xa0(%rbp), %rdi
leaq 0x1596e(%rip), %rsi     # 0x1c05a
callq 0x3370
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
jne 0x6717
callq 0x3050
movl (%rax), %edi
movq -0xa0(%rbp), %rdx
leaq 0x15c88(%rip), %rsi     # 0x1c398
movb $0x0, %al
callq 0x3300
movq -0x50(%rbp), %rdi
movslq -0x34(%rbp), %rdx
movq -0x78(%rbp), %rcx
movl $0x4, %esi
callq 0x3420
movq -0x78(%rbp), %rdi
callq 0x30e0
movq -0x10(%rbp), %rdi
callq 0x3040
movq -0xa0(%rbp), %rdi
callq 0x3040
movq -0x50(%rbp), %rdi
callq 0x3040
movq -0x58(%rbp), %rdi
callq 0x3040
movl $0x1, %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopl (%rax,%rax)