// File: /workspace/github_c_makefile_star2_O1/yhg926[P]public_kssd/iseq2comem.c
// Function: fasta2co
llong * fasta2co(char* seqfname, llong *co, char * pipecmd)
{
 llong tuple = 0LLU, crvstuple = 0LLU,
    unituple, drtuple, pfilter;
 memset(co,0LLU,hashsize*sizeof(llong));
 char seqin_buff[ READSEQ_BUFFSZ + 1 ];
 FILE *infp;
 char fas_fname[PATHLEN];
 if(pipecmd[0] != '\0')
  sprintf(fas_fname,"%s %s",pipecmd,seqfname);
 else
  sprintf(fas_fname,"%s %s",gzpipe_cmd,seqfname);
 if( (infp=popen(fas_fname,"r")) == NULL ) err(errno,"fasta2co():%s",fas_fname);
 int newLen = fread(seqin_buff, sizeof(char),READSEQ_BUFFSZ,infp);
 if(! (newLen >0) ) err(errno,"fastco():eof or fread error file=%s",seqfname);
 llong base = 1; char ch; int basenum;
 unsigned int keycount = 0;
 for(int pos = 0; pos <= newLen; pos++)
 {
  if(pos == newLen){
    newLen = fread(seqin_buff, sizeof(char),READSEQ_BUFFSZ,infp);
   if(newLen > 0)
    pos = 0;
   else break;
  };
  ch = seqin_buff[pos];
  basenum = Basemap[(int)ch];
  if(basenum != DEFAULT)
  {
   tuple = ( ( tuple<< 2 ) | (llong)basenum ) & tupmask ;
   crvstuple = ( crvstuple >> 2 ) + (((llong)basenum^3LLU) << crvsaddmove);
   base++;
  }
  else if ( (ch == '\n') || (ch == '\r') ) { continue;}
  else if (isalpha(ch)){ base=1; continue; }
  else if ( ch == '>' )
  {
   while( (pos < newLen ) && ( seqin_buff[pos] != '\n' ) )
   {
    if (pos < newLen - 1)
     pos++;
    else
    {
     newLen = fread(seqin_buff, sizeof(char),READSEQ_BUFFSZ,infp);
     if(newLen > 0) pos = -1;
     else err(errno,"fasta2co(): can not find seqences head start from '>' %d",newLen);
    };
   };
      base = 1;
      continue;
  }
  else {
      base=1;
      continue;
    };
  if( base > TL )
  {
   unituple = tuple < crvstuple ? tuple:crvstuple;
   int dim_tup = ((unituple & domask) >> ( (half_outctx_len)*2 ) ) ;
   pfilter = dim_shuf_arr[dim_tup];
   if( ( pfilter >= dim_end) || (pfilter < dim_start ) ) continue;
   pfilter = pfilter - dim_start;
   drtuple = ( ( (unituple & undomask)
       + ( ( unituple & ( ( 1LLU<< ( half_outctx_len*2) ) - 1)) << (TL*2 - half_outctx_len*4) ) )
             >> ( drlevel*4 ) )
             + pfilter ;
   unsigned int i,n ;
     for(i=0;i<hashsize;i++)
     {
       n = HASH(drtuple,i,hashsize);
       if (co[n] == 0)
       {
         co[n] = drtuple;
         keycount++;
         if( keycount > hashlimit)
           err(errno,"the context space is too crowd, try rerun the program using -k%d", half_ctx_len + 1);
         break;
       }
       else if ( co[n] == drtuple )
          break;
   };
  };
 };
  pclose(infp);
  return co;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10128, %rsp          # imm = 0x10128
movq %rdx, %r14
movq %rdi, %r12
movl 0x4bb16(%rip), %edx     # 0x5e628
shlq $0x3, %rdx
movq %rsi, 0x18(%rsp)
movq %rsi, %rdi
xorl %esi, %esi
callq 0x3210
cmpb $0x0, (%r14)
leaq 0x57f4(%rip), %rdx      # 0x18324
cmovneq %r14, %rdx
leaq 0x55e9(%rip), %rsi      # 0x18124
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x3430
leaq 0x426a(%rip), %rsi      # 0x16dbe
movq %r14, %rdi
callq 0x3390
testq %rax, %rax
je 0x12e20
movq %rax, %r13
leaq 0x120(%rsp), %rdi
movl $0x1, %eax
movq %rax, 0x10(%rsp)
movl $0x1, %esi
movl $0x10000, %edx          # imm = 0x10000
movq %r13, %rcx
callq 0x30c0
movq %rax, %r15
testl %r15d, %r15d
jle 0x12e35
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %eax, %eax
movl $0x0, 0xc(%rsp)
movl %eax, %r14d
cmpl %r15d, %eax
jne 0x12bd8
movl $0x1, %esi
movl $0x10000, %edx          # imm = 0x10000
leaq 0x120(%rsp), %rdi
movq %r13, %rcx
callq 0x30c0
movq %rax, %r15
xorl %r14d, %r14d
testl %r15d, %r15d
jle 0x12dd1
movslq %r14d, %rax
movsbq 0x120(%rsp,%rax), %rbx
leaq 0x4ee5(%rip), %rax      # 0x17ad0
movslq (%rax,%rbx,4), %rax
cmpq $-0x1, %rax
je 0x12d28
shlq $0x2, %rbp
orq %rax, %rbp
andq 0x4ba31(%rip), %rbp     # 0x5e638
movq %r12, %rdx
shrq $0x2, %rdx
xorq $0x3, %rax
movb 0x4ba1c(%rip), %cl      # 0x5e634
shlq %cl, %rax
movq %rax, %r12
addq %rdx, %r12
movq 0x10(%rsp), %rcx
incq %rcx
movslq 0x4ba10(%rip), %rax     # 0x5e640
movq %rcx, 0x10(%rsp)
cmpq %rax, %rcx
jbe 0x12dc4
cmpq %r12, %rbp
movq %r12, %rdx
cmovbq %rbp, %rdx
movq 0x4b9f9(%rip), %rsi     # 0x5e648
andq %rdx, %rsi
movl 0x4b9c7(%rip), %r8d     # 0x5e620
leal (%r8,%r8), %ecx
shrq %cl, %rsi
movq 0x4b9f1(%rip), %rdi     # 0x5e658
movslq %esi, %rsi
movslq (%rdi,%rsi,4), %rdi
cmpl 0x4b9ec(%rip), %edi     # 0x5e660
jae 0x12dc4
movq 0x4b9cf(%rip), %r9      # 0x5e650
movq $-0x1, %rsi
shlq %cl, %rsi
notq %rsi
andq %rdx, %rsi
addl %eax, %eax
shll $0x2, %r8d
subl %r8d, %eax
movl %eax, %ecx
shlq %cl, %rsi
andq %rdx, %r9
addq %r9, %rsi
movb 0x4b979(%rip), %cl      # 0x5e624
shlb $0x2, %cl
shrq %cl, %rsi
movl 0x4b970(%rip), %r8d     # 0x5e628
testq %r8, %r8
je 0x12dc4
addq %rdi, %rsi
xorl %r9d, %r9d
movq %rsi, %rax
xorl %edx, %edx
divq %r8
movq %rdx, %rcx
leal -0x1(%r8), %edi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, %rdi
incq %rdi
movl $0x1, %r10d
movl %r9d, %eax
imulq %rdi, %rax
addq %rcx, %rax
xorl %edx, %edx
divq %r8
movq 0x18(%rsp), %rax
movq (%rax,%rdx,8), %rax
testq %rax, %rax
je 0x12da9
cmpq %rsi, %rax
je 0x12dc4
incl %r9d
leal 0x1(%r10), %eax
cmpl %r8d, %r10d
movl %eax, %r10d
jb 0x12cea
jmp 0x12dc4
cmpb $0xa, %bl
je 0x12dc4
movzbl %bl, %eax
cmpl $0xd, %eax
je 0x12dc4
callq 0x34d0
movl $0x1, %ecx
movq %rcx, 0x10(%rsp)
cmpb $0x3e, %bl
jne 0x12dc4
movq (%rax), %rax
movzwl (%rax,%rbx,2), %eax
andl $0x400, %eax            # imm = 0x400
jne 0x12dc4
cmpl %r15d, %r14d
jge 0x12dc4
movslq %r14d, %rax
cmpb $0xa, 0x120(%rsp,%rax)
je 0x12dc4
leal -0x1(%r15), %eax
cmpl %eax, %r14d
jge 0x12d7f
incl %r14d
jmp 0x12d5f
movl $0x1, %esi
movl $0x10000, %edx          # imm = 0x10000
leaq 0x120(%rsp), %rdi
movq %r13, %rcx
callq 0x30c0
movq %rax, %r15
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %r15d, %r15d
jg 0x12d5f
jmp 0x12df0
movq 0x18(%rsp), %rax
movq %rsi, (%rax,%rdx,8)
movl 0xc(%rsp), %eax
incl %eax
movl %eax, 0xc(%rsp)
cmpl 0x4b86a(%rip), %eax     # 0x5e62c
ja 0x12e08
leal 0x1(%r14), %eax
cmpl %r15d, %r14d
jl 0x12ba7
movq %r13, %rdi
callq 0x31a0
movq 0x18(%rsp), %rax
addq $0x10128, %rsp          # imm = 0x10128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3060
movl (%rax), %edi
leaq 0x537f(%rip), %rsi      # 0x1817d
movl %r15d, %edx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
movl 0x4b803(%rip), %edx     # 0x5e618
incl %edx
leaq 0x53f0(%rip), %rsi      # 0x1820e
jmp 0x12e01
callq 0x3060
movl (%rax), %edi
leaq 0x53ae(%rip), %rsi      # 0x181dc
leaq 0x20(%rsp), %rdx
jmp 0x12e46
callq 0x3060
movl (%rax), %edi
leaq 0x53a7(%rip), %rsi      # 0x181ea
movq %r12, %rdx
xorl %eax, %eax
callq 0x3330