// File: /workspace/github_c_makefile_star2_O3/yhg926[P]public_kssd/iseq2comem.c
// Function: fastq2koc
llong * fastq2koc (char* seqfname, llong *co, char *pipecmd, int Q)
{
  llong tuple = 0LLU, crvstuple = 0LLU, unituple, drtuple, pfilter;
  memset(co,0LLU,hashsize*sizeof(llong));
  FILE *infp;
  char fq_fname[PATHLEN];
 if(pipecmd[0] != '\0')
    sprintf(fq_fname,"%s %s",pipecmd,seqfname);
  else
    sprintf(fq_fname,"%s %s",gzpipe_cmd,seqfname);
  if( (infp=popen(fq_fname,"r")) == NULL ) err(errno,"fastq2koc():%s",fq_fname);
 char *seq = malloc(LEN+10);
  char *qual = malloc(LEN+10);
  fgets(seq,LEN,infp); fgets(seq,LEN,infp);
  fgets(qual,LEN,infp); fgets(qual,LEN,infp);
  llong base = 1; char ch ; int basenum,line_num = 0 ;
  unsigned int keycount =0 ;
 int sl = strlen(seq);
  for(int pos = 0; pos < sl; pos++){
    if(seq[pos] == '\n' ){
      fgets(seq,LEN,infp); fgets(seq,LEN,infp);
      fgets(qual,LEN,infp); fgets(qual,LEN,infp);
   sl = strlen(seq);
      line_num+=4;
      if( !feof(infp) ) {
        base = 1;
        pos = -1;
        continue ;
      }
      else break;
    }
    else{
      ch = seq[pos];
      basenum = Basemap[(int)ch];
      if( (basenum != DEFAULT) && ( qual[pos] >= Q ) ){
        tuple = ( ( tuple<< 2 ) | (llong)basenum ) & tupmask ;
        crvstuple = ( crvstuple >> 2 ) + (((llong)basenum^3LLU) << crvsaddmove);
        base++;
      }
      else {
        base = 1;
        continue;
      };
    };
    if( base > TL ){
      unituple = tuple < crvstuple ? tuple:crvstuple;
      unsigned 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] == 0LLU){
          co[n] = (drtuple << OCCRC_BIT) + 1LLU ;
          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] >> OCCRC_BIT ) == drtuple ) {
            if( (co[n] & OCCRC_MAX) < OCCRC_MAX )
              co[n]+=1LLU;
          break ;
        };
      };
    };
  }
  pclose(infp);
 free(seq);
 free(qual);
  return co;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movl %ecx, 0x2c(%rsp)
