// File: /workspace/github_c_makefile_star2_O1/annoroad[P]fqtools_plus/fqtools.c
// Function: outreport
local void outreport(unsigned int (*base)[5], unsigned int (*quality)[50],  const char* outfile){
	FILE* fp=fopen(outfile,"w");
	fprintf(fp,"#\tA\tT\tC\tG\tN");
	int m,n;
	long long total_base = (long long)allstat.clean_reads * g.CUT;
	unsigned int q30=0;
	unsigned int q20=0;
	unsigned int N=0;
	unsigned int GC=0;

	float GC_bias=0;
	float AT_bias=0;
	float cur_GC_bias=0;
	float cur_AT_bias=0;

	for (m=0;m<42;m++){
		fprintf(fp,"\t%d",m);
	}
	fprintf(fp,"\n");
	for (n=0;n<g.CUT;n++){
		GC += base[n][2] + base[n][3];
		N += base[n][4];
		fprintf(fp,"%d\t%u\t%u\t%u\t%u\t%u",n+1,base[n][0],base[n][1],base[n][2],base[n][3],base[n][4]);
		cur_AT_bias=1.0 * abs(base[n][0] - base[n][1])/allstat.clean_reads;
		cur_GC_bias=1.0 * abs(base[n][2] - base[n][3])/allstat.clean_reads;
		if (cur_AT_bias > AT_bias){
			AT_bias = cur_AT_bias;
		}
		if (cur_GC_bias > GC_bias){
			GC_bias = cur_GC_bias;
		}
		for (m=0;m<42;m++){
			fprintf(fp,"\t%d",quality[n][m]);
			if (m >= 20){
				q20 += quality[n][m];
			}
			if (m >= 30){
				q30 += quality[n][m];
			}
		}	
		fprintf(fp,"\n");
	}
	fprintf(fp, "#total_reads\t%d\n",allstat.clean_reads);
	fprintf(fp, "#total_base\t%lld\n", total_base);
	fprintf(fp, "#GC_bias(%%)\t%.3f\n",(float)100.0*GC_bias);
	fprintf(fp, "#AT_bias(%%)\t%.3f\n",(float)100.0*AT_bias);
	fprintf(fp, "#N_percent(%%)\t%.3f\n",(float)100.0*(long long)N/total_base);
	fprintf(fp, "#Q20(%%)\t%.3f\n",(float)100.0*(long long)q20/total_base);
	fprintf(fp, "#Q30(%%)\t%.3f\n",(float)100.0*(long long)q30/total_base);
	fprintf(fp, "#GC_percent(%%)\t%.3f\n",(float)100.0*(long long)GC/total_base);
	fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r15
movq %rdi, 0x40(%rsp)
leaq 0x13ef(%rip), %rsi      # 0x7241
movq %rdx, %rdi
callq 0x2250
movq %rax, %rbx
leaq 0x204f(%rip), %rdi      # 0x7eb3
movl $0xb, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x22b0
movl 0x5493(%rip), %r13d     # 0xb310
movslq 0x5340(%rip), %r12      # 0xb1c4
leaq 0x2034(%rip), %r14      # 0x7ebf
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2150
incl %ebp
cmpl $0x2a, %ebp
jne 0x5e8d
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2110
cmpl $0x0, 0x530d(%rip)      # 0xb1c4
jle 0x608c
movq %r13, 0x30(%rsp)
movq %r12, 0x38(%rsp)
xorps %xmm0, %xmm0
xorl %edx, %edx
xorl %eax, %eax
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %r14d, %r14d
movaps %xmm0, 0x60(%rsp)
movl %r12d, 0x2c(%rsp)
leaq (%rdx,%rdx,4), %r12
movq 0x40(%rsp), %rbp
movl 0x8(%rbp,%r12,4), %r9d
movl 0xc(%rbp,%r12,4), %r10d
addl %r9d, %eax
movl %eax, (%rsp)
movl 0x10(%rbp,%r12,4), %r11d
incq %rdx
movl (%rbp,%r12,4), %ecx
movl 0x4(%rbp,%r12,4), %r8d
movq %rbx, %rdi
leaq 0x1fad(%rip), %rsi      # 0x7ec3
movq %rdx, 0x58(%rsp)
xorl %eax, %eax
movq %r11, 0x48(%rsp)
pushq %r11
movq %r10, 0x58(%rsp)
pushq %r10
callq 0x2150
addq $0x10, %rsp
movl 0x53d6(%rip), %eax      # 0xb310
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movd (%rbp,%r12,4), %xmm1
movd 0x8(%rbp,%r12,4), %xmm2
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
movd 0x4(%rbp,%r12,4), %xmm1
movd 0xc(%rbp,%r12,4), %xmm3
punpckldq %xmm1, %xmm3    # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
psubd %xmm3, %xmm2
movdqa %xmm2, %xmm1
psrad $0x1f, %xmm1
pxor %xmm1, %xmm2
psubd %xmm1, %xmm2
cvtdq2pd %xmm2, %xmm1
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm1
cvtpd2ps %xmm1, %xmm0
xorl %r12d, %r12d
leaq 0x1f2a(%rip), %rbp      # 0x7ebf
movapd %xmm0, 0x10(%rsp)
movl (%r15,%r12,4), %edx
movq %rbx, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2150
cmpq $0x14, %r12
jb 0x5fb6
addl (%r15,%r12,4), %r13d
cmpq $0x1e, %r12
movaps 0x10(%rsp), %xmm0
jb 0x5fc5
addl (%r15,%r12,4), %r14d
incq %r12
cmpq $0x2a, %r12
jne 0x5f9b
movl (%rsp), %ebp
addl 0x50(%rsp), %ebp
movl 0x2c(%rsp), %r12d
addl 0x48(%rsp), %r12d
maxps 0x60(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2110
movaps 0x10(%rsp), %xmm1
movslq 0x51c2(%rip), %rax      # 0xb1c4
addq $0xc8, %r15
movaps %xmm1, %xmm0
movq 0x58(%rsp), %rdx
cmpq %rax, %rdx
movl %ebp, %eax
jl 0x5ed7
mulps 0x100d(%rip), %xmm1     # 0x7030
cvtps2pd %xmm1, %xmm0
movaps %xmm0, (%rsp)
movd %eax, %xmm0
movd %r12d, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movd %r13d, %xmm0
movd %r14d, %xmm2
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
punpcklqdq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0]
movdqa 0xfef(%rip), %xmm0      # 0x7040
pand %xmm2, %xmm0
por 0xff3(%rip), %xmm0      # 0x7050
psrld $0x10, %xmm2
por 0xff6(%rip), %xmm2      # 0x7060
subps 0xfff(%rip), %xmm2      # 0x7070
addps %xmm0, %xmm2
mulps 0x1005(%rip), %xmm2     # 0x7080
movaps %xmm2, 0x10(%rsp)
movq 0x38(%rsp), %r12
movq 0x30(%rsp), %r13
jmp 0x6098
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movaps %xmm0, 0x10(%rsp)
imulq %r13, %r12
movl 0x526e(%rip), %edx      # 0xb310
leaq 0x1e2c(%rip), %rsi      # 0x7ed5
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2150
leaq 0x1e2c(%rip), %rsi      # 0x7ee6
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2150
leaq 0x1e2a(%rip), %rsi      # 0x7ef8
movq %rbx, %rdi
movaps (%rsp), %xmm0
movb $0x1, %al
callq 0x2150
movaps (%rsp), %xmm0
movhlps %xmm0, %xmm0            # xmm0 = xmm0[1,1]
leaq 0x1e21(%rip), %rsi      # 0x7f0b
movq %rbx, %rdi
movb $0x1, %al
callq 0x2150
xorps %xmm1, %xmm1
cvtsi2ss %r12, %xmm1
movss %xmm1, (%rsp)
movaps 0x10(%rsp), %xmm0
movhlps %xmm0, %xmm0            # xmm0 = xmm0[1,1]
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1e06(%rip), %rsi      # 0x7f1e
movq %rbx, %rdi
movb $0x1, %al
callq 0x2150
movaps 0x10(%rsp), %xmm0
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
divss (%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1df8(%rip), %rsi      # 0x7f33
movq %rbx, %rdi
movb $0x1, %al
callq 0x2150
movaps 0x10(%rsp), %xmm0
divss (%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1de8(%rip), %rsi      # 0x7f42
movq %rbx, %rdi
movb $0x1, %al
callq 0x2150
movaps 0x10(%rsp), %xmm0
shufps $0xff, %xmm0, %xmm0     # xmm0 = xmm0[3,3,3,3]
divss (%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1dd4(%rip), %rsi      # 0x7f51
movq %rbx, %rdi
movb $0x1, %al
callq 0x2150
movq %rbx, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20b0