// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
callq 0xbc50
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xa3ef
movq $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x9577(%rip), %rsi      # 0x1385e
callq 0x4790
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0xa303
movq $0x0, -0x8(%rbp)
jmp 0xa5d5
movq -0x30(%rbp), %rdi
leaq -0x18(%rbp), %rsi
movl $0x4, %edx
callq 0x4fb0
movq -0x30(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
movl $0xc, %edx
callq 0x4fb0
cmpl $0x0, -0x20(%rbp)
je 0xa35b
movl $0x0, -0x1c(%rbp)
cmpl $0x3, -0x1c(%rbp)
jge 0xa359
movslq -0x1c(%rbp), %rax
leaq -0x3c(%rbp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
callq 0x9d80
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xa334
jmp 0xa35b
cmpl $0x0, -0x34(%rbp)
je 0xa381
movl -0x34(%rbp), %eax
movl %eax, %edi
callq 0x22b0
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x34(%rbp), %eax
movl %eax, %edx
callq 0x4fb0
movq -0x30(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movl $0x4, %edx
callq 0x4fb0
cmpl $0x0, -0x20(%rbp)
je 0xa3a2
leaq -0x40(%rbp), %rdi
callq 0x9d80
movl -0x40(%rbp), %edi
movl -0x14(%rbp), %esi
movl -0x3c(%rbp), %ecx
movl -0x38(%rbp), %r8d
xorl %eax, %eax
movl %eax, %edx
callq 0x88d0
movq %rax, -0x28(%rbp)
movl -0x34(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %edx, %edx
callq 0xa5f0
movq -0x30(%rbp), %rdi
callq 0x5a10
jmp 0xa5cd
cmpl $0x2, -0x14(%rbp)
jne 0xa51b
movq -0x10(%rbp), %rdi
leaq 0x945a(%rip), %rsi      # 0x1385e
callq 0x4790
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0xa420
movq $0x0, -0x8(%rbp)
jmp 0xa5d5
movq -0x50(%rbp), %rdi
leaq -0x18(%rbp), %rsi
movl $0x4, %edx
callq 0x4fb0
movq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl $0x20, %edx
callq 0x4fb0
cmpl $0x0, -0x20(%rbp)
je 0xa478
movl $0x0, -0x1c(%rbp)
cmpl $0x8, -0x1c(%rbp)
jge 0xa476
movslq -0x1c(%rbp), %rax
leaq -0x70(%rbp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
callq 0x9d80
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xa451
jmp 0xa478
movl -0x70(%rbp), %edi
movl -0x14(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
movl $0xe, %ecx
movl $0x5, %r8d
callq 0x88d0
movq %rax, -0x28(%rbp)
movl -0x54(%rbp), %ecx
addl $0x1c, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %edi
callq 0x22b0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x6c(%rbp), %rcx
movq %rcx, (%rax)
movq -0x64(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x5c(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl -0x54(%rbp), %ecx
movl %ecx, 0x18(%rax)
movq -0x50(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
addq $0x1c, %rsi
movl -0x54(%rbp), %eax
movl %eax, %edx
callq 0x4fb0
movq -0x28(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl $0x2, %edx
callq 0xa5f0
movq -0x50(%rbp), %rdi
callq 0x5a10
jmp 0xa5cb
cmpl $0x1, -0x14(%rbp)
jne 0xa5c4
movq -0x10(%rbp), %rdi
leaq 0x8df0(%rip), %rsi      # 0x13320
callq 0x2360
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
jne 0xa54c
movq $0x0, -0x8(%rbp)
jmp 0xa5d5
leaq -0x18(%rbp), %rdi
movq -0x80(%rbp), %rcx
movl $0x1, %esi
movl $0x4, %edx
callq 0x20e0
movq -0x80(%rbp), %rcx
leaq -0x74(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x20e0
cmpl $0x0, -0x20(%rbp)
je 0xa589
leaq -0x74(%rbp), %rdi
callq 0x9d80
movl -0x74(%rbp), %edi
movl -0x14(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
movl $0xe, %ecx
movl $0x5, %r8d
callq 0x88d0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x80(%rbp), %rsi
movl $0x1, %edx
callq 0xa5f0
movq -0x80(%rbp), %rdi
callq 0x2140
jmp 0xa5c9
callq 0x2050
jmp 0xa5cb
jmp 0xa5cd
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)