// File: /workspace/github_cpp_makefile_star2_O3/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 0x1ff29(%rip), %rax     # 0x2dfb8
movslq (%rax), %rax
cmpl %edi, %eax
je 0xe25d
movq (%rsi,%rax,8), %rdi
cmpb $0x2d, (%rdi)
jne 0xe0ad
cmpb $0x0, 0x1(%rdi)
je 0xe23b
leaq 0x19013(%rip), %rsi     # 0x270c7
callq 0x10048
movq %rax, %rbx
testq %rax, %rax
je 0xe269
movq %rbx, %rdi
callq 0x12383
movq %rax, %r14
movq %rbx, %rdi
callq 0xde74
movq %rax, %r15
movq (%rax), %r12
leaq 0x16aae(%rip), %rdi     # 0x24b93
xorl %ebp, %ebp
movq %r12, %rsi
xorl %eax, %eax
callq 0x3040
movq 0x40(%r15), %rsi
leaq 0x16aa6(%rip), %rdi     # 0x24ba2
xorl %eax, %eax
callq 0x3040
movq 0x48(%r15), %rsi
leaq 0x16aa5(%rip), %rdi     # 0x24bb3
xorl %eax, %eax
callq 0x3040
movq 0x8(%r15), %rsi
cvtsi2ss %rsi, %xmm0
cvtsi2ss %r12, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x169d5(%rip), %xmm0    # 0x24b08
leaq 0x16a8a(%rip), %rdi     # 0x24bc4
movb $0x1, %al
callq 0x3040
movq 0x10(%r15), %r12
leaq 0x16a8e(%rip), %rdi     # 0x24bda
movq %r12, %rsi
xorl %eax, %eax
callq 0x3040
movq 0x30(%r15), %rsi
leaq 0x16a94(%rip), %rdi     # 0x24bf5
xorl %eax, %eax
callq 0x3040
movq 0x38(%r15), %rsi
leaq 0x16a8e(%rip), %rdi     # 0x24c01
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 0x16964(%rip), %xmm0    # 0x24b08
leaq 0x16a62(%rip), %rdi     # 0x24c0d
movb $0x1, %al
callq 0x3040
movq 0x18(%r15), %rsi
leaq 0x16a6f(%rip), %rdi     # 0x24c2c
xorl %eax, %eax
callq 0x3040
movq 0x28(%r15), %rsi
xorps %xmm0, %xmm0
cvtsi2ss %rsi, %xmm0
divss 0xc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x16926(%rip), %xmm0    # 0x24b08
leaq 0x16a65(%rip), %rdi     # 0x24c4e
movb $0x1, %al
callq 0x3040
movq 0x50(%r15), %rsi
leaq 0x16a6d(%rip), %rdi     # 0x24c68
xorl %eax, %eax
callq 0x3040
movq 0x58(%r15), %rsi
leaq 0x16a85(%rip), %rdi     # 0x24c92
xorl %eax, %eax
callq 0x3040
movq %r15, %rdi
callq 0x32c0
movq %r14, %rdi
callq 0x122ff
movq %rbx, %rdi
callq 0x10d25
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x1fd8e(%rip), %rax     # 0x2dfd0
movq (%rax), %rdi
callq 0x3030
leaq 0x18e76(%rip), %rsi     # 0x270c7
movl %eax, %edi
callq 0x101a3
jmp 0xe0b9
callq 0x3c07
movl $0x1, %ebp
jmp 0xe22c
leaq 0x14e69(%rip), %rdi     # 0x230d9
leaq 0x168f2(%rip), %rsi     # 0x24b69
leaq 0x168f6(%rip), %rcx     # 0x24b74
movl $0x3b, %edx
callq 0x3140