// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 in total\n", s->n_reads);
	printf("%lld QC failure\n", s->n_qcfail);
	printf("%lld duplicates\n", s->n_dup);
	printf("%lld mapped (%.2f%%)\n", s->n_mapped, (float)s->n_mapped / s->n_reads * 100.0);
	printf("%lld paired in sequencing\n", s->n_pair_all);
	printf("%lld read1\n", s->n_read1);
	printf("%lld read2\n", s->n_read2);
	printf("%lld properly paired (%.2f%%)\n", s->n_pair_good, (float)s->n_pair_good / s->n_pair_all * 100.0);
	printf("%lld with itself and mate mapped\n", s->n_pair_map);
	printf("%lld singletons (%.2f%%)\n", s->n_sgltn, (float)s->n_sgltn / s->n_pair_all * 100.0);
	printf("%lld with mate mapped to a different chr\n", s->n_diffchr);
	printf("%lld with mate mapped to a different chr (mapQ>=5)\n", s->n_diffhigh);
	free(s);
	bam_header_destroy(header);
	bam_close(fp);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq 0x214a3(%rip), %rax     # 0x2efb8
movslq (%rax), %rax
cmpl %edi, %eax
je 0xdce7
movq (%rsi,%rax,8), %rbx
leaq 0x1728b(%rip), %rsi     # 0x24db6
movq %rbx, %rdi
callq 0x34e0
testl %eax, %eax
je 0xdb48
leaq 0x1a489(%rip), %rsi     # 0x27fc7
movq %rbx, %rdi
callq 0xfa04
jmp 0xdb65
movq 0x21481(%rip), %rax     # 0x2efd0
movq (%rax), %rdi
callq 0x3030
leaq 0x1a469(%rip), %rsi     # 0x27fc7
movl %eax, %edi
callq 0xfb6d
movq %rax, %rbx
testq %rax, %rax
je 0xdcf3
movq %rbx, %rdi
callq 0x11d21
movq %rax, %r14
movq %rbx, %rdi
callq 0xd9e0
movq %rax, %r15
movq (%rax), %r12
leaq 0x17fb2(%rip), %rdi     # 0x25b43
xorl %ebp, %ebp
movq %r12, %rsi
xorl %eax, %eax
callq 0x3040
movq 0x40(%r15), %rsi
leaq 0x17faa(%rip), %rdi     # 0x25b52
xorl %eax, %eax
callq 0x3040
movq 0x48(%r15), %rsi
leaq 0x17fa9(%rip), %rdi     # 0x25b63
xorl %eax, %eax
callq 0x3040
movq 0x8(%r15), %rsi
cvtsi2ss %rsi, %xmm0
cvtsi2ss %r12, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x17ed9(%rip), %xmm0    # 0x25ab8
leaq 0x17f8e(%rip), %rdi     # 0x25b74
movb $0x1, %al
callq 0x3040
movq 0x10(%r15), %r12
leaq 0x17f92(%rip), %rdi     # 0x25b8a
movq %r12, %rsi
xorl %eax, %eax
callq 0x3040
movq 0x30(%r15), %rsi
leaq 0x17f98(%rip), %rdi     # 0x25ba5
xorl %eax, %eax
callq 0x3040
movq 0x38(%r15), %rsi
leaq 0x17f92(%rip), %rdi     # 0x25bb1
xorl %eax, %eax
callq 0x3040
movq 0x20(%r15), %rsi
xorps %xmm0, %xmm0
cvtsi2ss %rsi, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %r12, %xmm1
movss %xmm1, 0xc(%rsp)
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x17e68(%rip), %xmm0    # 0x25ab8
leaq 0x17f66(%rip), %rdi     # 0x25bbd
movb $0x1, %al
callq 0x3040
movq 0x18(%r15), %rsi
leaq 0x17f73(%rip), %rdi     # 0x25bdc
xorl %eax, %eax
callq 0x3040
movq 0x28(%r15), %rsi
xorps %xmm0, %xmm0
cvtsi2ss %rsi, %xmm0
divss 0xc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x17e2a(%rip), %xmm0    # 0x25ab8
leaq 0x17f69(%rip), %rdi     # 0x25bfe
movb $0x1, %al
callq 0x3040
movq 0x50(%r15), %rsi
leaq 0x17f71(%rip), %rdi     # 0x25c18
xorl %eax, %eax
callq 0x3040
movq 0x58(%r15), %rsi
leaq 0x17f89(%rip), %rdi     # 0x25c42
xorl %eax, %eax
callq 0x3040
movq %r15, %rdi
callq 0x32c0
movq %r14, %rdi
callq 0x11c9f
movq %rbx, %rdi
callq 0x1050e
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x3c07
movl $0x1, %ebp
jmp 0xdcd8
leaq 0x163c7(%rip), %rdi     # 0x240c1
leaq 0x17e18(%rip), %rsi     # 0x25b19
leaq 0x17e1c(%rip), %rcx     # 0x25b24
movl $0x3b, %edx
callq 0x3140
nop