// File: /workspace/github_c_makefile_star2_O1/lh3[P]bgt/bgt.c
// Function: bgt_open
bgt_file_t *bgt_open(const char *prefix)
{
	char *fn = 0;
	bgt_file_t *bf = 0;
	BGZF *fp = 0;

	fn = (char*)malloc(strlen(prefix) + 9);
	sprintf(fn, "%s.bcf", prefix);
	fp = bgzf_open(fn, "rb");
	if (fp == 0) goto bgt_open_err;
	bf = (bgt_file_t*)calloc(1, sizeof(bgt_file_t));
	bf->h0 = bcf_hdr_read(fp);
	if (bf->h0 == 0) goto bgt_open_err;
	bf->idx = bcf_index_load(fn);
	if (bf->idx == 0) goto bgt_open_err;
	sprintf(fn, "%s.spl", prefix);
	bf->f = fmf_read(fn);
	if (bf->f == 0) goto bgt_open_err;
	bf->prefix = strdup(prefix);
	bgzf_close(fp);
	free(fn);
	bf->mgs = (int32_t*)calloc(bf->f->n_rows, 4);
	bgt_set_mgs(bf);
	return bf;

bgt_open_err:
	free(fn);
	if (fp) bgzf_close(fp);
	if (bf) bgt_close(bf);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r12
callq 0x2170
leaq 0x9(%rax), %rdi
callq 0x22e0
movq %rax, %r14
leaq 0x879a(%rip), %rsi      # 0x1e358
xorl %ebx, %ebx
movq %rax, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x23f0
leaq 0x944c(%rip), %rsi      # 0x1f020
movq %r14, %rdi
callq 0x434c
movq %rax, %r15
testq %rax, %rax
je 0x15cd4
movl $0x1, %edi
movl $0x28, %esi
callq 0x2220
movq %rax, %rbx
movq %r15, %rdi
callq 0xb8f8
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x15cd4
movq %r14, %rdi
xorl %esi, %esi
callq 0x959d
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x15cd4
leaq 0x8713(%rip), %rsi      # 0x1e340
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x23f0
movq %r14, %rdi
callq 0x9a08
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x15cd4
movq %r12, %rdi
callq 0x2420
movq %rax, (%rbx)
movq %r15, %rdi
callq 0x5040
movq %r14, %rdi
callq 0x2050
movq 0x8(%rbx), %r12
movslq 0x20(%r12), %r15
movl $0x4, %esi
movq %r15, %rdi
callq 0x2220
movq %rax, %r14
movq %rax, 0x20(%rbx)
testq %r15, %r15
jle 0x15ca3
xorl %eax, %eax
movl $0xffffffff, (%r14,%rax,4) # imm = 0xFFFFFFFF
incq %rax
movslq 0x20(%r12), %rcx
cmpq %rcx, %rax
jl 0x15c8e
movl (%r12), %ebp
testl %ebp, %ebp
jle 0x15d0a
movq 0x8(%r12), %r15
xorl %r13d, %r13d
movq (%r15,%r13,8), %rdi
leaq 0xa02c(%rip), %rsi      # 0x1fcea
callq 0x2230
testl %eax, %eax
je 0x15d0d
incq %r13
cmpq %r13, %rbp
jne 0x15cb3
movl %ebp, %r13d
jmp 0x15d0d
movq %r14, %rdi
callq 0x2050
testq %r15, %r15
je 0x15ce9
movq %r15, %rdi
callq 0x5040
testq %rbx, %rbx
je 0x15cf6
movq %rbx, %rdi
callq 0x15d86
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
cmpl %ebp, %r13d
je 0x15cf8
cmpl $0x0, 0x20(%r12)
jle 0x15cf8
movq 0x28(%r12), %rax
xorl %ecx, %ecx
leaq (%rcx,%rcx,2), %rdx
cmpl $0x0, 0x8(%rax,%rdx,8)
jle 0x15d74
leaq (%rax,%rdx,8), %rdx
movq 0x10(%rdx), %rsi
xorl %edi, %edi
movl (%rsi,%rdi,8), %r8d
movl %r8d, %r9d
andl $0xfffffff, %r9d        # imm = 0xFFFFFFF
xorl %r13d, %r9d
andl $0xf0000000, %r8d       # imm = 0xF0000000
xorl $0x10000000, %r8d       # imm = 0x10000000
orl %r9d, %r8d
jne 0x15d68
movl 0x4(%rsi,%rdi,8), %r8d
testl %r8d, %r8d
js 0x15d68
movl %r8d, (%r14,%rcx,4)
incq %rdi
movslq 0x8(%rdx), %r8
cmpq %r8, %rdi
jl 0x15d36
incq %rcx
movslq 0x20(%r12), %rdx
cmpq %rdx, %rcx
jl 0x15d21
jmp 0x15cf8