// File: /workspace/github_c_makefile_star2_O2/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 $0x128, %rsp            # imm = 0x128
movl %ecx, 0x14(%rsp)
movq %rdx, %r14
movq %rdi, %r15
movl 0x4b19f(%rip), %edx     # 0x5d628
shlq $0x3, %rdx
movq $0x0, 0x18(%rsp)
movq %rsi, 0x8(%rsp)
movq %rsi, %rdi
xorl %esi, %esi
callq 0x3210
cmpb $0x0, (%r14)
leaq 0x4e54(%rip), %rdx      # 0x17304
cmovneq %r14, %rdx
leaq 0x4c49(%rip), %rsi      # 0x17104
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x3430
leaq 0x38ea(%rip), %rsi      # 0x15dbe
movq %r14, %rdi
callq 0x3390
testq %rax, %rax
je 0x1278a
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
pushq $0x1
popq %rdi
xorl %r8d, %r8d
xorl %ebp, %ebp
xorl %ebx, %ebx
cmpl %r13d, %r8d
jge 0x1275b
movslq %r8d, %rcx
movsbq (%r15,%rcx), %rax
cmpq $0xa, %rax
jne 0x125d2
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 0x1275b
pushq $0x1
popq %rdi
pushq $-0x1
popq %r8
jmp 0x125f1
leaq 0x44d7(%rip), %rdx      # 0x16ab0
movslq (%rdx,%rax,4), %rax
cmpq $-0x1, %rax
je 0x125ee
movsbl (%r12,%rcx), %ecx
cmpl 0x14(%rsp), %ecx
jge 0x125f9
pushq $0x1
popq %rdi
incl %r8d
jmp 0x12557
shlq $0x2, %rbx
orq %rax, %rbx
andq 0x4b031(%rip), %rbx     # 0x5d638
movq %rbp, %rdx
shrq $0x2, %rdx
xorq $0x3, %rax
movb 0x4b01c(%rip), %cl      # 0x5d634
shlq %cl, %rax
movq %rax, %rbp
addq %rdx, %rbp
incq %rdi
movslq 0x4b015(%rip), %rax     # 0x5d640
cmpq %rax, %rdi
jbe 0x125f1
cmpq %rbp, %rbx
movq %rbp, %r10
cmovbq %rbx, %r10
movq 0x4b007(%rip), %rdx     # 0x5d648
andq %r10, %rdx
movl 0x4afd5(%rip), %r9d     # 0x5d620
leal (%r9,%r9), %ecx
shrq %cl, %rdx
movq 0x4afff(%rip), %rsi     # 0x5d658
movl %edx, %edx
movslq (%rsi,%rdx,4), %rdx
cmpl 0x4affb(%rip), %edx     # 0x5d660
jae 0x125f1
movq %rbp, (%rsp)
movq 0x4afde(%rip), %r11     # 0x5d650
andq %r10, %r11
pushq $-0x1
popq %rsi
shlq %cl, %rsi
notq %rsi
andq %r10, %rsi
addl %eax, %eax
shll $0x2, %r9d
subl %r9d, %eax
movl %eax, %ecx
shlq %cl, %rsi
addq %r11, %rsi
movb 0x4af8c(%rip), %cl      # 0x5d624
shlb $0x2, %cl
shrq %cl, %rsi
addq %rdx, %rsi
movl 0x4af80(%rip), %r9d     # 0x5d628
leal -0x1(%r9), %r10d
leaq 0x1(%r9), %r11
xorl %ebp, %ebp
decq %r11
je 0x12709
movq %rsi, %rax
xorl %edx, %edx
divq %r9
movq %rdx, %rcx
movq %rsi, %rax
xorl %edx, %edx
divq %r10
leaq 0x1(%rdx), %rax
imulq %rbp, %rax
addq %rcx, %rax
xorl %edx, %edx
divq %r9
movq 0x8(%rsp), %rax
movq (%rax,%rdx,8), %rax
testq %rax, %rax
je 0x12712
incq %rbp
movq %rax, %rcx
shrq $0x10, %rcx
cmpq %rsi, %rcx
jne 0x126b2
cmpw $-0x1, %ax
je 0x12709
incq %rax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%rdx,8)
movq (%rsp), %rbp
jmp 0x125f1
shlq $0x10, %rsi
incq %rsi
movq 0x8(%rsp), %rax
movq %rsi, (%rax,%rdx,8)
movq 0x18(%rsp), %rax
incl %eax
movq %rax, 0x18(%rsp)
cmpl 0x4aef8(%rip), %eax     # 0x5d62c
movq (%rsp), %rbp
jbe 0x125f1
callq 0x3060
movl (%rax), %edi
movl 0x4aecd(%rip), %edx     # 0x5d618
incl %edx
leaq 0x4a9a(%rip), %rsi      # 0x171ee
xorl %eax, %eax
callq 0x3330
movq %r14, %rdi
callq 0x31a0
movq %r15, %rdi
callq 0x3040
movq %r12, %rdi
callq 0x3040
movq 0x8(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3060
movl (%rax), %edi
leaq 0x4b41(%rip), %rsi      # 0x172d9
leaq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x3330