// File: /workspace/github_c_makefile_star2_O2/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 0x68fd(%rip), %rsi      # 0x15dbe
callq 0x33a0
testq %rax, %rax
je 0xf7c7
movq %rax, %r14
movl $0x0, 0xc(%rsp)
movq %r14, %rdi
callq 0x34b0
cmpb $0xa, %al
je 0xf4f2
movzbl %al, %eax
cmpl $0xff, %eax
jne 0xf4da
jmp 0xf4f8
incl 0xc(%rsp)
jmp 0xf4da
movq %r14, %rdi
callq 0x3190
cvtsi2sdl 0xc(%rsp), %xmm0
divsd 0x4ce2(%rip), %xmm0     # 0x141f0
cvttsd2si %xmm0, %edi
callq 0x11439
movl %eax, %ebp
movslq %eax, %rbx
imulq $0x18, %rbx, %rdi
callq 0x3340
movq %rbx, %rsi
movq %rax, %rbx
xorl %eax, %eax
testl %esi, %esi
cmovlel %eax, %esi
imulq $0x18, %rsi, %rcx
cmpq %rax, %rcx
je 0xf54b
orl $-0x1, (%rbx,%rax)
andq $0x0, 0x8(%rbx,%rax)
addq $0x18, %rax
jmp 0xf536
movq %rcx, 0x20(%rsp)
movl %ebp, %r15d
decl %r15d
xorl %r12d, %r12d
leaq 0x30(%rsp), %r13
movl $0x0, 0x14(%rsp)
movq %r14, 0x18(%rsp)
movq %rsi, 0x28(%rsp)
cmpl 0xc(%rsp), %r12d
je 0xf6fa
movl %r12d, 0x10(%rsp)
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x3290
movq %r13, %rdi
callq 0x3130
cmpb $0xa, -0x1(%rax,%r13)
jne 0xf781
movb $0x0, 0x2f(%rsp,%rax)
movq %r13, %rdi
leaq 0x4ded(%rip), %r14      # 0x143a0
movq %r14, %rsi
callq 0x33c0
movq %rax, %rdi
callq 0x3410
movl %eax, %r13d
xorl %r12d, %r12d
xorl %edi, %edi
movq %r14, %rsi
callq 0x33c0
movq %rax, %r8
movq 0x28(%rsp), %rsi
cmpl %r12d, %esi
je 0xf68a
movl %r13d, %eax
cltd
idivl %ebp
movl %edx, %ecx
movl %r13d, %eax
cltd
idivl %r15d
leal 0x1(%rdx), %eax
imull %r12d, %eax
addl %ecx, %eax
cltd
idivl %ebp
movslq %edx, %rax
imulq $0x18, %rax, %rax
leaq (%rbx,%rax), %r14
movl (%rbx,%rax), %eax
cmpl $-0x1, %eax
je 0xf69b
incl %r12d
cmpl %r13d, %eax
jne 0xf5db
movq 0x8(%r14), %rdi
testq %rdi, %rdi
sete %al
testq %r8, %r8
setne %cl
testb %cl, %al
movl 0x10(%rsp), %r12d
jne 0xf7a5
testq %rdi, %rdi
setne %al
testq %r8, %r8
sete %cl
testb %cl, %al
jne 0xf7a5
testq %r8, %r8
je 0xf664
movq %r8, %rsi
callq 0x32b0
testl %eax, %eax
jne 0xf7a5
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
jmp 0xf6e5
movq 0x18(%rsp), %r14
movl 0x10(%rsp), %r12d
leaq 0x30(%rsp), %r13
jmp 0xf6f2
movl %r13d, (%r14)
testq %r8, %r8
movl 0x10(%rsp), %r12d
je 0xf6cb
movq %r8, %rdi
movq %r8, %r13
callq 0x3130
leaq 0x1(%rax), %rdi
callq 0x3340
movq %rax, 0x8(%r14)
movq %rax, %rdi
movq %r13, %rsi
callq 0x3080
incl 0x14(%rsp)
pushq $0x8
popq %rdi
callq 0x3340
movq %rax, 0x10(%r14)
movl $0x1, (%rax)
addq $0x4, %rax
movq 0x18(%rsp), %r14
leaq 0x30(%rsp), %r13
movl %r12d, (%rax)
incl %r12d
jmp 0xf570
movq %r14, %rdi
callq 0x3100
pushq $0x10
popq %rdi
callq 0x3340
movq %rax, %r14
movl 0x14(%rsp), %ecx
movl %ecx, (%rax)
movl 0xc(%rsp), %eax
movl %eax, 0x4(%r14)
movslq %ecx, %rax
imulq $0x18, %rax, %rdi
callq 0x3340
movq %rax, 0x8(%r14)
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x20(%rsp), %r9
cmpq %rcx, %r9
je 0xf764
cmpl $-0x1, (%rbx,%rcx)
je 0xf75e
leaq (%rbx,%rcx), %rsi
movslq %edx, %rdx
imulq $0x18, %rdx, %rdi
movq 0x10(%rsi), %r8
movq %r8, 0x10(%rax,%rdi)
movupd (%rsi), %xmm0
movupd %xmm0, (%rax,%rdi)
incl %edx
addq $0x18, %rcx
jmp 0xf734
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 0x696a(%rip), %rsi      # 0x160f9
leaq 0x30(%rsp), %rcx
movl 0x10(%rsp), %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 0x6982(%rip), %rsi      # 0x1613c
movl %r13d, %edx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0x5ba1(%rip), %rsi      # 0x15376
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3330