// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/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:
subq $0x38, %rsp
movl %edi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
cmpl $0x2, 0x30(%rsp)
jge 0x473039
movq 0x188fad(%rip), %rax    # 0x5fbfc8
movq (%rax), %rdi
leaq 0x107361(%rip), %rsi    # 0x57a386
movb $0x0, %al
callq 0x33960
movl $0x1, 0x34(%rsp)
jmp 0x473206
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x8c2f2(%rip), %rsi     # 0x4ff33b
callq 0x464500
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
jne 0x473087
movq 0x188f66(%rip), %rax    # 0x5fbfc8
movq (%rax), %rdi
leaq 0x10733d(%rip), %rsi    # 0x57a3a9
leaq 0x10734e(%rip), %rdx    # 0x57a3c1
movb $0x0, %al
callq 0x33960
movl $0x1, 0x34(%rsp)
jmp 0x473206
movq 0x10(%rsp), %rdi
callq 0x4691e0
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rdi
callq 0x4646c0
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x472ce0
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x4730e7
movq 0x188f06(%rip), %rax    # 0x5fbfc8
movq (%rax), %rdi
leaq 0x107302(%rip), %rsi    # 0x57a3ce
leaq 0x1072ee(%rip), %rdx    # 0x57a3c1
movb $0x0, %al
callq 0x33960
movl $0x1, 0x34(%rsp)
jmp 0x473206
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
movq 0x20(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x4731d3
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0xc(%rsp), %rcx
movl (%rax,%rcx,4), %edx
leaq 0x1072ac(%rip), %rdi    # 0x57a3ec
movb $0x0, %al
callq 0x2f300
movq (%rsp), %rdi
movl $0x924a, %esi           # imm = 0x924A
callq 0x473210
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
movq (%rsp), %rcx
cmpl (%rcx), %eax
je 0x4731ab
movq (%rsp), %rax
movq 0x20(%rax), %rax
movl 0x8(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rsi
movq (%rsp), %rax
movq 0x20(%rax), %rax
movl 0x8(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rdx
leaq 0x107250(%rip), %rdi    # 0x57a3f2
movb $0x0, %al
callq 0x2f300
jmp 0x4731b9
leaq 0x10724b(%rip), %rdi    # 0x57a3fd
movb $0x0, %al
callq 0x2f300
movl $0xa, %edi
callq 0x2ff90
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x4730ef
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x10721f(%rip), %rdi    # 0x57a402
movb $0x0, %al
callq 0x2f300
movq 0x18(%rsp), %rdi
callq 0x469100
movq 0x20(%rsp), %rdi
callq 0x472020
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nop