// File: /workspace/github_c_makefile_star2_O3/DReichLab[P]adna/hts.c
// Function: hts_idx_load_direct
hts_idx_t *hts_idx_load_direct(const char *fn, int fmt)
{
	uint8_t magic[4];
	int i, is_be;
	hts_idx_t *idx;
	is_be = ed_is_big();
	if (fmt == HTS_FMT_CSI) {
		BGZF *fp;
		uint32_t x[3], n;
		uint8_t *meta = 0;
		if ((fp = bgzf_open(fn, "r")) == 0) return 0;
		bgzf_read(fp, magic, 4);
		bgzf_read(fp, x, 12);
		if (is_be) for (i = 0; i < 3; ++i) ed_swap_4p(&x[i]);
		if (x[2]) {
			meta = (uint8_t*)malloc(x[2]);
			bgzf_read(fp, meta, x[2]);
		}
		bgzf_read(fp, &n, 4);
		if (is_be) ed_swap_4p(&n);
		idx = hts_idx_init(n, fmt, 0, x[0], x[1]);
		idx->l_meta = x[2];
		idx->meta = meta;
		hts_idx_load_core(idx, fp, HTS_FMT_CSI);
		bgzf_close(fp);
	} else if (fmt == HTS_FMT_TBI) {
		BGZF *fp;
		uint32_t x[8];
		if ((fp = bgzf_open(fn, "r")) == 0) return 0;
		bgzf_read(fp, magic, 4);
		bgzf_read(fp, x, 32);
		if (is_be) for (i = 0; i < 8; ++i) ed_swap_4p(&x[i]);
		idx = hts_idx_init(x[0], fmt, 0, 14, 5);
		idx->l_meta = 28 + x[7];
		idx->meta = (uint8_t*)malloc(idx->l_meta);
		memcpy(idx->meta, &x[1], 28);
		bgzf_read(fp, idx->meta + 28, x[7]);
		hts_idx_load_core(idx, fp, HTS_FMT_TBI);
		bgzf_close(fp);
	} else if (fmt == HTS_FMT_BAI) {
		uint32_t n;
#ifdef _USE_KURL
		kurl_t *fp;
		if ((fp = kurl_open(fn, 0)) == 0) return 0;
		kurl_read(fp, magic, 4);
		kurl_read(fp, &n, 4);
#else
		FILE *fp;
		if ((fp = fopen(fn, "rb")) == 0) return 0;
		fread(magic, 1, 4, fp);
		fread(&n, 4, 1, fp);
#endif
		if (is_be) ed_swap_4p(&n);
		idx = hts_idx_init(n, fmt, 0, 14, 5);
		hts_idx_load_core(idx, fp, HTS_FMT_BAI);
#ifdef _USE_KURL
		kurl_close(fp);
#else
		fclose(fp);
#endif
	} else abort();
	return idx;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpl $0x2, %esi
je 0x7505
cmpl $0x1, %esi
je 0x7482
testl %esi, %esi
jne 0x7608
leaq 0x756b(%rip), %rsi      # 0xe98a
callq 0x3ad0
testq %rax, %rax
je 0x75a3
movq %rax, %rbx
leaq 0x8(%rsp), %rsi
movl $0x4, %edx
movq %rax, %rdi
callq 0x3e73
leaq 0x10(%rsp), %r14
movl $0xc, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3e73
movl 0x8(%r14), %r14d
testq %r14, %r14
je 0x75a8
movq %r14, %rdi
callq 0x22a0
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x3e73
jmp 0x75ab
leaq 0x6f07(%rip), %rsi      # 0xe390
callq 0x2350
testq %rax, %rax
je 0x75a3
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %rax, %rcx
callq 0x20e0
leaq 0x10(%rsp), %r14
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x20e0
movl (%r14), %edi
movl $0x1, %esi
xorl %edx, %edx
movl $0xe, %ecx
movl $0x5, %r8d
callq 0x5f20
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x760d
movq %rbx, %rdi
callq 0x2140
jmp 0x75f9
leaq 0x747e(%rip), %rsi      # 0xe98a
callq 0x3ad0
testq %rax, %rax
je 0x75a3
movq %rax, %rbx
leaq 0x8(%rsp), %rsi
movl $0x4, %edx
movq %rax, %rdi
callq 0x3e73
leaq 0x10(%rsp), %r15
movl $0x20, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3e73
movl (%r15), %edi
movl $0x2, %esi
xorl %edx, %edx
movl $0xe, %ecx
movl $0x5, %r8d
callq 0x5f20
movq %rax, %r14
movl 0x1c(%r15), %r12d
leal 0x1c(%r12), %edi
movl %edi, 0x10(%rax)
callq 0x22a0
movq %rax, 0x38(%r14)
movups 0x4(%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm0, (%rax)
movups %xmm1, 0xc(%rax)
leaq 0x1c(%rax), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x3e73
movq %r14, %rdi
movq %rbx, %rsi
movl $0x2, %edx
jmp 0x75ec
xorl %r14d, %r14d
jmp 0x75f9
xorl %r15d, %r15d
leaq 0xc(%rsp), %r14
movl $0x4, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3e73
movl (%r14), %edi
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x5f20
movq %rax, %r14
movl 0x18(%rsp), %eax
movl %eax, 0x10(%r14)
movq %r15, 0x38(%r14)
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x760d
movq %rbx, %rdi
callq 0x44e0
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x2060