// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movq %rdi, %r15
callq 0x2170
leaq 0x9(%rax), %rdi
callq 0x22e0
movq %rax, %r14
leaq 0x8263(%rip), %rsi      # 0x1e358
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x23f0
leaq 0x8f57(%rip), %rsi      # 0x1f060
movq %r14, %rdi
callq 0x43f4
testq %rax, %rax
je 0x16315
movq %rax, %r13
movl $0x1, %edi
movl $0x28, %esi
callq 0x2220
movq %rax, %rbx
movq %r13, %rdi
callq 0xba37
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x162fb
movq %r14, %rdi
xorl %esi, %esi
callq 0x9839
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x162fb
leaq 0x81de(%rip), %rsi      # 0x1e340
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x23f0
movq %r14, %rdi
callq 0x9c9c
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x162fb
movq %rax, %rbp
movq %r15, %rdi
callq 0x2420
movq %rax, (%rbx)
movq %r13, %rdi
callq 0x542d
movq %r14, %rdi
callq 0x2050
movslq 0x20(%rbp), %r14
movl $0x4, %esi
movq %r14, %rdi
callq 0x2220
movq %rax, %r15
movq %rax, 0x20(%rbx)
testq %r14, %r14
jle 0x162c1
leal 0x3(%r14), %eax
leaq -0x1(%r14), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %eax
shlq $0x4, %rax
movdqa 0x8c6c(%rip), %xmm1     # 0x1ee50
movdqa 0x8c74(%rip), %xmm2     # 0x1ee60
xorl %ecx, %ecx
movdqa 0x8c7a(%rip), %xmm3     # 0x1ee70
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x8c7a(%rip), %xmm5     # 0x1ee80
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edx
notl %edx
testb $0x1, %dl
je 0x16242
movl $0xffffffff, (%r15,%rcx) # imm = 0xFFFFFFFF
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x16259
movl $0xffffffff, 0x4(%r15,%rcx) # imm = 0xFFFFFFFF
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edx
testb $0x1, %dl
je 0x16299
movl $0xffffffff, 0x8(%r15,%rcx) # imm = 0xFFFFFFFF
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x162ac
movl $0xffffffff, 0xc(%r15,%rcx) # imm = 0xFFFFFFFF
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x16206
movslq (%rbp), %r12
testq %r12, %r12
movq %rbp, 0x10(%rsp)
jle 0x16331
movq %r14, 0x8(%rsp)
movq 0x8(%rbp), %r14
xorl %ebp, %ebp
leaq 0x9a29(%rip), %r13      # 0x1fd0a
movq (%r14,%rbp,8), %rdi
movq %r13, %rsi
callq 0x2230
testl %eax, %eax
je 0x16335
incq %rbp
cmpq %rbp, %r12
jne 0x162e1
jmp 0x1631f
movq %r14, %rdi
callq 0x2050
movq %r13, %rdi
callq 0x542d
movq %rbx, %rdi
callq 0x163b9
jmp 0x1631d
movq %r14, %rdi
callq 0x2050
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0x1633a
movq 0x8(%rsp), %r14
testl %r14d, %r14d
setle %al
cmpl %r12d, %ebp
sete %cl
orb %al, %cl
jne 0x1631f
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
xorl %ecx, %ecx
leaq (%rcx,%rcx,2), %rsi
movl 0x8(%rax,%rsi,8), %edx
testl %edx, %edx
jle 0x163ac
leaq (%rax,%rsi,8), %rsi
movq 0x10(%rsi), %rdi
xorl %r8d, %r8d
movl (%rdi,%r8,8), %r9d
movl %r9d, %r10d
andl $0xfffffff, %r10d       # imm = 0xFFFFFFF
xorl %ebp, %r10d
andl $0xf0000000, %r9d       # imm = 0xF0000000
xorl $0x10000000, %r9d       # imm = 0x10000000
orl %r10d, %r9d
jne 0x163a1
movl 0x4(%rdi,%r8,8), %r9d
testl %r9d, %r9d
js 0x163a1
movl %r9d, (%r15,%rcx,4)
movl 0x8(%rsi), %edx
incq %r8
movslq %edx, %r9
cmpq %r9, %r8
jl 0x1636c
incq %rcx
cmpq %r14, %rcx
jl 0x16355
jmp 0x1631f