// File: /workspace/github_c_makefile_star2_O1/DReichLab[P]adna/hts.c
// Function: hts_idx_load_core
static void hts_idx_load_core(hts_idx_t *idx, void *fp, int fmt)
{
	int32_t i, n, is_be;
	int is_bgzf = (fmt != HTS_FMT_BAI);
	is_be = ed_is_big();
	for (i = 0; i < idx->n; ++i) {
		bidx_t *h;
		lidx_t *l = &idx->lidx[i];
		uint32_t key;
		int j, absent;
		hts_bin_t *p;
		h = idx->bidx[i] = kh_init(bin);
		idx_read(is_bgzf, fp, &n, 4);
		if (is_be) ed_swap_4p(&n);
		for (j = 0; j < n; ++j) {
			khint_t k;
			idx_read(is_bgzf, fp, &key, 4);
			if (is_be) ed_swap_4p(&key);
			k = kh_put(bin, h, key, &absent);
			p = &kh_val(h, k);
			if (fmt == HTS_FMT_CSI) {
				idx_read(is_bgzf, fp, &p->loff, 8);
				if (is_be) ed_swap_8p(&p->loff);
			} else p->loff = 0;
			idx_read(is_bgzf, fp, &p->n, 4);
			if (is_be) ed_swap_4p(&p->n);
			p->m = p->n;
			p->list = (hts_pair64_t*)malloc(p->m * 16);
			idx_read(is_bgzf, fp, p->list, p->n<<4);
			if (is_be) swap_bins(p);
		}
		if (fmt != HTS_FMT_CSI) { // load linear index
			int j;
			idx_read(is_bgzf, fp, &l->n, 4);
			if (is_be) ed_swap_4p(&l->n);
			l->m = l->n;
			l->offset = (uint64_t*)malloc(l->n << 3);
			idx_read(is_bgzf, fp, l->offset, l->n << 3);
			if (is_be) for (j = 0; j < l->n; ++j) ed_swap_8p(&l->offset[j]);
			for (j = 1; j < l->n; ++j) // fill missing values; may happen given older samtools and tabix
				if (l->offset[j] == 0) l->offset[j] = l->offset[j-1];
			update_loff(idx, i, 1);
		}
	}
	if (idx_read(is_bgzf, fp, &idx->n_no_coor, 8) != 8) idx->n_no_coor = 0;
	if (is_be) ed_swap_8p(&idx->n_no_coor);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
cmpl $0x0, 0x14(%rdi)
jle 0x7649
xorl %r12d, %r12d
movq %r15, 0x10(%rsp)
movq %r12, %r13
shlq $0x4, %r13
addq 0x30(%r15), %r13
movl $0x1, %edi
movl $0x28, %esi
callq 0x21f0
movq %rax, %rbx
movq 0x28(%r15), %rax
movq %rbx, (%rax,%r12,8)
cmpl $0x1, %ebp
movq %r12, 0x18(%rsp)
movq %r13, 0x8(%rsp)
jne 0x7466
movl $0x1, %esi
movl $0x4, %edx
movq %rsp, %rdi
movq %r14, %rcx
callq 0x20e0
jmp 0x7476
movl $0x4, %edx
movq %r14, %rdi
movq %rsp, %rsi
callq 0x3e92
cmpl $0x0, (%rsp)
jle 0x7574
xorl %r13d, %r13d
cmpl $0x1, %ebp
jne 0x74a1
movl $0x1, %esi
movl $0x4, %edx
leaq 0x4(%rsp), %rdi
movq %r14, %rcx
callq 0x20e0
jmp 0x74b3
movl $0x4, %edx
movq %r14, %rdi
leaq 0x4(%rsp), %rsi
callq 0x3e92
movl 0x4(%rsp), %esi
movq %rbx, %rdi
leaq 0x24(%rsp), %rdx
callq 0x851b
movq 0x20(%rbx), %r15
movl %eax, %eax
leaq (%rax,%rax,2), %r12
leaq (%r15,%r12,8), %rsi
addq $0x8, %rsi
testl %ebp, %ebp
je 0x74e3
movq $0x0, (%rsi)
jmp 0x74f0
movl $0x8, %edx
movq %r14, %rdi
callq 0x3e92
leaq (%r15,%r12,8), %r12
leaq 0x4(%r12), %rax
cmpl $0x1, %ebp
jne 0x7515
movl $0x1, %esi
movl $0x4, %edx
movq %rax, %rdi
movq %r14, %rcx
callq 0x20e0
jmp 0x7525
movl $0x4, %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x3e92
movslq 0x4(%r12), %r15
movl %r15d, (%r12)
shlq $0x4, %r15
movq %r15, %rdi
callq 0x22a0
movq %rax, 0x10(%r12)
cmpl $0x1, %ebp
jne 0x7559
movl $0x1, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x20e0
jmp 0x7567
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x3e92
incl %r13d
cmpl (%rsp), %r13d
jl 0x7483
testl %ebp, %ebp
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
je 0x7639
cmpl $0x1, %ebp
jne 0x75a7
movl $0x1, %esi
movl $0x4, %edx
movq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rcx
callq 0x20e0
jmp 0x75bc
movl $0x4, %edx
movq %r14, %rdi
movq 0x8(%rsp), %r13
movq %r13, %rsi
callq 0x3e92
movl (%r13), %eax
movl %eax, 0x4(%r13)
shll $0x3, %eax
movslq %eax, %rbx
movq %rbx, %rdi
callq 0x22a0
movq %rax, 0x8(%r13)
cmpl $0x1, %ebp
jne 0x75f0
movl $0x1, %esi
movq %rax, %rdi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x20e0
jmp 0x75fe
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x3e92
movslq (%r13), %rax
cmpq $0x2, %rax
jl 0x7629
movq 0x8(%r13), %rcx
movl $0x1, %edx
cmpq $0x0, (%rcx,%rdx,8)
jne 0x7621
movq -0x8(%rcx,%rdx,8), %rsi
movq %rsi, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x7611
movq %r15, %rdi
movl %r12d, %esi
movl $0x1, %edx
callq 0x6531
incq %r12
movslq 0x14(%r15), %rax
cmpq %rax, %r12
jl 0x741b
addq $0x20, %r15
cmpl $0x1, %ebp
jne 0x7669
movl $0x1, %esi
movl $0x8, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x20e0
jmp 0x7679
movl $0x8, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3e92
cmpq $0x8, %rax
je 0x7686
movq $0x0, (%r15)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq