// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_stat.c
// Function: bam_flagstat
int bam_flagstat(int argc, char *argv[])
{
	bamFile fp;
	bam_header_t *header;
	bam_flagstat_t *s;
	if (argc == optind) {
		fprintf(stderr, "Usage: samtools flagstat <in.bam>\n");
		return 1;
	}
	fp = strcmp(argv[optind], "-")? bam_open(argv[optind], "r") : bam_dopen(fileno(stdin), "r");
	assert(fp);
	header = bam_header_read(fp);
	s = bam_flagstat_core(fp);
	printf("%lld + %lld in total (QC-passed reads + QC-failed reads)\n", s->n_reads[0], s->n_reads[1]);
	printf("%lld + %lld duplicates\n", s->n_dup[0], s->n_dup[1]);
	printf("%lld + %lld mapped (%.2f%%:%.2f%%)\n", s->n_mapped[0], s->n_mapped[1], (float)s->n_mapped[0] / s->n_reads[0] * 100.0, (float)s->n_mapped[1] / s->n_reads[1] * 100.0);
	printf("%lld + %lld paired in sequencing\n", s->n_pair_all[0], s->n_pair_all[1]);
	printf("%lld + %lld read1\n", s->n_read1[0], s->n_read1[1]);
	printf("%lld + %lld read2\n", s->n_read2[0], s->n_read2[1]);
	printf("%lld + %lld properly paired (%.2f%%:%.2f%%)\n", s->n_pair_good[0], s->n_pair_good[1], (float)s->n_pair_good[0] / s->n_pair_all[0] * 100.0, (float)s->n_pair_good[1] / s->n_pair_all[1] * 100.0);
	printf("%lld + %lld with itself and mate mapped\n", s->n_pair_map[0], s->n_pair_map[1]);
	printf("%lld + %lld singletons (%.2f%%:%.2f%%)\n", s->n_sgltn[0], s->n_sgltn[1], (float)s->n_sgltn[0] / s->n_pair_all[0] * 100.0, (float)s->n_sgltn[1] / s->n_pair_all[1] * 100.0);
	printf("%lld + %lld with mate mapped to a different chr\n", s->n_diffchr[0], s->n_diffchr[1]);
	printf("%lld + %lld with mate mapped to a different chr (mapQ>=5)\n", s->n_diffhigh[0], s->n_diffhigh[1]);
	free(s);
	bam_header_destroy(header);
	bam_close(fp);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x40a80(%rip), %rax     # 0x4efb8
movslq (%rax), %rax
cmpl %edi, %eax
je 0xe799
movq (%rsi,%rax,8), %rbx
leaq 0x3090a(%rip), %rsi     # 0x3ee58
movq %rbx, %rdi
callq 0x35a0
testl %eax, %eax
je 0xe56b
leaq 0x3670e(%rip), %rsi     # 0x44c6f
movq %rbx, %rdi
callq 0x1fdb8
jmp 0xe588
movq 0x40a5e(%rip), %rax     # 0x4efd0
movq (%rax), %rdi
callq 0x3030
leaq 0x366ee(%rip), %rsi     # 0x44c6f
movl %eax, %edi
callq 0x1ff6b
movq %rax, %rbx
testq %rax, %rax
je 0xe7a5
movq %rbx, %rdi
callq 0x22efa
movq %rax, %r14
movq %rbx, %rdi
callq 0xe400
movq %rax, %r15
movq (%rax), %r13
movq 0x8(%rax), %r12
leaq 0x31d8b(%rip), %rdi     # 0x40343
xorl %ebp, %ebp
movq %r13, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x3060
movq 0x80(%r15), %rsi
movq 0x88(%r15), %rdx
leaq 0x31da1(%rip), %rdi     # 0x4037d
xorl %eax, %eax
callq 0x3060
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
cvtsi2ss %rsi, %xmm0
cvtsi2ss %r13, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %rdx, %xmm1
movsd 0x31cab(%rip), %xmm3    # 0x402b8
cvtsi2ss %r12, %xmm2
mulsd %xmm3, %xmm0
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm3, %xmm1
leaq 0x31d6c(%rip), %rdi     # 0x40395
movb $0x2, %al
callq 0x3060
movq 0x20(%r15), %r13
movq 0x28(%r15), %r12
leaq 0x31d7a(%rip), %rdi     # 0x403b9
movq %r13, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x3060
movq 0x60(%r15), %rsi
movq 0x68(%r15), %rdx
leaq 0x31d80(%rip), %rdi     # 0x403db
xorl %eax, %eax
callq 0x3060
movq 0x70(%r15), %rsi
movq 0x78(%r15), %rdx
leaq 0x31d7d(%rip), %rdi     # 0x403ee
xorl %eax, %eax
callq 0x3060
movq 0x40(%r15), %rsi
xorps %xmm0, %xmm0
cvtsi2ss %rsi, %xmm0
movq 0x48(%r15), %rdx
xorps %xmm1, %xmm1
cvtsi2ss %r13, %xmm1
movss %xmm1, 0x4(%rsp)
divss %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %rdx, %xmm1
cvtss2sd %xmm0, %xmm0
xorps %xmm3, %xmm3
cvtsi2ss %r12, %xmm3
movss %xmm3, (%rsp)
movsd 0x31bfd(%rip), %xmm2    # 0x402b8
mulsd %xmm2, %xmm0
divss %xmm3, %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm2, %xmm1
leaq 0x31d2f(%rip), %rdi     # 0x40401
movb $0x2, %al
callq 0x3060
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
leaq 0x31d46(%rip), %rdi     # 0x4042e
xorl %eax, %eax
callq 0x3060
movq 0x50(%r15), %rsi
movq 0x58(%r15), %rdx
xorps %xmm0, %xmm0
cvtsi2ss %rsi, %xmm0
divss 0x4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %rdx, %xmm1
movsd 0x31b9f(%rip), %xmm2    # 0x402b8
mulsd %xmm2, %xmm0
divss (%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm2, %xmm1
leaq 0x31d26(%rip), %rdi     # 0x40457
movb $0x2, %al
callq 0x3060
movq 0x90(%r15), %rsi
movq 0x98(%r15), %rdx
leaq 0x31d32(%rip), %rdi     # 0x4047f
xorl %eax, %eax
callq 0x3060
movq 0xa0(%r15), %rsi
movq 0xa8(%r15), %rdx
leaq 0x31d47(%rip), %rdi     # 0x404b0
xorl %eax, %eax
callq 0x3060
movq %r15, %rdi
callq 0x3350
movq %r14, %rdi
callq 0x22e78
movq %rbx, %rdi
callq 0x20aae
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3f9b
movl $0x1, %ebp
jmp 0xe788
leaq 0x2f9ad(%rip), %rdi     # 0x3e159
leaq 0x31b66(%rip), %rsi     # 0x40319
leaq 0x31b6a(%rip), %rcx     # 0x40324
movl $0x3b, %edx
callq 0x31b0