// File: /workspace/github_c_makefile_star2_O2/annoroad[P]fqtools_plus/fqtools.c
// Function: single_filter_main
void single_filter_main(void){
    new_pool(&in_pool, -1);
	struct job* job = new_job();
	job->in = get_space(&in_pool);
	in_pool.head = job->in;
	struct readclass* readclass = job->in->readclass;
	struct readline* read1 = readclass->read1;
	struct readline* read2 = readclass->read2;
	struct STAT* stat = readclass->stat;

	for(;;){
		if (!readn(job->in)) break;
		if (g.outraw){
			to_buffer_raw(readclass,job);
			fwrite(job->buffer1_raw,sizeof(char),job->l1_r,g.fpout1_raw);
			if (g.single_or_pair) fwrite(job->buffer2_raw,sizeof(char),job->l2_r,g.fpout2_raw);
		}

		if (g.single_or_pair){
			read1->seqlen = strlen(read1->reads[1])-1;
			read2->seqlen = strlen(read2->reads[1])-1;
			substr_((read1->reads)[0], read1->id);
			substr_((read2->reads)[0], read2->id);
			if (read1->seqlen < g.CUT || read2->seqlen < g.CUT) {
				continue;
			}
			raw_Q30(readclass);
			stat->raw_reads++;
			stat->raw_bases+= read1->seqlen + read2->seqlen;	
			cutseq(readclass);
			read1->seqlen = g.CUT;
			read2->seqlen = g.CUT;
			if (!checkadapter(readclass)){
				stat->adapter_reads++;
				continue;
			}
			quality_base_percent(readclass);
			if (read1->low >= g.LOW_QUALITY || read2->low >= g.LOW_QUALITY){
				stat->low_quality_reads++;
				continue;
			}
			if (read1->N >= g.highN || read2->N >= g.highN){
			    stat->ns_reads++;
				continue;
			}
			if (check_ployAT((read1->reads)[1], g.ployAT) || check_ployAT((read2->reads)[1], g.ployAT)){
			  	stat->ployAT_reads++;
			}
			if (read1->GC >= g.highGC || read2->GC >= g.highGC){
			   	stat->HighGC_reads++;
			}
			if (read1->highAT_sign || read2->highAT_sign){
			   	stat->HighAT_reads++;
			}
			stat->clean_Q30_bases += read1->Q30 + read2->Q30;
			stat->clean_reads++;
			report(readclass);
		}else{
			read1->seqlen = strlen(read1->reads[1])-1;
			substr_((read1->reads)[0], read1->id);
			if (read1->seqlen < g.CUT) {
				continue;
			}
			raw_Q30(readclass);
			stat->raw_reads++;
			stat->raw_bases+= read1->seqlen;
			cutseq(readclass);
			read1->seqlen = g.CUT;
			if (!checkadapter(readclass)){
				stat->adapter_reads++;
				continue;
			}
			quality_base_percent(readclass);
			if (read1->low >= g.LOW_QUALITY){
				stat->low_quality_reads++;
				continue;
			}
			if (read1->N >= g.highN){
			    stat->ns_reads++;
				continue;
			}

			if (check_ployAT((read1->reads)[1], g.ployAT)){
			  	stat->ployAT_reads++;
			}
			if (read1->GC >= g.highGC){
			   	stat->HighGC_reads++;
			}
			if (read1->highAT_sign){
			   	stat->HighAT_reads++;
			}
			stat->clean_Q30_bases += read1->Q30;
			stat->clean_reads++;
			report(readclass);

		}
		//-----------------------------------------------------
		to_buffer(readclass,job);
		fwrite(job->buffer1,sizeof(char),job->l1,g.fpout1);
		if (g.single_or_pair) fwrite(job->buffer2,sizeof(char),job->l2,g.fpout2);
		if (stat->clean_reads == g.QUOTA) break;
	}


	if (g.outraw){
		possess(job->calc);
		twist(job->calc,TO,1);	
	}

	gzclose(g.gzfp1);
    if (g.single_or_pair) gzclose(g.gzfp2);
    fclose(g.fpout1);
    if (g.single_or_pair) fclose(g.fpout2);
    if (g.outraw){
    	fclose(g.fpout1_raw);
	    if (g.single_or_pair) fclose(g.fpout2_raw);
    }

	if (job != NULL) free_job(job);
	merge_stat(&in_pool);
	free_pool(&in_pool);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
pushq $-0x1
popq %rdi
callq 0x35b0
callq 0x2a94
movq %rax, %rbx
callq 0x2ad4
movq %rax, %rdi
movq %rax, 0x10(%rbx)
movq %rax, 0x7147(%rip)      # 0xa2d0
movq 0x8(%rax), %r14
movq (%r14), %rbp
movq 0x8(%r14), %r15
movq 0x10(%r14), %r12
leaq 0x1d(%rbp), %rax
movq %rax, 0x30(%rsp)
movl $0x41d, %eax            # imm = 0x41D
leaq (%rax,%rbp), %r13
leaq 0x1d(%r15), %rcx
movq %rcx, 0x40(%rsp)
addq %r15, %rax
movq %rax, 0x20(%rsp)
movl $0x101d, %eax           # imm = 0x101D
leaq (%rax,%rbp), %rcx
movq %rcx, 0x28(%rsp)
addq %r15, %rax
movq %rax, 0x38(%rsp)
leaq 0x24(%r12), %rax
movq %rax, 0x8(%rsp)
leaq 0x2c(%r12), %rax
movq %rax, (%rsp)
leaq 0x34(%r12), %rax
movq %rax, 0x18(%rsp)
callq 0x2c2d
testl %eax, %eax
je 0x3502
cmpb $0x0, 0x7002(%rip)      # 0xa204
je 0x324a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x35d8
movq 0x50(%rbx), %rdi
movslq 0x58(%rbx), %rdx
movq 0x7082(%rip), %rcx      # 0xa2a0
pushq $0x1
popq %rsi
callq 0x22c0
cmpb $0x0, 0x6f9b(%rip)      # 0xa1c8
je 0x33be
movq 0x60(%rbx), %rdi
movslq 0x68(%rbx), %rdx
movq 0x7066(%rip), %rcx      # 0xa2a8
pushq $0x1
popq %rsi
callq 0x22c0
cmpb $0x0, 0x6f77(%rip)      # 0xa1c8
je 0x33be
movq %r13, %rdi
callq 0x20c0
decl %eax
movl %eax, (%rbp)
movq 0x20(%rsp), %rdi
callq 0x20c0
decl %eax
movl %eax, (%r15)
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x36a6
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x36a6
movl 0x6f35(%rip), %eax      # 0xa1cc
cmpl %eax, (%rbp)
jl 0x34f9
cmpl %eax, (%r15)
jl 0x34f9
movq %r14, %rdi
callq 0x36c0
incl (%r12)
movslq (%rbp), %rax
movslq (%r15), %rcx
addq %rax, %rcx
addq %rcx, 0x8(%r12)
movq %r14, %rdi
callq 0x3737
movl 0x6efa(%rip), %eax      # 0xa1cc
movl %eax, (%rbp)
movl %eax, (%r15)
movq %r14, %rdi
callq 0x381b
movq 0x18(%rsp), %rcx
testb %al, %al
je 0x34f7
movq %r14, %rdi
callq 0x38b4
cvtsi2ssl 0x14(%rbp), %xmm1
movss 0x6ee6(%rip), %xmm0     # 0xa1e8
ucomiss %xmm0, %xmm1
movq 0x8(%rsp), %rcx
jae 0x34f7
cvtsi2ssl 0x14(%r15), %xmm1
ucomiss %xmm0, %xmm1
movq 0x8(%rsp), %rcx
jae 0x34f7
cvtsi2ssl 0x18(%rbp), %xmm1
movss 0x6ebb(%rip), %xmm0     # 0xa1ec
ucomiss %xmm0, %xmm1
movq (%rsp), %rcx
jae 0x34f7
cvtsi2ssl 0x18(%r15), %xmm1
ucomiss %xmm0, %xmm1
movq (%rsp), %rcx
jae 0x34f7
movl 0x6ea1(%rip), %esi      # 0xa1f8
movq %r13, %rdi
movl %esi, 0x14(%rsp)
callq 0x3acc
testb %al, %al
jne 0x3379
movq 0x20(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x3acc
testb %al, %al
je 0x337e
incl 0x6c(%r12)
cvtsi2ssl 0x10(%rbp), %xmm1
movss 0x6e69(%rip), %xmm0     # 0xa1f4
ucomiss %xmm0, %xmm1
jae 0x339b
cvtsi2ssl 0x10(%r15), %xmm1
ucomiss %xmm0, %xmm1
jb 0x33a0
incl 0x64(%r12)
cmpb $0x0, 0x1c(%rbp)
jne 0x33ad
cmpb $0x0, 0x1c(%r15)
je 0x33b2
incl 0x5c(%r12)
movl 0x4(%r15), %eax
addl 0x4(%rbp), %eax
jmp 0x3491
movq %r13, %rdi
callq 0x20c0
decl %eax
movl %eax, (%rbp)
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x36a6
movl (%rbp), %eax
cmpl 0x6de9(%rip), %eax      # 0xa1cc
jl 0x34f9
movq %r14, %rdi
callq 0x36c0
incl (%r12)
movslq (%rbp), %rax
addq %rax, 0x8(%r12)
movq %r14, %rdi
callq 0x3737
movl 0x6dc0(%rip), %eax      # 0xa1cc
movl %eax, (%rbp)
movq %r14, %rdi
callq 0x381b
movq 0x18(%rsp), %rcx
testb %al, %al
je 0x34f7
movq %r14, %rdi
callq 0x38b4
cvtsi2ssl 0x14(%rbp), %xmm0
ucomiss 0x6db0(%rip), %xmm0     # 0xa1e8
movq 0x8(%rsp), %rcx
jae 0x34f7
cvtsi2ssl 0x18(%rbp), %xmm0
ucomiss 0x6d9d(%rip), %xmm0     # 0xa1ec
movq (%rsp), %rcx
jae 0x34f7
movl 0x6d99(%rip), %esi      # 0xa1f8
movq %r13, %rdi
callq 0x3acc
testb %al, %al
je 0x3470
incl 0x6c(%r12)
cvtsi2ssl 0x10(%rbp), %xmm0
ucomiss 0x6d78(%rip), %xmm0     # 0xa1f4
jb 0x3483
incl 0x64(%r12)
cmpb $0x0, 0x1c(%rbp)
je 0x348e
incl 0x5c(%r12)
movl 0x4(%rbp), %eax
cltq
addq %rax, 0x50(%r12)
incl 0x10(%r12)
movq %r14, %rdi
callq 0x3b20
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3cf6
movq 0x30(%rbx), %rdi
movslq 0x38(%rbx), %rdx
movq 0x6dd1(%rip), %rcx      # 0xa290
pushq $0x1
popq %rsi
callq 0x22c0
cmpb $0x0, 0x6cfa(%rip)      # 0xa1c8
je 0x34e7
movq 0x40(%rbx), %rdi
movslq 0x48(%rbx), %rdx
movq 0x6db9(%rip), %rcx      # 0xa298
pushq $0x1
popq %rsi
callq 0x22c0
movl 0x10(%r12), %eax
cmpq %rax, 0x6ce5(%rip)      # 0xa1d8
jne 0x34f9
jmp 0x3502
incl (%rcx)
movq 0x10(%rbx), %rdi
jmp 0x31ee
cmpb $0x0, 0x6cfb(%rip)      # 0xa204
je 0x3524
movq 0x18(%rbx), %r14
movq %r14, %rdi
callq 0x5ccb
pushq $0x1
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x5e4d
movq 0x6d55(%rip), %rdi      # 0xa280
callq 0x2030
cmpb $0x0, 0x6c91(%rip)      # 0xa1c8
je 0x3545
movq 0x6d48(%rip), %rdi      # 0xa288
callq 0x2030
movq 0x6d44(%rip), %rdi      # 0xa290
callq 0x20b0
cmpb $0x0, 0x6c70(%rip)      # 0xa1c8
je 0x3566
movq 0x6d37(%rip), %rdi      # 0xa298
callq 0x20b0
cmpb $0x0, 0x6c97(%rip)      # 0xa204
je 0x3590
movq 0x6d2a(%rip), %rdi      # 0xa2a0
callq 0x20b0
cmpb $0x0, 0x6c46(%rip)      # 0xa1c8
je 0x3590
movq 0x6d1d(%rip), %rdi      # 0xa2a8
callq 0x20b0
movq %rbx, %rdi
callq 0x264f
callq 0x3dbe
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3fe4