// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r14
cmpl $0x0, 0x14(%rdi)
jle 0x7881
xorl %r15d, %r15d
movq %r14, 0x18(%rsp)
movq %r12, 0x8(%rsp)
movq %r15, %rbx
shlq $0x4, %rbx
addq 0x30(%r14), %rbx
movl $0x1, %edi
movl $0x28, %esi
callq 0x21f0
movq 0x28(%r14), %rcx
movq %rax, 0x28(%rsp)
movq %rax, (%rcx,%r15,8)
cmpl $0x1, %ebp
movq %r15, 0x20(%rsp)
movq %rbx, 0x10(%rsp)
jne 0x7687
movl $0x1, %esi
movl $0x4, %edx
movq %rsp, %rdi
movq %r12, %rcx
callq 0x20e0
jmp 0x7697
movl $0x4, %edx
movq %r12, %rdi
movq %rsp, %rsi
callq 0x3e73
cmpl $0x0, (%rsp)
jle 0x77ac
xorl %r13d, %r13d
cmpl $0x1, %ebp
jne 0x76c2
movl $0x1, %esi
movl $0x4, %edx
leaq 0x4(%rsp), %rdi
movq %r12, %rcx
callq 0x20e0
jmp 0x76d4
movl $0x4, %edx
movq %r12, %rdi
leaq 0x4(%rsp), %rsi
callq 0x3e73
movl 0x4(%rsp), %esi
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
leaq 0x34(%rsp), %rdx
callq 0x8732
movq 0x20(%rbx), %r12
movl %eax, %eax
leaq (%rax,%rax,2), %r14
leaq (%r12,%r14,8), %rsi
addq $0x8, %rsi
leaq (%r12,%r14,8), %r15
addq $0x4, %r15
testl %ebp, %ebp
je 0x7730
movq $0x0, (%rsi)
cmpl $0x1, %ebp
movq 0x8(%rsp), %rbx
jne 0x7742
movl $0x1, %esi
movl $0x4, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x20e0
jmp 0x7752
movl $0x8, %edx
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x3e73
movl $0x4, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3e73
leaq (%r12,%r14,8), %r14
movslq 0x4(%r14), %r15
movl %r15d, (%r14)
shlq $0x4, %r15
movq %r15, %rdi
callq 0x22a0
movq %rax, 0x10(%r14)
cmpl $0x1, %ebp
jne 0x778c
movl $0x1, %esi
movq %rax, %rdi
movq %r15, %rdx
movq 0x8(%rsp), %r12
movq %r12, %rcx
callq 0x20e0
jmp 0x779f
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x3e73
incl %r13d
cmpl (%rsp), %r13d
jl 0x76a4
testl %ebp, %ebp
movq 0x18(%rsp), %r14
movq 0x20(%rsp), %r15
je 0x7871
cmpl $0x1, %ebp
jne 0x77df
movl $0x1, %esi
movl $0x4, %edx
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r12, %rcx
callq 0x20e0
jmp 0x77f4
movl $0x4, %edx
movq %r12, %rdi
movq 0x10(%rsp), %r13
movq %r13, %rsi
callq 0x3e73
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 0x7828
movl $0x1, %esi
movq %rax, %rdi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x20e0
jmp 0x7836
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x3e73
movslq (%r13), %rax
cmpq $0x2, %rax
jl 0x7861
movq 0x8(%r13), %rcx
movl $0x1, %edx
cmpq $0x0, (%rcx,%rdx,8)
jne 0x7859
movq -0x8(%rcx,%rdx,8), %rsi
movq %rsi, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x7849
movq %r14, %rdi
movl %r15d, %esi
movl $0x1, %edx
callq 0x66f5
incq %r15
movslq 0x14(%r14), %rax
cmpq %rax, %r15
jl 0x763a
addq $0x20, %r14
cmpl $0x1, %ebp
jne 0x78a1
movl $0x1, %esi
movl $0x8, %edx
movq %r14, %rdi
movq %r12, %rcx
callq 0x20e0
jmp 0x78b1
movl $0x8, %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x3e73
cmpq $0x8, %rax
je 0x78be
movq $0x0, (%r14)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq