// File: /workspace/github_c_makefile_star2_O3/yhg926[P]public_kssd/command_set.c
// Function: organize_taxf
compan_t *organize_taxf(char* taxfile){
 FILE *tf = fopen(taxfile,"r");
 if(tf == NULL) err(errno,"%s",taxfile);
 int ln = 0;
 for (char c = getc(tf); c != EOF; c = getc(tf))
  if (c == '\n') ln++;
 rewind(tf);
#define D_TAXID (-1)
 int hashsz = nextPrime( (int)((double) ln / LD_FCTR) );
 subset_t *tmphs = malloc(hashsz * sizeof(subset_t));
 for(int i = 0 ; i < hashsz ; i++) {
  tmphs[i].taxid = D_TAXID;
  tmphs[i].taxname = NULL;
 }
 char tmpstr[PATHLEN+1];
 const char s[2] = "\t";
 int tax_count = 0 ;
 for(int i= 0; i< ln ; i++) {
  fgets(tmpstr,PATHLEN,tf);
  if( tmpstr[strlen(tmpstr)-1] != '\n')
   err(errno,"organize_taxf(): %dth line %s is not full read, exceed PATHLEN %d ",i,tmpstr,PATHLEN);
  else tmpstr[strlen(tmpstr)-1] = '\0' ;
  int taxid = atoi(strtok(tmpstr,s)) ;
  char *taxname = strtok(NULL,s);
  for(int n = 0; n<hashsz ;n++){
   int hv = HASH(taxid,n,hashsz);
   if(tmphs[hv].taxid == D_TAXID) {
    tmphs[hv].taxid = taxid;
    tax_count++;
    if(taxname != NULL){
     tmphs[hv].taxname = malloc(strlen(taxname)+1);
     strcpy(tmphs[hv].taxname,taxname);
    }
    tmphs[hv].gids = malloc(2*sizeof(int));
    tmphs[hv].gids[0] = 1;
    tmphs[hv].gids[1] = i;
    break;
   }
   else if(tmphs[hv].taxid == taxid){
    if( (tmphs[hv].taxname == NULL && taxname != NULL )
     ||(tmphs[hv].taxname != NULL && taxname == NULL)
     || (taxname != NULL && strcmp(tmphs[hv].taxname,taxname) != 0)
     ) err(errno,"organize_taxf() abort!: taxid %d has different taxnames in %dth and %dth lines",taxid,tmphs[hv].gids[1],i);
     tmphs[hv].gids[0]++;
     tmphs[hv].gids = realloc(tmphs[hv].gids,(tmphs[hv].gids[0]+1) * sizeof(int));
     tmphs[hv].gids[tmphs[hv].gids[0]] = i;
     break;
   }
  }
 }
 fclose(tf);
 compan_t * subset = malloc(sizeof(compan_t));
 subset->taxn = tax_count;
 subset->gn = ln;
 subset->tax = malloc(tax_count * sizeof(subset_t)) ;
 int it = 0;
 for(int n = 0; n <hashsz; n++){
  if(tmphs[n].taxid != D_TAXID){
   subset->tax[it] = tmphs[n];
   it++;
  }
 }
 free(tmphs);
 return subset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, %rbx
leaq 0x6b47(%rip), %rsi      # 0x16e0e
callq 0x33a0
testq %rax, %rax
je 0x105df
movq %rax, %r14
movl $0x0, 0xc(%rsp)
movq %r14, %rdi
callq 0x34b0
cmpb $0xa, %al
je 0x102f8
movzbl %al, %eax
cmpl $0xff, %eax
jne 0x102e0
jmp 0x102fe
incl 0xc(%rsp)
jmp 0x102e0
movq %r14, %rdi
callq 0x3190
cvtsi2sdl 0xc(%rsp), %xmm0
divsd 0x4f2c(%rip), %xmm0     # 0x15240
cvttsd2si %xmm0, %edi
callq 0x12a04
movl %eax, %r15d
cltq
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdi
callq 0x3340
movq %rax, %rbx
movl %r15d, %edx
testl %r15d, %r15d
jle 0x10361
leaq (,%rdx,8), %rax
leaq (%rax,%rax,2), %rax
xorl %ecx, %ecx
movl $0xffffffff, (%rbx,%rcx) # imm = 0xFFFFFFFF
movq $0x0, 0x8(%rbx,%rcx)
addq $0x18, %rcx
cmpq %rcx, %rax
jne 0x10348
cmpl $0x0, 0xc(%rsp)
movq %rdx, 0x28(%rsp)
je 0x104f8
leal -0x1(%r15), %eax
movl %eax, 0x1c(%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x30(%rsp), %r12
xorl %ebp, %ebp
movq %r14, 0x20(%rsp)
movq %r12, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x3290
movq %r12, %rdi
callq 0x3130
cmpb $0xa, -0x1(%rax,%r12)
jne 0x1059b
movb $0x0, 0x2f(%rsp,%rax)
movq %r12, %rdi
leaq 0x502f(%rip), %r12      # 0x153f0
movq %r12, %rsi
callq 0x33c0
movq %rax, %rdi
callq 0x3410
movl %eax, %r13d
xorl %edi, %edi
movq %r12, %rsi
callq 0x33c0
testl %r15d, %r15d
jle 0x104e5
movq %rax, %r12
movl %r13d, %eax
cltd
idivl %r15d
movl %edx, %ecx
movl %r13d, %eax
cltd
idivl 0x1c(%rsp)
movl %edx, %esi
incl %esi
movl %r15d, %edi
movl %ecx, %eax
cltd
idivl %r15d
movslq %edx, %rax
leaq (%rax,%rax,2), %rax
leaq (%rbx,%rax,8), %r14
movl (%rbx,%rax,8), %eax
cmpl $-0x1, %eax
je 0x1042b
cmpl %r13d, %eax
je 0x10479
addl %esi, %ecx
decl %edi
jne 0x10402
jmp 0x104e0
movl %r13d, (%r14)
testq %r12, %r12
je 0x10453
movq %r12, %rdi
callq 0x3130
leaq 0x1(%rax), %rdi
callq 0x3340
movq %rax, 0x8(%r14)
movq %rax, %rdi
movq %r12, %rsi
callq 0x3080
movq 0x10(%rsp), %rax
incl %eax
movq %rax, 0x10(%rsp)
movl $0x8, %edi
callq 0x3340
movq %rax, 0x10(%r14)
movl $0x1, (%rax)
addq $0x4, %rax
jmp 0x104de
movq 0x8(%r14), %rdi
testq %rdi, %rdi
sete %al
testq %r12, %r12
setne %cl
testb %cl, %al
jne 0x105bd
testq %rdi, %rdi
setne %al
testq %r12, %r12
sete %cl
testb %cl, %al
jne 0x105bd
testq %r12, %r12
je 0x104ba
movq %r12, %rsi
callq 0x32b0
testl %eax, %eax
jne 0x105bd
movq 0x10(%r14), %rdi
movslq (%rdi), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%rdi)
leaq 0x8(,%rax,4), %rsi
callq 0x3350
movq %rax, 0x10(%r14)
movslq (%rax), %rcx
leaq (%rax,%rcx,4), %rax
movl %ebp, (%rax)
movq 0x20(%rsp), %r14
leaq 0x30(%rsp), %r12
incl %ebp
cmpl 0xc(%rsp), %ebp
jne 0x1038e
jmp 0x10501
movq $0x0, 0x10(%rsp)
movq %r14, %rdi
callq 0x3100
movl $0x10, %edi
callq 0x3340
movq %rax, %r14
movq 0x10(%rsp), %rcx
movl %ecx, (%rax)
movl 0xc(%rsp), %eax
movl %eax, 0x4(%r14)
movslq %ecx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdi
callq 0x3340
movq %rax, 0x8(%r14)
testl %r15d, %r15d
jle 0x1057e
movq 0x28(%rsp), %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
xorl %esi, %esi
cmpl $-0x1, (%rbx,%rdx)
je 0x10575
leaq (%rbx,%rdx), %rdi
movslq %esi, %rsi
leaq (%rsi,%rsi,2), %r8
movq 0x10(%rdi), %r9
movq %r9, 0x10(%rax,%r8,8)
movupd (%rdi), %xmm0
movupd %xmm0, (%rax,%r8,8)
incl %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0x1054f
movq %rbx, %rdi
callq 0x3040
movq %r14, %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3060
movl (%rax), %edi
leaq 0x6ba0(%rip), %rsi      # 0x17149
leaq 0x30(%rsp), %rcx
movl %ebp, %edx
movl $0x100, %r8d            # imm = 0x100
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
movq 0x10(%r14), %rax
movl 0x4(%rax), %ecx
leaq 0x6bba(%rip), %rsi      # 0x1718c
movl %r13d, %edx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0x5dd9(%rip), %rsi      # 0x163c6
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3330