// File: /workspace/github_c_makefile_star2_O0/yhg926[P]public_kssd/iseq2comem.c
// Function: fastq2co
llong * fastq2co(char* seqfname, llong *co, char *pipecmd, int Q, int M )
{
 if(M >= CT_MAX) err(errno,"fastq2co(): Occurence num should smaller than %d", (int)CT_MAX);
 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,"fastq2co():%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;
   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){
     if( M == 1) co[n] = (drtuple << CT_BIT) | CT_MAX;
     else co[n] = (drtuple << CT_BIT) + 1LLU;
          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] >> CT_BIT ) == drtuple ) {
           if( (co[n] & CT_MAX) == CT_MAX ) break;
      co[n] += 1LLU;
      if( !((co[n] & CT_MAX) < M) ) co[n]|= CT_MAX ;
      break ;
        };
   };
  };
 }
 printf("%d reads detected\n",line_num);
 pclose(infp);
 free(seq);
  free(qual);
 return co;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movslq -0x20(%rbp), %rax
cmpq $0xf, %rax
jb 0x19112
callq 0x3050
movl (%rax), %edi
leaq 0x600b(%rip), %rsi      # 0x1f111
movl $0xf, %edx
movb $0x0, %al
callq 0x3300
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl 0x4b4f0(%rip), %eax     # 0x6461c
movl %eax, %edx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x31f0
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x19164
leaq -0x150(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x8(%rbp), %rcx
leaq 0x5e8b(%rip), %rsi      # 0x1efe6
movb $0x0, %al
callq 0x3400
jmp 0x19184
leaq -0x150(%rbp), %rdi
movq -0x8(%rbp), %rcx
leaq 0x5e70(%rip), %rsi      # 0x1efe6
leaq 0x606a(%rip), %rdx      # 0x1f1e7
movb $0x0, %al
callq 0x3400
leaq -0x150(%rbp), %rdi
leaq 0x4b46(%rip), %rsi      # 0x1dcd8
callq 0x3360
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0x191bd
callq 0x3050
movl (%rax), %edi
leaq -0x150(%rbp), %rdx
leaq 0x5f8c(%rip), %rsi      # 0x1f142
movb $0x0, %al
callq 0x3300
movl $0x4e2a, %edi           # imm = 0x4E2A
callq 0x3310
movq %rax, -0x158(%rbp)
movl $0x4e2a, %edi           # imm = 0x4E2A
callq 0x3310
movq %rax, -0x160(%rbp)
movq -0x158(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x4e20, %esi           # imm = 0x4E20
callq 0x3260
movq -0x158(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x4e20, %esi           # imm = 0x4E20
callq 0x3260
movq -0x160(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x4e20, %esi           # imm = 0x4E20
callq 0x3260
movq -0x160(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x4e20, %esi           # imm = 0x4E20
callq 0x3260
movq $0x1, -0x168(%rbp)
movl $0x0, -0x174(%rbp)
movl $0x0, -0x178(%rbp)
movq -0x158(%rbp), %rdi
callq 0x3110
movl %eax, -0x17c(%rbp)
movl $0x0, -0x180(%rbp)
movl -0x180(%rbp), %eax
cmpl -0x17c(%rbp), %eax
jge 0x196a3
movq -0x158(%rbp), %rax
movslq -0x180(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x1933d
movq -0x158(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x4e20, %esi           # imm = 0x4E20
callq 0x3260
movq -0x158(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x4e20, %esi           # imm = 0x4E20
callq 0x3260
movq -0x160(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x4e20, %esi           # imm = 0x4E20
callq 0x3260
movq -0x160(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x4e20, %esi           # imm = 0x4E20
callq 0x3260
movq -0x158(%rbp), %rdi
callq 0x3110
movl %eax, -0x17c(%rbp)
movl -0x174(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x174(%rbp)
movq -0x50(%rbp), %rdi
callq 0x32a0
cmpl $0x0, %eax
jne 0x19338
movq $0x1, -0x168(%rbp)
movl $0xffffffff, -0x180(%rbp) # imm = 0xFFFFFFFF
jmp 0x1968f
jmp 0x196a3
movq -0x158(%rbp), %rax
movslq -0x180(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x169(%rbp)
movsbl -0x169(%rbp), %eax
movslq %eax, %rcx
leaq 0x562b(%rip), %rax      # 0x1e990
movl (%rax,%rcx,4), %eax
movl %eax, -0x170(%rbp)
cmpl $-0x1, -0x170(%rbp)
je 0x193e5
movq -0x160(%rbp), %rax
movslq -0x180(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x1c(%rbp), %eax
jl 0x193e5
movq -0x28(%rbp), %rax
shlq $0x2, %rax
movslq -0x170(%rbp), %rcx
orq %rcx, %rax
andq 0x4b289(%rip), %rax     # 0x64630
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
shrq $0x2, %rax
movslq -0x170(%rbp), %rdx
xorq $0x3, %rdx
movl 0x4b268(%rip), %ecx     # 0x6462c
shlq %cl, %rdx
movq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x168(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x168(%rbp)
jmp 0x193f5
movq $0x1, -0x168(%rbp)
jmp 0x1968f
jmp 0x193f7
movq -0x168(%rbp), %rax
movslq 0x4b233(%rip), %rcx     # 0x64638
cmpq %rcx, %rax
jbe 0x1968d
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x19425
movq -0x28(%rbp), %rax
movq %rax, -0x198(%rbp)
jmp 0x19430
movq -0x30(%rbp), %rax
movq %rax, -0x198(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
andq 0x4b1fa(%rip), %rax     # 0x64640
movl 0x4b1c8(%rip), %ecx     # 0x64614
shll %ecx
movl %ecx, %ecx
shrq %cl, %rax
movl %eax, -0x184(%rbp)
movq 0x4b1f0(%rip), %rax     # 0x64650
movslq -0x184(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movslq 0x4b1e6(%rip), %rcx     # 0x64660
cmpq %rcx, %rax
jae 0x1948f
movq -0x48(%rbp), %rax
movslq 0x4b1d2(%rip), %rcx     # 0x6465c
cmpq %rcx, %rax
jae 0x19494
jmp 0x1968f
movq -0x48(%rbp), %rax
movslq 0x4b1bd(%rip), %rcx     # 0x6465c
subq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
andq 0x4b197(%rip), %rax     # 0x64648
movq -0x38(%rbp), %rdx
movl 0x4b159(%rip), %ecx     # 0x64614
shll %ecx
movl %ecx, %ecx
movl $0x1, %esi
shlq %cl, %rsi
movq %rsi, %rcx
subq $0x1, %rcx
andq %rcx, %rdx
movl 0x4b161(%rip), %ecx     # 0x64638
shll %ecx
movl 0x4b135(%rip), %esi     # 0x64614
shll $0x2, %esi
subl %esi, %ecx
movl %ecx, %ecx
shlq %cl, %rdx
movq %rdx, %rcx
addq %rcx, %rax
movl 0x4b123(%rip), %ecx     # 0x64618
shll $0x2, %ecx
movl %ecx, %ecx
shrq %cl, %rax
addq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x188(%rbp)
movl -0x188(%rbp), %eax
cmpl 0x4b101(%rip), %eax     # 0x6461c
jae 0x1968b
movq -0x40(%rbp), %rax
movl 0x4b0f1(%rip), %ecx     # 0x6461c
xorl %edx, %edx
divq %rcx
movq %rdx, -0x1a0(%rbp)
movl -0x188(%rbp), %eax
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl 0x4b0d3(%rip), %edx     # 0x6461c
subl $0x1, %edx
movl %edx, %edx
movl %edx, %esi
xorl %edx, %edx
divq %rsi
movq -0x1a0(%rbp), %rax
addq $0x1, %rdx
imulq %rdx, %rcx
addq %rcx, %rax
movl 0x4b0af(%rip), %ecx     # 0x6461c
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, -0x18c(%rbp)
movq -0x10(%rbp), %rax
movl -0x18c(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x195f8
cmpl $0x1, -0x20(%rbp)
jne 0x195ad
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
orq $0xf, %rdx
movq -0x10(%rbp), %rax
movl -0x18c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x195c7
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq $0x1, %rdx
movq -0x10(%rbp), %rax
movl -0x18c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x178(%rbp), %eax
cmpl 0x4b04d(%rip), %eax     # 0x64620
jbe 0x195f3
callq 0x3050
movl (%rax), %edi
movl 0x4b02a(%rip), %edx     # 0x6460c
addl $0x1, %edx
leaq 0x5ae4(%rip), %rsi      # 0x1f0d0
movb $0x0, %al
callq 0x3300
jmp 0x1968b
movq -0x10(%rbp), %rax
movl -0x18c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x4, %rax
cmpq -0x40(%rbp), %rax
jne 0x19673
movq -0x10(%rbp), %rax
movl -0x18c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
andq $0xf, %rax
cmpq $0xf, %rax
jne 0x1962a
jmp 0x1968b
movq -0x10(%rbp), %rax
movl -0x18c(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movl -0x18c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
andq $0xf, %rax
movslq -0x20(%rbp), %rcx
cmpq %rcx, %rax
jb 0x19671
movq -0x10(%rbp), %rax
movl -0x18c(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
orq $0xf, %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1968b
jmp 0x19675
jmp 0x19677
movl -0x188(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x188(%rbp)
jmp 0x1950f
jmp 0x1968d
jmp 0x1968f
movl -0x180(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x180(%rbp)
jmp 0x1926e
movl -0x174(%rbp), %esi
leaq 0x5aa0(%rip), %rdi      # 0x1f150
movb $0x0, %al
callq 0x3150
movq -0x50(%rbp), %rdi
callq 0x3180
movq -0x158(%rbp), %rdi
callq 0x3040
movq -0x160(%rbp), %rdi
callq 0x3040
movq -0x10(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
nopw %cs:(%rax,%rax)