// File: /workspace/github_c_makefile_star2_O2/annoroad[P]fqtools_plus/fqtools.c
// Function: quality_base_percent
local void quality_base_percent(struct readclass* readclass){
	readline* read1 = readclass->read1;
    int i=0;
    int curqual;
    read1->highAT_sign=0;
    read1->low = 0;
	read1->N = 0;
    read1->Q30=0;
    read1->A=0;
    read1->T=0;
    read1->GC=0;
	char* seq=(read1->reads)[1];
	char* qual=(read1->reads)[3];
    while(i < g.CUT){
        switch (*(seq + i)){
            case 'A': read1->A++; break;
            case 'a': read1->A++; break;
            case 'T': read1->T++; break;
            case 't': read1->T++; break;
            case 'G': read1->GC++; break;
            case 'g': read1->GC++; break;
            case 'C': read1->GC++; break;
            case 'c': read1->GC++; break;
            case 'N': read1->N++;  break;
            case 'n': read1->N++;  break;
        }
        curqual = (int)*(qual + i) - g.ASCII;
        i++;
        if (curqual <= g.LOWQ){
           	read1->low++;
            continue;
        }

        if (curqual >= g.HIGHQ){
            read1->Q30++;
            continue;
        }
    }
    if (read1->A >= g.highAT || read1->T >= g.highAT){
    	read1->highAT_sign=1;
    }
    if (g.single_or_pair){
    	readline* read2 = readclass->read2;
    	i=0;
	    read2->highAT_sign=0;
	    read2->low = 0;
		read2->N = 0;
	    read2->Q30=0;
	    read2->A=0;
	    read2->T=0;
	    read2->GC=0;
	   	seq=(read2->reads)[1];
		qual=(read2->reads)[3];
	    while(i < g.CUT){
	        switch (*(seq + i)){
	            case 'A': read2->A++; break;
	            case 'a': read2->A++; break;
	            case 'T': read2->T++; break;
	            case 't': read2->T++; break;
	            case 'G': read2->GC++; break;
	            case 'g': read2->GC++; break;
	            case 'C': read2->GC++; break;
	            case 'c': read2->GC++; break;
	            case 'N': read2->N++;  break;
	            case 'n': read2->N++;  break;
	        }
	        curqual = (int)*(qual + i) - g.ASCII;
	        i++;
	        if (curqual <= g.LOWQ){
	            read2->low++;
	            continue;
	        }
	        if (curqual >= g.HIGHQ){
	            read2->Q30++;
	            continue;
	        }
	    }
		if (read2->A >= g.highAT || read2->T >= g.highAT){
		   	read2->highAT_sign=1;
		}
    }
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq (%rdi), %rcx
leaq 0x4(%rcx), %rdx
xorps %xmm0, %xmm0
movups %xmm0, 0xd(%rcx)
movups %xmm0, 0x4(%rcx)
movl 0x68f6(%rip), %eax      # 0xa1cc
movl 0x6920(%rip), %esi      # 0xa1fc
movl 0x68fd(%rip), %r8d      # 0xa1e0
movl 0x68fa(%rip), %r9d      # 0xa1e4
xorl %r10d, %r10d
testl %eax, %eax
cmovlel %r10d, %eax
xorl %ebx, %ebx
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r11d, %r11d
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpq %r12, %rax
je 0x39a3
movzbl 0x41d(%rcx,%r12), %r13d
cmpl $0x74, %r13d
je 0x396a
cmpl $0x43, %r13d
je 0x395a
cmpl $0x47, %r13d
je 0x395a
cmpl $0x4e, %r13d
je 0x3961
cmpl $0x54, %r13d
je 0x396a
cmpl $0x61, %r13d
je 0x3951
cmpl $0x63, %r13d
je 0x395a
cmpl $0x67, %r13d
je 0x395a
cmpl $0x6e, %r13d
je 0x3961
cmpl $0x41, %r13d
jne 0x3971
incl %r15d
movl %r15d, 0x8(%rcx)
jmp 0x3971
incl %ebp
movl %ebp, 0x10(%rcx)
jmp 0x3971
incl %r14d
movl %r14d, 0x18(%rcx)
jmp 0x3971
incl %r11d
movl %r11d, 0xc(%rcx)
movsbl 0xc1d(%rcx,%r12), %r13d
subl %esi, %r13d
incq %r12
cmpl %r8d, %r13d
jle 0x3999
cmpl %r9d, %r13d
jl 0x3903
incl %r10d
movl %r10d, (%rdx)
jmp 0x3903
incl %ebx
movl %ebx, 0x14(%rcx)
jmp 0x3903
cvtsi2ss %r15d, %xmm1
movss 0x6840(%rip), %xmm0     # 0xa1f0
ucomiss %xmm0, %xmm1
jae 0x39bf
cvtsi2ss %r11d, %xmm1
ucomiss %xmm0, %xmm1
jb 0x39c3
movb $0x1, 0x1c(%rcx)
cmpb $0x0, 0x67fe(%rip)      # 0xa1c8
je 0x3ac1
movq 0x8(%rdi), %rcx
leaq 0x4(%rcx), %rdx
xorps %xmm1, %xmm1
movups %xmm1, 0xd(%rcx)
movups %xmm1, 0x4(%rcx)
movl 0x6813(%rip), %esi      # 0xa1fc
movl 0x67f1(%rip), %edi      # 0xa1e0
xorl %r8d, %r8d
movl 0x67eb(%rip), %r10d     # 0xa1e4
xorl %r11d, %r11d
xorl %ebx, %ebx
xorl %ebp, %ebp
xorl %r9d, %r9d
xorl %r14d, %r14d
xorl %r15d, %r15d
cmpq %r15, %rax
je 0x3aa9
movzbl 0x41d(%rcx,%r15), %r12d
cmpl $0x74, %r12d
je 0x3a6e
cmpl $0x43, %r12d
je 0x3a60
cmpl $0x47, %r12d
je 0x3a60
cmpl $0x4e, %r12d
je 0x3a67
cmpl $0x54, %r12d
je 0x3a6e
cmpl $0x61, %r12d
je 0x3a57
cmpl $0x63, %r12d
je 0x3a60
cmpl $0x67, %r12d
je 0x3a60
cmpl $0x6e, %r12d
je 0x3a67
cmpl $0x41, %r12d
jne 0x3a75
incl %r14d
movl %r14d, 0x8(%rcx)
jmp 0x3a75
incl %ebx
movl %ebx, 0x10(%rcx)
jmp 0x3a75
incl %ebp
movl %ebp, 0x18(%rcx)
jmp 0x3a75
incl %r9d
movl %r9d, 0xc(%rcx)
movsbl 0xc1d(%rcx,%r15), %r12d
subl %esi, %r12d
incq %r15
cmpl %edi, %r12d
jle 0x3a9d
cmpl %r10d, %r12d
jl 0x3a09
incl %r8d
movl %r8d, (%rdx)
jmp 0x3a09
incl %r11d
movl %r11d, 0x14(%rcx)
jmp 0x3a09
cvtsi2ss %r14d, %xmm1
ucomiss %xmm0, %xmm1
jae 0x3abd
cvtsi2ss %r9d, %xmm1
ucomiss %xmm0, %xmm1
jb 0x3ac1
movb $0x1, 0x1c(%rcx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq