// File: /workspace/github_c_makefile_star2_O0/lh3[P]bgt/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;
	char magic[4];
	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);
	// FIXME: NOT WORKING ON BIG ENDIAN!!!
	if (idx_read(is_bgzf, fp, magic, 4) == 4 && strncmp(magic, "RNI\1", 4) == 0) {
		idx_read(is_bgzf, fp, &idx->n_rec, 8);
		idx_read(is_bgzf, fp, &idx->rec_shift, 4);
		idx_read(is_bgzf, fp, &idx->ridx.n, 4);
		idx->ridx.m = idx->ridx.n;
		idx->ridx.offset = (uint64_t*)malloc(idx->ridx.m * 8);
		idx_read(is_bgzf, fp, idx->ridx.offset, idx->ridx.n * 8);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x28(%rbp)
callq 0xc9b0
movl %eax, -0x20(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0xb4e6
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
callq 0xd280
movq -0x8(%rbp), %rcx
movq 0x30(%rcx), %rcx
movslq -0x18(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
movq %rax, -0x30(%rbp)
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq -0x1c(%rbp), %rdx
movl $0x4, %ecx
callq 0xd460
cmpl $0x0, -0x20(%rbp)
je 0xb285
leaq -0x1c(%rbp), %rdi
callq 0xa980
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0xb3ba
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
movl $0x4, %ecx
callq 0xd460
cmpl $0x0, -0x20(%rbp)
je 0xb2bc
leaq -0x3c(%rbp), %rdi
callq 0xa980
movq -0x30(%rbp), %rdi
movl -0x3c(%rbp), %esi
leaq -0x44(%rbp), %rdx
callq 0xc9d0
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x54(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xb319
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq $0x8, %rdx
movl $0x8, %ecx
callq 0xd460
cmpl $0x0, -0x20(%rbp)
je 0xb317
movq -0x50(%rbp), %rdi
addq $0x8, %rdi
callq 0xd3b0
jmp 0xb325
movq -0x50(%rbp), %rax
movq $0x0, 0x8(%rax)
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq $0x4, %rdx
movl $0x4, %ecx
callq 0xd460
cmpl $0x0, -0x20(%rbp)
je 0xb351
movq -0x50(%rbp), %rdi
addq $0x4, %rdi
callq 0xa980
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movl (%rax), %eax
shll $0x4, %eax
movslq %eax, %rdi
callq 0x22f0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
shll $0x4, %eax
movslq %eax, %rcx
callq 0xd460
cmpl $0x0, -0x20(%rbp)
je 0xb3aa
movq -0x50(%rbp), %rdi
callq 0xd340
jmp 0xb3ac
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xb28c
cmpl $0x0, -0x14(%rbp)
je 0xb4d6
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl $0x4, %ecx
callq 0xd460
cmpl $0x0, -0x20(%rbp)
je 0xb3e8
movq -0x38(%rbp), %rdi
callq 0xa980
movq -0x38(%rbp), %rax
movl (%rax), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x38(%rbp), %rax
movl (%rax), %eax
shll $0x3, %eax
movslq %eax, %rdi
callq 0x22f0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x38(%rbp), %rax
movl (%rax), %eax
shll $0x3, %eax
movslq %eax, %rcx
callq 0xd460
cmpl $0x0, -0x20(%rbp)
je 0xb46e
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xb46c
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movslq -0x58(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0xd3b0
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0xb43e
jmp 0xb46e
movl $0x1, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xb4c5
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x58(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0xb4b8
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x58(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x58(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xb4ba
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0xb475
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movl $0x1, %edx
callq 0x96a0
jmp 0xb4d8
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xb221
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x8(%rbp), %rdx
addq $0x20, %rdx
movl $0x8, %ecx
callq 0xd460
cmpq $0x8, %rax
je 0xb511
movq -0x8(%rbp), %rax
movq $0x0, 0x20(%rax)
cmpl $0x0, -0x20(%rbp)
je 0xb524
movq -0x8(%rbp), %rdi
addq $0x20, %rdi
callq 0xd3b0
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq -0x24(%rbp), %rdx
movl $0x4, %ecx
callq 0xd460
cmpq $0x4, %rax
jne 0xb5f8
leaq -0x24(%rbp), %rdi
leaq 0x1caaf(%rip), %rsi     # 0x27ffd
movl $0x4, %edx
callq 0x2080
cmpl $0x0, %eax
jne 0xb5f8
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x8(%rbp), %rdx
addq $0x28, %rdx
movl $0x8, %ecx
callq 0xd460
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x8(%rbp), %rdx
addq $0x10, %rdx
movl $0x4, %ecx
callq 0xd460
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x8(%rbp), %rdx
addq $0x48, %rdx
movl $0x4, %ecx
callq 0xd460
movq -0x8(%rbp), %rax
movl 0x48(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x4c(%rax)
movq -0x8(%rbp), %rax
movl 0x4c(%rax), %eax
shll $0x3, %eax
movslq %eax, %rdi
callq 0x22f0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x50(%rax)
movl -0x28(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdx
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
shll $0x3, %eax
movslq %eax, %rcx
callq 0xd460
addq $0x60, %rsp
popq %rbp
retq
nop