// File: /workspace/github_c_makefile_star2_O1/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 0x4b3de(%rip), %edx     # 0x5e628
shlq $0x3, %rdx
movq %rsi, 0x20(%rsp)
movq %rsi, %rdi
xorl %esi, %esi
callq 0x3210
cmpb $0x0, (%r14)
leaq 0x50bc(%rip), %rdx      # 0x18324
cmovneq %r14, %rdx
leaq 0x4eb1(%rip), %rsi      # 0x18124
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x3430
leaq 0x3b32(%rip), %rsi      # 0x16dbe
movq %r14, %rdi
callq 0x3390
testq %rax, %rax
je 0x13569
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 0x1353a
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 0x13394
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 0x1353a
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
jmp 0x133b0
leaq 0x4735(%rip), %rdx      # 0x17ad0
movslq (%rdx,%rax,4), %rax
cmpq $-0x1, %rax
je 0x133b0
movsbl (%r12,%rcx), %ecx
cmpl 0x2c(%rsp), %ecx
jge 0x133c7
movl $0x1, %r8d
incl %r9d
cmpl %r13d, %r9d
jl 0x13323
jmp 0x1353a
shlq $0x2, %rbp
orq %rax, %rbp
andq 0x4b263(%rip), %rbp     # 0x5e638
movq %rbx, %rdx
shrq $0x2, %rdx
xorq $0x3, %rax
movb 0x4b24e(%rip), %cl      # 0x5e634
shlq %cl, %rax
movq %rax, %rbx
addq %rdx, %rbx
incq %r8
movslq 0x4b247(%rip), %rax     # 0x5e640
cmpq %rax, %r8
jbe 0x133b6
cmpq %rbx, %rbp
movq %rbx, %rdx
cmovbq %rbp, %rdx
movq 0x4b239(%rip), %rsi     # 0x5e648
andq %rdx, %rsi
movl 0x4b207(%rip), %r10d    # 0x5e620
leal (%r10,%r10), %ecx
shrq %cl, %rsi
movq 0x4b231(%rip), %rdi     # 0x5e658
movl %esi, %esi
movslq (%rdi,%rsi,4), %rdi
cmpl 0x4b22d(%rip), %edi     # 0x5e660
jae 0x133b6
movq %rbx, 0x18(%rsp)
movq 0x4b20f(%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 0x4b1b9(%rip), %cl      # 0x5e624
shlb $0x2, %cl
shrq %cl, %rsi
movl 0x4b1b0(%rip), %r10d    # 0x5e628
testq %r10, %r10
je 0x134dd
movq %rbp, 0x10(%rsp)
addq %rdi, %rsi
xorl %r11d, %r11d
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
movl %r10d, %ebx
movl %r11d, %eax
imulq %rdi, %rax
addq %rcx, %rax
xorl %edx, %edx
divq %r10
movq 0x20(%rsp), %rax
movq (%rax,%rdx,8), %rbp
testq %rbp, %rbp
je 0x134e7
movq %rbp, %rax
shrq $0x10, %rax
cmpq %rsi, %rax
je 0x13519
incl %r11d
decl %ebx
jne 0x134a8
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %rbx
jmp 0x133b6
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 0x4b125(%rip), %eax     # 0x5e62c
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %rbx
jbe 0x133b6
jmp 0x13583
cmpw $-0x1, %bp
movq 0x18(%rsp), %rbx
je 0x13530
incq %rbp
movq 0x20(%rsp), %rax
movq %rbp, (%rax,%rdx,8)
movq 0x10(%rsp), %rbp
jmp 0x133b6
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 0x4d82(%rip), %rsi      # 0x182f9
leaq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
movl 0x4b088(%rip), %edx     # 0x5e618
incl %edx
leaq 0x4c75(%rip), %rsi      # 0x1820e
xorl %eax, %eax
callq 0x3330