// File: /workspace/github_c_makefile_star2_O1/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 0x72e9
cmpl $0x1, %esi
je 0x7267
testl %esi, %esi
jne 0x73ee
leaq 0x770b(%rip), %rsi      # 0xe910
callq 0x3abc
movq %rax, %r14
testq %rax, %rax
je 0x7387
leaq 0x8(%rsp), %rsi
movl $0x4, %edx
movq %r14, %rdi
callq 0x3e92
leaq 0x10(%rsp), %rbx
movl $0xc, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3e92
movl 0x8(%rbx), %ebx
testq %rbx, %rbx
je 0x7389
movq %rbx, %rdi
callq 0x22a0
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x3e92
jmp 0x738c
leaq 0x70c2(%rip), %rsi      # 0xe330
callq 0x2350
movq %rax, %r14
testq %rax, %rax
je 0x7387
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
movl $0x4, %edx
movq %r14, %rcx
callq 0x20e0
leaq 0x10(%rsp), %rbx
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rcx
callq 0x20e0
movl (%rbx), %edi
movl $0x1, %esi
xorl %edx, %edx
movl $0xe, %ecx
movl $0x5, %r8d
callq 0x5e3a
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x73f3
movq %r14, %rdi
callq 0x2140
jmp 0x73d8
leaq 0x7620(%rip), %rsi      # 0xe910
callq 0x3abc
movq %rax, %r14
testq %rax, %rax
je 0x7387
leaq 0x8(%rsp), %rsi
movl $0x4, %edx
movq %r14, %rdi
callq 0x3e92
leaq 0x10(%rsp), %r15
movl $0x20, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3e92
movl (%r15), %edi
movl $0x2, %esi
xorl %edx, %edx
movl $0xe, %ecx
movl $0x5, %r8d
callq 0x5e3a
movq %rax, %rbx
movl 0x1c(%r15), %r12d
leal 0x1c(%r12), %edi
movl %edi, 0x10(%rax)
callq 0x22a0
movq %rax, 0x38(%rbx)
movups 0x4(%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm0, (%rax)
movups %xmm1, 0xc(%rax)
leaq 0x1c(%rax), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x3e92
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2, %edx
jmp 0x73cb
jmp 0x73d8
xorl %r15d, %r15d
leaq 0xc(%rsp), %rbx
movl $0x4, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3e92
movl (%rbx), %edi
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x5e3a
movq %rax, %rbx
movl 0x18(%rsp), %eax
movl %eax, 0x10(%rbx)
movq %r15, 0x38(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x73f3
movq %r14, %rdi
callq 0x4433
testq %r14, %r14
jne 0x73df
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x2060