movq %rdx, %r14
movq %rdi, %r15
movl 0x4aaac(%rip), %edx     # 0x5e628
shlq $0x3, %rdx
movq %rsi, 0x20(%rsp)
movq %rsi, %rdi
xorl %esi, %esi
callq 0x3210
cmpb $0x0, (%r14)
leaq 0x47ba(%rip), %rdx      # 0x18354
cmovneq %r14, %rdx
leaq 0x45af(%rip), %rsi      # 0x18154
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x3430
leaq 0x3250(%rip), %rsi      # 0x16e0e
movq %r14, %rdi
callq 0x3390
testq %rax, %rax
je 0x13e9b
movq %rax, %r14
movl $0x4e2a, %edi           # imm = 0x4E2A
callq 0x3340
movq %rax, %r15
movl $0x4e2a, %edi           # imm = 0x4E2A
callq 0x3340
movq %rax, %r12
movq %r15, %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movq %r14, %rdx
callq 0x3290
movq %r15, %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movq %r14, %rdx
callq 0x3290
movq %r12, %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movq %r14, %rdx
callq 0x3290
movq %r12, %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movq %r14, %rdx
callq 0x3290
movq %r15, %rdi
callq 0x3130
movq %rax, %r13
testl %r13d, %r13d
jle 0x13e6c
movl $0x1, %r8d
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %r9d, %r9d
movl $0x0, 0xc(%rsp)
movslq %r9d, %rcx
movsbq (%r15,%rcx), %rax
cmpq $0xa, %rax
jne 0x13cc6
movq %r15, %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movq %r14, %rdx
callq 0x3290
movq %r15, %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movq %r14, %rdx
callq 0x3290
movq %r12, %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movq %r14, %rdx
callq 0x3290
movq %r12, %rdi
movl $0x4e20, %esi           # imm = 0x4E20
movq %r14, %rdx
callq 0x3290
movq %r15, %rdi
callq 0x3130
movq %rax, %r13
movq %r14, %rdi
callq 0x32d0
testl %eax, %eax
jne 0x13e6c
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
jmp 0x13ce2
leaq 0x3e33(%rip), %rdx      # 0x17b00
movslq (%rdx,%rax,4), %rax
cmpq $-0x1, %rax
je 0x13ce2
movsbl (%r12,%rcx), %ecx
cmpl 0x2c(%rsp), %ecx
jge 0x13cf9
movl $0x1, %r8d
incl %r9d
cmpl %r13d, %r9d
jl 0x13c55
jmp 0x13e6c
shlq $0x2, %rbp
orq %rax, %rbp
andq 0x4a931(%rip), %rbp     # 0x5e638
movq %rbx, %rdx
shrq $0x2, %rdx
xorq $0x3, %rax
movb 0x4a91c(%rip), %cl      # 0x5e634
shlq %cl, %rax
movq %rax, %rbx
addq %rdx, %rbx
incq %r8
movslq 0x4a915(%rip), %rax     # 0x5e640
cmpq %rax, %r8
jbe 0x13ce8
cmpq %rbx, %rbp
movq %rbx, %rdx
cmovbq %rbp, %rdx
movq 0x4a907(%rip), %rsi     # 0x5e648
andq %rdx, %rsi
movl 0x4a8d5(%rip), %r10d    # 0x5e620
leal (%r10,%r10), %ecx
shrq %cl, %rsi
movq 0x4a8ff(%rip), %rdi     # 0x5e658
movl %esi, %esi
movslq (%rdi,%rsi,4), %rdi
cmpl 0x4a8fb(%rip), %edi     # 0x5e660
jae 0x13ce8
movq %rbx, 0x18(%rsp)
movq 0x4a8dd(%rip), %r11     # 0x5e650
movq $-0x1, %rsi
shlq %cl, %rsi
notq %rsi
andq %rdx, %rsi
addl %eax, %eax
shll $0x2, %r10d
subl %r10d, %eax
movl %eax, %ecx
shlq %cl, %rsi
andq %rdx, %r11
addq %r11, %rsi
movb 0x4a887(%rip), %cl      # 0x5e624
shlb $0x2, %cl
shrq %cl, %rsi
movl 0x4a87e(%rip), %r10d    # 0x5e628
testq %r10, %r10
je 0x13e0f
movq %rbp, 0x10(%rsp)
addq %rdi, %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %r10
movq %rdx, %rcx
leal -0x1(%r10), %edi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, %rdi
incq %rdi
movq %r10, %r11
xorl %ebx, %ebx
movq %rdi, %rax
imulq %rbx, %rax
addq %rcx, %rax
xorl %edx, %edx
divq %r10
movq 0x20(%rsp), %rax
movq (%rax,%rdx,8), %rbp
testq %rbp, %rbp
je 0x13e19
movq %rbp, %rax
shrq $0x10, %rax
cmpq %rsi, %rax
je 0x13e4b
incq %rbx
decq %r11
jne 0x13dd9
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %rbx
jmp 0x13ce8
shlq $0x10, %rsi
incq %rsi
movq 0x20(%rsp), %rax
movq %rsi, (%rax,%rdx,8)
movl 0xc(%rsp), %eax
incl %eax
movl %eax, 0xc(%rsp)
cmpl 0x4a7f3(%rip), %eax     # 0x5e62c
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %rbx
jbe 0x13ce8
jmp 0x13eb5
cmpw $-0x1, %bp
movq 0x18(%rsp), %rbx
je 0x13e62
incq %rbp
movq 0x20(%rsp), %rax
movq %rbp, (%rax,%rdx,8)
movq 0x10(%rsp), %rbp
jmp 0x13ce8
movq %r14, %rdi
callq 0x31a0
movq %r15, %rdi
callq 0x3040
movq %r12, %rdi
callq 0x3040
movq 0x20(%rsp), %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 0x4480(%rip), %rsi      # 0x18329
leaq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
movl 0x4a756(%rip), %edx     # 0x5e618
incl %edx
leaq 0x4373(%rip), %rsi      # 0x1823e
xorl %eax, %eax
callq 0x3330