// File: /workspace/github_c_makefile_star2_O2/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, 0x48(%rsp)
leaq 0x1919(%rip), %rsi      # 0x71e5
movq %rdx, %rdi
callq 0x2260
movq %rax, %rbx
leaq 0x2579(%rip), %rdi      # 0x7e57
pushq $0xb
popq %rsi
pushq $0x1
popq %rdx
movq %rax, %rcx
callq 0x22c0
movl 0x4a26(%rip), %eax      # 0xa318
movq %rax, 0x38(%rsp)
movslq 0x48ce(%rip), %rax      # 0xa1cc
movq %rax, 0x40(%rsp)
leaq 0x2559(%rip), %r14      # 0x7e63
xorl %ebp, %ebp
cmpl $0x2a, %ebp
je 0x5924
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2160
incl %ebp
jmp 0x590c
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x30(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
movl $0x0, 0xc(%rsp)
xorl %r12d, %r12d
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x2110
movslq 0x4875(%rip), %rax      # 0xa1cc
movq 0x30(%rsp), %rdx
cmpq %rax, %rdx
jge 0x5a81
movl %r12d, %eax
imulq $0x14, %rdx, %r12
movq 0x48(%rsp), %r14
movl 0x8(%r14,%r12), %r9d
movl 0xc(%r14,%r12), %r11d
addl %r9d, %eax
movl %eax, 0x2c(%rsp)
movl 0x10(%r14,%r12), %r10d
incq %rdx
movl (%r14,%r12), %ecx
movl 0x4(%r14,%r12), %r8d
movq %rbx, %rdi
leaq 0x24ca(%rip), %rsi      # 0x7e67
movq %rdx, 0x30(%rsp)
xorl %eax, %eax
movq %r10, 0x58(%rsp)
pushq %r10
movq %r11, 0x58(%rsp)
pushq %r11
callq 0x2160
popq %rcx
popq %rdx
movl 0x4959(%rip), %eax      # 0xa318
cvtsi2sd %rax, %xmm0
movd (%r14,%r12), %xmm1
movd 0x8(%r14,%r12), %xmm2
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
movd 0x4(%r14,%r12), %xmm1
movd 0xc(%r14,%r12), %xmm3
xorl %r14d, %r14d
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
movapd %xmm0, 0x60(%rsp)
xorl %r12d, %r12d
cmpq $0x2a, %r12
je 0x5a4f
movl (%r15,%r12,4), %edx
movq %rbx, %rdi
leaq 0x2437(%rip), %rsi      # 0x7e63
xorl %eax, %eax
callq 0x2160
cmpq $0x14, %r12
jb 0x5a4a
movl (%r15,%r12,4), %eax
addl %eax, %r13d
cmpq $0x1e, %r12
cmovbl %r14d, %eax
addl %eax, %ebp
incq %r12
jmp 0x5a18
movl 0x2c(%rsp), %r12d
addl 0x50(%rsp), %r12d
movq 0x58(%rsp), %rax
addl 0xc(%rsp), %eax
movaps 0x60(%rsp), %xmm0
maxps 0x10(%rsp), %xmm0
addq $0xc8, %r15
movl %eax, 0xc(%rsp)
movaps %xmm0, 0x10(%rsp)
jmp 0x5945
movq 0x40(%rsp), %r14
imulq 0x38(%rsp), %r14
movl 0x4886(%rip), %edx      # 0xa318
leaq 0x23e0(%rip), %rsi      # 0x7e79
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2160
leaq 0x23e0(%rip), %rsi      # 0x7e8a
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2160
movaps 0x10(%rsp), %xmm0
mulss 0x1588(%rip), %xmm0     # 0x704c
cvtss2sd %xmm0, %xmm0
leaq 0x23cd(%rip), %rsi      # 0x7e9c
movq %rbx, %rdi
movb $0x1, %al
callq 0x2160
movaps 0x10(%rsp), %xmm0
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
mulss 0x1562(%rip), %xmm0     # 0x704c
cvtss2sd %xmm0, %xmm0
leaq 0x23ba(%rip), %rsi      # 0x7eaf
movq %rbx, %rdi
movb $0x1, %al
callq 0x2160
movl 0xc(%rsp), %eax
cvtsi2ss %rax, %xmm0
cvtsi2ss %r14, %xmm1
movss %xmm1, 0x10(%rsp)
mulss 0x1531(%rip), %xmm0     # 0x704c
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2398(%rip), %rsi      # 0x7ec2
movq %rbx, %rdi
movb $0x1, %al
callq 0x2160
movl %r13d, %eax
cvtsi2ss %rax, %xmm0
mulss 0x1508(%rip), %xmm0     # 0x704c
divss 0x10(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2382(%rip), %rsi      # 0x7ed7
movq %rbx, %rdi
movb $0x1, %al
callq 0x2160
movl %ebp, %eax
cvtsi2ss %rax, %xmm0
mulss 0x14de(%rip), %xmm0     # 0x704c
divss 0x10(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2367(%rip), %rsi      # 0x7ee6
movq %rbx, %rdi
movb $0x1, %al
callq 0x2160
movl %r12d, %eax
cvtsi2ss %rax, %xmm0
mulss 0x14b3(%rip), %xmm0     # 0x704c
divss 0x10(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x234b(%rip), %rsi      # 0x7ef5
movq %rbx, %rdi
movb $0x1, %al
callq 0x2160
movq %rbx, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20b0