// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_index.c
// Function: bam_idxstats
int bam_idxstats(int argc, char *argv[])
{
	bam_index_t *idx;
	bam_header_t *header;
	bamFile fp;
	int i;
	if (argc < 2) {
		fprintf(stderr, "Usage: samtools idxstats <in.bam>\n");
		return 1;
	}
	fp = bam_open(argv[1], "r");
	if (fp == 0) { fprintf(stderr, "[%s] fail to open BAM.\n", __func__); return 1; }
	header = bam_header_read(fp);
	bam_close(fp);
	idx = bam_index_load(argv[1]);
	if (idx == 0) { fprintf(stderr, "[%s] fail to load the index.\n", __func__); return 1; }
	for (i = 0; i < idx->n; ++i) {
		khint_t k;
		khash_t(i) *h = idx->index[i];
		printf("%s\t%d", header->target_name[i], header->target_len[i]);
		k = kh_get(i, h, BAM_MAX_BIN);
		if (k != kh_end(h))
			printf("\t%llu\t%llu", (long long)kh_val(h, k).list[1].u, (long long)kh_val(h, k).list[1].v);
		else printf("\t0\t0");
		putchar('\n');
	}
	printf("*\t0\t0\t%llu\n", (long long)idx->n_no_coor);
	bam_header_destroy(header);
	bam_index_destroy(idx);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x1, %edi
jle 0x10a6a
movq %rsi, %r14
movq 0x8(%rsi), %rdi
leaq 0xc033(%rip), %rsi      # 0x1c926
callq 0x17710
testq %rax, %rax
je 0x10a71
movq %rax, %r15
movq %rax, %rdi
callq 0x9bfb
movq %rax, %rbx
movq %r15, %rdi
callq 0x18719
movq 0x8(%r14), %rdi
callq 0x10734
testq %rax, %rax
je 0x10a78
movq %rax, (%rsp)
movslq (%rax), %rbp
testq %rbp, %rbp
jle 0x10a31
movq (%rsp), %rax
movq 0x10(%rax), %r12
xorl %r14d, %r14d
xorl %r13d, %r13d
movq (%r12,%r13,8), %r15
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
movq (%rax,%r13,8), %rsi
movl (%rcx,%r13,4), %edx
leaq 0xbbea(%rip), %rdi      # 0x1c54c
xorl %eax, %eax
callq 0x3210
movl (%r15), %edi
movl $0x0, %eax
testl %edi, %edi
je 0x109e2
movl $0x924a, %eax           # imm = 0x924A
xorl %edx, %edx
divl %edi
movl %edx, %esi
leal -0x1(%rdi), %ecx
movl $0x924a, %eax           # imm = 0x924A
xorl %edx, %edx
divl %ecx
incl %edx
movq 0x10(%r15), %r8
movl %esi, %eax
movl %eax, %ecx
shrl $0x4, %ecx
movl (%r8,%rcx,4), %r9d
leal (%rax,%rax), %ecx
andl $0x1e, %ecx
movl %r9d, %r10d
shrl %cl, %r10d
testb $0x2, %r10b
jne 0x109d8
testb $0x1, %r10b
jne 0x109c6
movq 0x18(%r15), %r10
movl %eax, %r11d
cmpl $0x924a, (%r10,%r11,4)  # imm = 0x924A
je 0x109d8
addl %edx, %eax
cmpl %edi, %eax
movl %edi, %ecx
cmovbl %r14d, %ecx
subl %ecx, %eax
cmpl %esi, %eax
jne 0x10994
jmp 0x109e6
shrl %cl, %r9d
testb $0x3, %r9b
cmovnel %edi, %eax
cmpl %edi, %eax
jne 0x109f6
leaq 0xbb70(%rip), %rdi      # 0x1c55d
xorl %eax, %eax
callq 0x3210
jmp 0x10a1b
movq 0x20(%r15), %rcx
movl %eax, %eax
shlq $0x4, %rax
movq 0x8(%rcx,%rax), %rax
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdx
leaq 0xbb3e(%rip), %rdi      # 0x1c552
xorl %eax, %eax
callq 0x3210
movl $0xa, %edi
callq 0x3070
incq %r13
cmpq %rbp, %r13
jb 0x10947
movq (%rsp), %r14
movq 0x8(%r14), %rsi
leaq 0xbb22(%rip), %rdi      # 0x1c562
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x3210
movq %rbx, %rdi
callq 0x9b77
movq %r14, %rdi
callq 0xfea9
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x41f9
jmp 0x10a7d
callq 0x41da
jmp 0x10a7d
callq 0x41bb
movl $0x1, %ebp
jmp 0x10a59