// File: /workspace/github_c_makefile_star2_O3/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 0x4b1e4(%rip), %edx     # 0x5e628
shlq $0x3, %rdx
movq %rsi, 0x18(%rsp)
movq %rsi, %rdi
xorl %esi, %esi
callq 0x3210
cmpb $0x0, (%r14)
leaq 0x4ef2(%rip), %rdx      # 0x18354
cmovneq %r14, %rdx
leaq 0x4ce7(%rip), %rsi      # 0x18154
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x3430
leaq 0x3988(%rip), %rsi      # 0x16e0e
movq %r14, %rdi
callq 0x3390
testq %rax, %rax
je 0x13752
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 0x13767
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %eax, %eax
movl $0x0, 0xc(%rsp)
movl %eax, %r14d
cmpl %r15d, %eax
jne 0x1350a
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 0x13703
movslq %r14d, %rax
movsbq 0x120(%rsp,%rax), %rbx
leaq 0x45e3(%rip), %rax      # 0x17b00
movslq (%rax,%rbx,4), %rax
cmpq $-0x1, %rax
je 0x1365a
shlq $0x2, %rbp
orq %rax, %rbp
andq 0x4b0ff(%rip), %rbp     # 0x5e638
movq %r12, %rdx
shrq $0x2, %rdx
xorq $0x3, %rax
movb 0x4b0ea(%rip), %cl      # 0x5e634
shlq %cl, %rax
movq %rax, %r12
addq %rdx, %r12
movq 0x10(%rsp), %rcx
incq %rcx
movslq 0x4b0de(%rip), %rax     # 0x5e640
movq %rcx, 0x10(%rsp)
cmpq %rax, %rcx
jbe 0x136f6
cmpq %r12, %rbp
movq %r12, %rdx
cmovbq %rbp, %rdx
movq 0x4b0c7(%rip), %rsi     # 0x5e648
andq %rdx, %rsi
movl 0x4b095(%rip), %r8d     # 0x5e620
leal (%r8,%r8), %ecx
shrq %cl, %rsi
movq 0x4b0bf(%rip), %rdi     # 0x5e658
movslq %esi, %rsi
movslq (%rdi,%rsi,4), %rdi
cmpl 0x4b0ba(%rip), %edi     # 0x5e660
jae 0x136f6
movq 0x4b09d(%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 0x4b047(%rip), %cl      # 0x5e624
shlb $0x2, %cl
shrq %cl, %rsi
movl 0x4b03e(%rip), %r8d     # 0x5e628
testq %r8, %r8
je 0x136f6
addq %rdi, %rsi
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, %r9d
xorl %r10d, %r10d
movq %rdi, %rax
imulq %r10, %rax
addq %rcx, %rax
xorl %edx, %edx
divq %r8
movq 0x18(%rsp), %rax
movq (%rax,%rdx,8), %rax
testq %rax, %rax
je 0x136db
cmpq %rsi, %rax
je 0x136f6
incq %r10
leaq 0x1(%r9), %rax
cmpq %r8, %r9
movq %rax, %r9
jb 0x1361c
jmp 0x136f6
cmpb $0xa, %bl
je 0x136f6
movzbl %bl, %eax
cmpl $0xd, %eax
je 0x136f6
callq 0x34d0
movl $0x1, %ecx
movq %rcx, 0x10(%rsp)
cmpb $0x3e, %bl
jne 0x136f6
movq (%rax), %rax
movzwl (%rax,%rbx,2), %eax
andl $0x400, %eax            # imm = 0x400
jne 0x136f6
cmpl %r15d, %r14d
jge 0x136f6
movslq %r14d, %rax
cmpb $0xa, 0x120(%rsp,%rax)
je 0x136f6
leal -0x1(%r15), %eax
cmpl %eax, %r14d
jge 0x136b1
incl %r14d
jmp 0x13691
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 0x13691
jmp 0x13722
movq 0x18(%rsp), %rax
movq %rsi, (%rax,%rdx,8)
movl 0xc(%rsp), %eax
incl %eax
movl %eax, 0xc(%rsp)
cmpl 0x4af38(%rip), %eax     # 0x5e62c
ja 0x1373a
leal 0x1(%r14), %eax
cmpl %r15d, %r14d
jl 0x134d9
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 0x4a7d(%rip), %rsi      # 0x181ad
movl %r15d, %edx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
movl 0x4aed1(%rip), %edx     # 0x5e618
incl %edx
leaq 0x4aee(%rip), %rsi      # 0x1823e
jmp 0x13733
callq 0x3060
movl (%rax), %edi
leaq 0x4aac(%rip), %rsi      # 0x1820c
leaq 0x20(%rsp), %rdx
jmp 0x13778
callq 0x3060
movl (%rax), %edi
leaq 0x4aa5(%rip), %rsi      # 0x1821a
movq %r12, %rdx
xorl %eax, %eax
callq 0x3330