// File: /workspace/github_c_makefile_star2_O0/yhg926[P]public_kssd/command_set.c
// Function: combin_subset_pans
int combin_subset_pans(char* taxfile){
 compan_t *subset = organize_taxf(taxfile);
  const char* co_dstat_fpath = NULL;
 co_dstat_fpath = test_get_fullpath(set_opt.insketchpath,co_dstat);
  if(co_dstat_fpath == NULL ) err(errno,"cannot find %s under %s ",co_dstat,set_opt.insketchpath);
 FILE *tmpfh;
 if( ( tmpfh = fopen(co_dstat_fpath,"rb")) == NULL ) err(errno,"combin_subset_pans():%s",co_dstat_fpath);
 co_dstat_t co_dstat_readin;
 fread( &co_dstat_readin, sizeof(co_dstat_t),1,tmpfh );
 fclose(tmpfh);
 if(co_dstat_readin.infile_num != subset->gn)
  err(errno,"combin_subset_pans():%s's genome number %d not matches %s's genome number %d",co_dstat_fpath,co_dstat_readin.infile_num,taxfile,subset->gn);
 free(co_dstat_fpath);
 mkdir(set_opt.outdir,0777);
 char tmppath[PATHLEN]; struct stat s; int outfn = 0; llong all_ctx_ct = 0;
 ctx_obj_ct_t *ctx_ct_list = calloc(subset->taxn,sizeof(ctx_obj_ct_t));
 size_t comp_sz = (1LLU << 4*COMPONENT_SZ);
  llong* dict = (llong*)malloc(comp_sz/8);
  size_t *outcombcoidx = malloc(sizeof(size_t)* (subset->taxn+1));
  for(int c=0; c < co_dstat_readin.comp_num; c++){
  sprintf(tmppath,"%s/%s.%d",set_opt.insketchpath,skch_prefix,c);
  if(stat(tmppath, &s) != 0) err(errno,"combin_subset_pans():%s",tmppath);
  unsigned int *tmpcombco = malloc(s.st_size);
  if((tmpfh = fopen(tmppath,"rb")) == NULL) err(errno,"combin_subset_pans():%s",tmppath);
  fread(tmpcombco,s.st_size, 1,tmpfh);
  fclose(tmpfh);
  sprintf(tmppath,"%s/%s.%d",set_opt.insketchpath,idx_prefix,c);
  if(stat(tmppath, &s) != 0) err(errno,"combin_subset_pans():%s",tmppath);
  size_t *tmpcombcoidx = malloc(s.st_size);
  if((tmpfh = fopen(tmppath,"rb")) == NULL) err(errno,"combin_subset_pans():%s",tmppath);
  fread(tmpcombcoidx,s.st_size, 1,tmpfh);
  fclose(tmpfh);
  sprintf(tmppath,"%s/%s.%d",set_opt.outdir,skch_prefix,c);
  if((tmpfh = fopen(tmppath,"wb")) == NULL) err(errno,"combin_subset_pans():%s",tmppath);
  outfn = 0;
  size_t offset = 0;
  outcombcoidx[0] = 0;
  for(int t = 0; t < subset->taxn; t++){
   if(subset->tax[t].taxid == 0) continue;
    memset(dict,0,comp_sz/8);
    for(int n = 1; n <= subset->tax[t].gids[0];n++){
     int gid = subset->tax[t].gids[n] ;
     for(size_t i= tmpcombcoidx[gid]; i < tmpcombcoidx[gid+1];i++){
      dict[tmpcombco[i]/64] |= ( 0x8000000000000000LLU >> (tmpcombco[i] % 64) ) ;
     }
    }
    for(unsigned int n=0;n< comp_sz/64; n++){
        if(dict[n]){
          for(int b=0; b< 64; b++){
            if ((0x8000000000000000LLU >> b) & dict[n]){
              unsigned int var = 64*n + b ;
              fwrite(&var,sizeof(unsigned int),1,tmpfh);
        offset++; all_ctx_ct++; ctx_ct_list[outfn]++;
            }
          }
        }
    }
    outfn++;
    outcombcoidx[outfn]= offset;
    printf("%d/%d species pangenome grouped\r",t,subset->taxn);
  }
  printf("\n");
  fclose(tmpfh);
  sprintf(tmppath,"%s/%s.%d",set_opt.outdir,idx_prefix,c);
  tmpfh = fopen(tmppath,"wb");
  if(tmpfh == NULL) err(errno,"combin_subset_pans():%s",tmppath);
  fwrite(outcombcoidx,sizeof(size_t),outfn+1,tmpfh);
  fclose(tmpfh);
  free(tmpcombco);
   free(tmpcombcoidx);
 }
 co_dstat_readin.infile_num = outfn;
 co_dstat_readin.koc = 0;
 co_dstat_readin.all_ctx_ct = all_ctx_ct;
 sprintf(tmppath,"%s/%s",set_opt.outdir,co_dstat);
 if((tmpfh = fopen(tmppath,"wb")) == NULL) err(errno,"combin_subset_pans():%s",tmppath);
 fwrite(&co_dstat_readin,sizeof(co_dstat_t),1,tmpfh);
 fwrite(ctx_ct_list,sizeof(ctx_obj_ct_t),outfn,tmpfh);
 char (*tmpfname)[PATHLEN] = malloc(outfn * PATHLEN);
 int idx = 0;
  for(int t=0;t<subset->taxn;t++){
  if(subset->tax[t].taxid != 0) {
   if(subset->tax[t].taxname != NULL)
    sprintf(tmpfname[idx],"%d_%s",subset->tax[t].taxid,subset->tax[t].taxname);
   else sprintf(tmpfname[idx],"%d",subset->tax[t].taxid);
   idx++;
  }
  free(subset->tax[t].gids);
    free(subset->tax[t].taxname);
  }
  free(subset->tax);
  free(subset);
 fwrite(tmpfname,PATHLEN,outfn,tmpfh);
 fclose(tmpfh);
 free(tmpfname);
 free(ctx_ct_list);
 free(dict);
 free(outcombcoidx);
 return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x14ac0
movq %rax, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
leaq 0xe585(%rip), %rdi      # 0x23660
addq $0x18, %rdi
leaq 0x760a(%rip), %rsi      # 0x1c6f0
callq 0x8250
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1511d
callq 0x3050
movl (%rax), %edi
leaq 0x727b(%rip), %rsi      # 0x1c37f
leaq 0x75e5(%rip), %rdx      # 0x1c6f0
leaq 0xe54e(%rip), %rcx      # 0x23660
addq $0x18, %rcx
movb $0x0, %al
callq 0x3300
movq -0x18(%rbp), %rdi
leaq 0x6f2f(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x15150
callq 0x3050
movl (%rax), %edi
movq -0x18(%rbp), %rdx
leaq 0x8f13(%rip), %rsi      # 0x1e05c
movb $0x0, %al
callq 0x3300
movq -0x20(%rbp), %rcx
leaq -0x40(%rbp), %rdi
movl $0x20, %esi
movl $0x1, %edx
callq 0x30a0
movq -0x20(%rbp), %rdi
callq 0x30e0
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
je 0x151a4
callq 0x3050
movl (%rax), %edi
movq -0x18(%rbp), %rdx
movl -0x2c(%rbp), %ecx
movq -0x8(%rbp), %r8
movq -0x10(%rbp), %rax
movl 0x4(%rax), %r9d
leaq 0x8ed7(%rip), %rsi      # 0x1e074
movb $0x0, %al
callq 0x3300
movq -0x18(%rbp), %rdi
callq 0x3040
leaq 0xe4ac(%rip), %rdi      # 0x23660
addq $0x318, %rdi            # imm = 0x318
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x3080
movl $0x0, -0x1d4(%rbp)
movq $0x0, -0x1e0(%rbp)
movq -0x10(%rbp), %rax
movslq (%rax), %rdi
movl $0x4, %esi
callq 0x3270
movq %rax, -0x1e8(%rbp)
movq $0x10000000, -0x1f0(%rbp) # imm = 0x10000000
movq -0x1f0(%rbp), %rdi
shrq $0x3, %rdi
callq 0x3310
movq %rax, -0x1f8(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x3310
movq %rax, -0x200(%rbp)
movl $0x0, -0x204(%rbp)
movl -0x204(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x1581f
leaq -0x140(%rbp), %rdi
movl -0x204(%rbp), %r8d
leaq 0x6df0(%rip), %rsi      # 0x1c04e
leaq 0xe3fb(%rip), %rdx      # 0x23660
addq $0x18, %rdx
leaq 0x91e9(%rip), %rcx      # 0x1e459
movb $0x0, %al
callq 0x3400
leaq -0x140(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x32b0
cmpl $0x0, %eax
je 0x152ab
callq 0x3050
movl (%rax), %edi
leaq -0x140(%rbp), %rdx
leaq 0x8db8(%rip), %rsi      # 0x1e05c
movb $0x0, %al
callq 0x3300
movq -0x1a0(%rbp), %rdi
callq 0x3310
movq %rax, -0x210(%rbp)
leaq -0x140(%rbp), %rdi
leaq 0x6d8b(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x152f7
callq 0x3050
movl (%rax), %edi
leaq -0x140(%rbp), %rdx
leaq 0x8d6c(%rip), %rsi      # 0x1e05c
movb $0x0, %al
callq 0x3300
movq -0x210(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
movq -0x20(%rbp), %rcx
movl $0x1, %edx
callq 0x30a0
movq -0x20(%rbp), %rdi
callq 0x30e0
leaq -0x140(%rbp), %rdi
movl -0x204(%rbp), %r8d
leaq 0x6d1d(%rip), %rsi      # 0x1c04e
leaq 0xe328(%rip), %rdx      # 0x23660
addq $0x18, %rdx
leaq 0x911d(%rip), %rcx      # 0x1e460
movb $0x0, %al
callq 0x3400
leaq -0x140(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x32b0
cmpl $0x0, %eax
je 0x1537e
callq 0x3050
movl (%rax), %edi
leaq -0x140(%rbp), %rdx
leaq 0x8ce5(%rip), %rsi      # 0x1e05c
movb $0x0, %al
callq 0x3300
movq -0x1a0(%rbp), %rdi
callq 0x3310
movq %rax, -0x218(%rbp)
leaq -0x140(%rbp), %rdi
leaq 0x6cb8(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x153ca
callq 0x3050
movl (%rax), %edi
leaq -0x140(%rbp), %rdx
leaq 0x8c99(%rip), %rsi      # 0x1e05c
movb $0x0, %al
callq 0x3300
movq -0x218(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
movq -0x20(%rbp), %rcx
movl $0x1, %edx
callq 0x30a0
movq -0x20(%rbp), %rdi
callq 0x30e0
leaq -0x140(%rbp), %rdi
movl -0x204(%rbp), %r8d
leaq 0x6c4a(%rip), %rsi      # 0x1c04e
leaq 0xe255(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0x9040(%rip), %rcx      # 0x1e459
movb $0x0, %al
callq 0x3400
leaq -0x140(%rbp), %rdi
leaq 0x6c2c(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x15459
callq 0x3050
movl (%rax), %edi
leaq -0x140(%rbp), %rdx
leaq 0x8c0a(%rip), %rsi      # 0x1e05c
movb $0x0, %al
callq 0x3300
movl $0x0, -0x1d4(%rbp)
movq $0x0, -0x220(%rbp)
movq -0x200(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x224(%rbp)
movl -0x224(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x15747
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x224(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0x154b8
jmp 0x15733
movq -0x1f8(%rbp), %rdi
movq -0x1f0(%rbp), %rdx
shrq $0x3, %rdx
xorl %esi, %esi
callq 0x31f0
movl $0x1, -0x228(%rbp)
movl -0x228(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x224(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
cmpl (%rcx), %eax
jg 0x155da
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x224(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movslq -0x228(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x22c(%rbp)
movq -0x218(%rbp), %rax
movslq -0x22c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rax
movq -0x218(%rbp), %rcx
movl -0x22c(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
cmpq (%rcx,%rdx,8), %rax
jae 0x155c4
movq -0x210(%rbp), %rax
movq -0x238(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0x3f, %eax
movl %eax, %eax
movl %eax, %ecx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
shrq %cl, %rdx
movq -0x1f8(%rbp), %rax
movq -0x210(%rbp), %rcx
movq -0x238(%rbp), %rsi
movl (%rcx,%rsi,4), %ecx
shrl $0x6, %ecx
movl %ecx, %ecx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x238(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x238(%rbp)
jmp 0x15546
jmp 0x155c6
movl -0x228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
jmp 0x154db
movl $0x0, -0x23c(%rbp)
movl -0x23c(%rbp), %eax
movq -0x1f0(%rbp), %rcx
shrq $0x6, %rcx
cmpq %rcx, %rax
jae 0x156f1
movq -0x1f8(%rbp), %rax
movl -0x23c(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0x156db
movl $0x0, -0x240(%rbp)
cmpl $0x40, -0x240(%rbp)
jge 0x156d9
movl -0x240(%rbp), %eax
movl %eax, %ecx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
shrq %cl, %rax
movq -0x1f8(%rbp), %rcx
movl -0x23c(%rbp), %edx
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x156c3
movl -0x23c(%rbp), %eax
shll $0x6, %eax
addl -0x240(%rbp), %eax
movl %eax, -0x244(%rbp)
movq -0x20(%rbp), %rcx
leaq -0x244(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x3420
movq -0x220(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x220(%rbp)
movq -0x1e0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1e0(%rbp)
movq -0x1e8(%rbp), %rax
movslq -0x1d4(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x156c5
movl -0x240(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x240(%rbp)
jmp 0x15620
jmp 0x156db
jmp 0x156dd
movl -0x23c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x23c(%rbp)
jmp 0x155e4
movl -0x1d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d4(%rbp)
movq -0x220(%rbp), %rdx
movq -0x200(%rbp), %rax
movslq -0x1d4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x224(%rbp), %esi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0x8995(%rip), %rdi      # 0x1e0c1
movb $0x0, %al
callq 0x3150
movl -0x224(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x224(%rbp)
jmp 0x15486
leaq 0x9861(%rip), %rdi      # 0x1efaf
movb $0x0, %al
callq 0x3150
movq -0x20(%rbp), %rdi
callq 0x30e0
leaq -0x140(%rbp), %rdi
movl -0x204(%rbp), %r8d
leaq 0x68db(%rip), %rsi      # 0x1c04e
leaq 0xdee6(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0x8cd8(%rip), %rcx      # 0x1e460
movb $0x0, %al
callq 0x3400
leaq -0x140(%rbp), %rdi
leaq 0x68bd(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x157c9
callq 0x3050
movl (%rax), %edi
leaq -0x140(%rbp), %rdx
leaq 0x889a(%rip), %rsi      # 0x1e05c
movb $0x0, %al
callq 0x3300
movq -0x200(%rbp), %rdi
movl -0x1d4(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
movq -0x20(%rbp), %rcx
movl $0x8, %esi
callq 0x3420
movq -0x20(%rbp), %rdi
callq 0x30e0
movq -0x210(%rbp), %rdi
callq 0x3040
movq -0x218(%rbp), %rdi
callq 0x3040
movl -0x204(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x204(%rbp)
jmp 0x1523a
movl -0x1d4(%rbp), %eax
movl %eax, -0x2c(%rbp)
movb $0x0, -0x3c(%rbp)
movq -0x1e0(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq -0x140(%rbp), %rdi
leaq 0x6ae6(%rip), %rsi      # 0x1c32b
leaq 0xde14(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0x6e96(%rip), %rcx      # 0x1c6f0
movb $0x0, %al
callq 0x3400
leaq -0x140(%rbp), %rdi
leaq 0x67eb(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x1589a
callq 0x3050
movl (%rax), %edi
leaq -0x140(%rbp), %rdx
leaq 0x87c9(%rip), %rsi      # 0x1e05c
movb $0x0, %al
callq 0x3300
movq -0x20(%rbp), %rcx
leaq -0x40(%rbp), %rdi
movl $0x20, %esi
movl $0x1, %edx
callq 0x3420
movq -0x1e8(%rbp), %rdi
movslq -0x1d4(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl $0x4, %esi
callq 0x3420
movl -0x1d4(%rbp), %eax
shll $0x8, %eax
movslq %eax, %rdi
callq 0x3310
movq %rax, -0x250(%rbp)
movl $0x0, -0x254(%rbp)
movl $0x0, -0x258(%rbp)
movl -0x258(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x15a3a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x258(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
je 0x159e8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x258(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x1599e
movq -0x250(%rbp), %rdi
movslq -0x254(%rbp), %rax
shlq $0x8, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x258(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x258(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
leaq 0x874d(%rip), %rsi      # 0x1e0e2
movb $0x0, %al
callq 0x3400
jmp 0x159d9
movq -0x250(%rbp), %rdi
movslq -0x254(%rbp), %rax
shlq $0x8, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x258(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
leaq 0x96a3(%rip), %rsi      # 0x1f075
movb $0x0, %al
callq 0x3400
movl -0x254(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x254(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x258(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x3040
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x258(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x3040
movl -0x258(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x258(%rbp)
jmp 0x158f9
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3040
movq -0x10(%rbp), %rdi
callq 0x3040
movq -0x250(%rbp), %rdi
movslq -0x1d4(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
callq 0x3420
movq -0x20(%rbp), %rdi
callq 0x30e0
movq -0x250(%rbp), %rdi
callq 0x3040
movq -0x1e8(%rbp), %rdi
callq 0x3040
movq -0x1f8(%rbp), %rdi
callq 0x3040
movq -0x200(%rbp), %rdi
callq 0x3040
xorl %eax, %eax
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq