// File: /workspace/github_c_makefile_star2_O2/lh3[P]bgt/bgt.c
// Function: bgtm_set_alleles
int bgtm_set_alleles(bgtm_t *bm, const char *expr, const fmf_t *f, const char *fn)
{
	int i, is_file, n_al = 0;
	bgt_allele_t *al = 0;
	assert(f == 0 || fn == 0);
	is_file = bgt_is_file(expr);
	if (*expr == ':' || *expr == ',' || (*expr != '?' && is_file) || (f == 0 && fn == 0 && is_file)) {
		char **al_str;
		int n;
		al_str = hts_readlines(expr, &n);
		al = (bgt_allele_t*)calloc(n, sizeof(bgt_allele_t));
		for (i = 0; i < n; ++i) {
			if (bgt_al_parse(al_str[i], &al[n_al]) == 0) ++n_al;
			free(al_str[i]);
		}
		free(al_str);
	} else if (f || fn) {
		int err, m_al = 0;
		kexpr_t *ke;
		ke = ke_parse(expr, &err);
		if (err && ke) ke_destroy(ke);
		if (err) return -1;
		if (f) {
			for (i = 0; i < f->n_rows; ++i)
				if (fmf_test(f, i, ke))
					al = add_allele(al, &n_al, &m_al, f->rows[i].name);
		} else {
			fms_t *f;
			const char *s;
			f = fms_open(fn);
			while ((s = fms_read(f, ke, 1)) != 0)
				al = add_allele(al, &n_al, &m_al, s);
			fms_close(f);
		}
		ke_destroy(ke);
	} else return -1;
	if (n_al > 0) {
		int absent, diff_rid = 0;
		int min_pos = INT_MAX, max_pos = INT_MIN;
		khash_t(str) *h;
		kstring_t s = {0,0,0};
		khint_t k;
		h = kh_init(str);
		for (i = 0; i < n_al; ++i) {
			bgt_al_format(&al[i], &s);
			k = kh_put(str, h, s.s, &absent);
			if (absent) {
				kh_key(h, k) = strdup(s.s);
				min_pos = min_pos < al[i].pos? min_pos : al[i].pos;
				max_pos = max_pos > al[i].pos? max_pos : al[i].pos;
				if (strcmp(al[i].chr.s, al[0].chr.s) != 0) diff_rid = 1;
			}
		}
		free(s.s);
		if (!diff_rid && bm->bgt[0]->itr == 0) {
			char *reg;
			reg = (char*)alloca(strlen(al[0].chr.s) + 23);
			sprintf(reg, "%s:%d-%d", al[0].chr.s, min_pos+1, max_pos+1);
			bgtm_set_region(bm, reg);
		}
		for (i = 0; i < n_al; ++i) free(al[i].chr.s);
		free(al);
		n_al = kh_size(h);
		bm->h_al = (void*)h;
		for (i = 0; i < bm->n_bgt; ++i)
			bm->bgt[i]->h_al = bm->h_al;
	}
	return n_al;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, %r14
andl $0x0, -0x3c(%rbp)
testq %rdx, %rdx
sete %al
testq %rcx, %rcx
sete %cl
orb %al, %cl
je 0x12c20
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movq %rsi, %rdi
callq 0x117ea
movzbl (%r12), %ecx
cmpl $0x2c, %ecx
je 0x124d6
cmpl $0x3a, %ecx
je 0x124d6
cmpb $0x3f, %cl
sete %cl
movq %r15, %rdx
orq %r14, %rdx
setne %dl
testb %cl, %dl
jne 0x12af9
testl %eax, %eax
je 0x12af9
leaq -0xc0(%rbp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x60a9
movq %rax, %r14
movl (%rbx), %r12d
movslq %r12d, %rdi
pushq $0x30
popq %rsi
callq 0x2220
movq %rax, -0x30(%rbp)
xorl %r15d, %r15d
xorl %ebx, %ebx
movslq %r12d, %rax
cmpq %rax, %r15
jge 0x12538
movq (%r14,%r15,8), %rdi
movl %ebx, %eax
imulq $0x30, %rax, %rsi
addq -0x30(%rbp), %rsi
callq 0x12c3f
cmpl $0x1, %eax
adcl $0x0, %ebx
movq (%r14,%r15,8), %rdi
callq 0x2050
incq %r15
movl -0xc0(%rbp), %r12d
jmp 0x12502
movl %ebx, -0x3c(%rbp)
movq %r14, %rdi
callq 0x2050
testl %ebx, %ebx
jle 0x12b4c
movq %r13, -0x88(%rbp)
xorpd %xmm0, %xmm0
leaq -0xc0(%rbp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x2220
movq %rax, %r12
movl %ebx, %eax
movq %rax, -0xa8(%rbp)
movl $0x80000000, -0x50(%rbp) # imm = 0x80000000
movl $0x7fffffff, -0x4c(%rbp) # imm = 0x7FFFFFFF
xorl %ebx, %ebx
pushq $0x4
popq %r15
pushq $0x2
popq %r13
xorl %esi, %esi
xorl %ecx, %ecx
movq $0x0, -0x90(%rbp)
xorl %r14d, %r14d
movl $0x0, -0x58(%rbp)
xorl %eax, %eax
movl $0x0, -0x54(%rbp)
movq %r12, -0x80(%rbp)
cmpq -0xa8(%rbp), %rax
je 0x12a2d
movq %rsi, -0x38(%rbp)
movl %ecx, -0x64(%rbp)
movq %rax, -0xd0(%rbp)
imulq $0x30, %rax, %rdi
addq -0x30(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
leaq -0xc0(%rbp), %rsi
callq 0x12f49
movq -0xb0(%rbp), %rdi
cmpl %r14d, -0x58(%rbp)
movq %rdi, -0x60(%rbp)
jae 0x1260f
movq -0x38(%rbp), %rax
leal -0x1(%rax), %r15d
jmp 0x127cd
movq -0x90(%rbp), %rsi
leal (%rsi,%rsi), %eax
movq -0x38(%rbp), %r8
cmpl %r8d, %eax
movl $0x0, %eax
sbbl %eax, %eax
orl $0x1, %eax
addl %r8d, %eax
decl %eax
movl %eax, %ecx
shrl %ecx
orl %eax, %ecx
movl %ecx, %eax
shrl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
shrl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %edx
shrl $0x8, %edx
orl %ecx, %edx
movl %edx, %eax
shrl $0x10, %eax
orl %edx, %eax
incl %eax
cmpl $0x5, %eax
movl %r15d, %edx
cmovael %eax, %r15d
cvtsi2sd %r15, %xmm0
mulsd 0x67ce(%rip), %xmm0     # 0x18e38
addsd 0x67ce(%rip), %xmm0     # 0x18e40
cvttsd2si %xmm0, %rcx
cmpl %ecx, %esi
jae 0x127c6
movq %rcx, -0x70(%rbp)
movl %r15d, %r14d
shrl $0x2, %r14d
andl $-0x4, %r14d
cmpl $0x10, %eax
cmovbl %edx, %r14d
movq %r14, %rdi
callq 0x22e0
movq %rax, %rbx
movq %rax, %rdi
movl $0xaa, %esi
movq %r14, %rdx
callq 0x21e0
movq -0x38(%rbp), %r8
movl %r15d, %eax
movq %rax, -0x78(%rbp)
cmpl %r15d, %r8d
jae 0x126df
movq 0x18(%r12), %rdi
movq -0x78(%rbp), %rax
leaq (,%rax,8), %rsi
callq 0x2340
movq -0x38(%rbp), %r8
movq %rax, 0x18(%r12)
movq %r15, -0x48(%rbp)
decl %r15d
xorl %edi, %edi
cmpl %r8d, %edi
je 0x127da
movq 0x10(%r12), %r9
movl %edi, %edx
shrl $0x4, %edx
movl (%r9,%rdx,4), %eax
leal (%rdi,%rdi), %ecx
andl $0x1e, %ecx
movl %eax, %esi
shrl %cl, %esi
testb $0x3, %sil
jne 0x127bf
movq %r8, -0x38(%rbp)
movq %r9, -0xa0(%rbp)
leaq (%r9,%rdx,4), %rdx
movq 0x18(%r12), %r12
movq %rdi, -0x98(%rbp)
movl %edi, %esi
movq (%r12,%rsi,8), %r14
btsl %ecx, %eax
movl %eax, (%rdx)
movq %r14, %rdi
callq 0x1526f
movl %eax, %ecx
shrl $0x3, %ecx
movl %eax, %esi
shll $0x3, %esi
xorl %ecx, %esi
orl $0x1, %esi
andl %r15d, %esi
movl %eax, %edi
andl %r15d, %edi
movl %edi, %edx
leal (%rdi,%rdi), %ecx
andl $0x1e, %ecx
movl %r13d, %r8d
shll %cl, %r8d
shrl $0x4, %edx
movl (%rbx,%rdx,4), %r9d
leal (%rdi,%rsi), %eax
testl %r9d, %r8d
je 0x12753
notl %r8d
andl %r8d, %r9d
movl %r9d, (%rbx,%rdx,4)
movl %edi, %esi
movq -0x38(%rbp), %r8
cmpl %r8d, %edi
movq -0xa0(%rbp), %r9
jae 0x127b0
movl (%r9,%rdx,4), %eax
movl %eax, %edi
shrl %cl, %edi
testb $0x3, %dil
jne 0x127b0
leaq (%r9,%rdx,4), %rdx
movq (%r12,%rsi,8), %rdi
movq %r14, (%r12,%rsi,8)
movq %rdi, %r14
jmp 0x12734
movq %r14, (%r12,%rsi,8)
movq -0x80(%rbp), %r12
movq -0x98(%rbp), %rdi
incl %edi
jmp 0x126e8
leal -0x1(%r8), %r15d
movl %r8d, %eax
movq %rax, -0x48(%rbp)
movl %r14d, %eax
movq %rax, -0x70(%rbp)
jmp 0x1282f
cmpl -0x48(%rbp), %r8d
jbe 0x127f7
movq 0x18(%r12), %rdi
movq -0x78(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2340
movq %rax, 0x18(%r12)
movq 0x10(%r12), %rdi
callq 0x2050
movq %rbx, 0x10(%r12)
movq -0x48(%rbp), %rax
movl %eax, (%r12)
movl -0x64(%rbp), %eax
movl %eax, 0x8(%r12)
movq -0x70(%rbp), %rcx
movl %ecx, 0xc(%r12)
movl %eax, %ecx
movq %rcx, -0x90(%rbp)
movl %eax, -0x58(%rbp)
movq -0x60(%rbp), %rdi
callq 0x1526f
movl %eax, %edx
movl %eax, %esi
andl %r15d, %esi
movl %esi, %eax
shrl $0x4, %eax
movl (%rbx,%rax,4), %eax
leal (%rsi,%rsi), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x12858
movl %esi, %r8d
movq -0x60(%rbp), %rdi
jmp 0x12930
movl %edx, %eax
shrl $0x3, %eax
shll $0x3, %edx
xorl %eax, %edx
orl $0x1, %edx
andl %r15d, %edx
movq -0x48(%rbp), %rax
movl %eax, %r8d
movl %esi, %r14d
movq -0x60(%rbp), %rdi
movq %rsi, -0x98(%rbp)
movl %edx, -0x78(%rbp)
movl %r14d, %eax
shrl $0x4, %eax
movl (%rbx,%rax,4), %r9d
leal (%r14,%r14), %r12d
andl $0x1e, %r12d
movl %r9d, %eax
movl %r12d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x12908
testb $0x1, %al
jne 0x128e2
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rdi
movq -0x60(%rbp), %rsi
movq %r8, -0x38(%rbp)
movl %r9d, -0xa0(%rbp)
callq 0x2230
movl -0xa0(%rbp), %r9d
movl -0x78(%rbp), %edx
movq -0x38(%rbp), %r8
movq -0x98(%rbp), %rsi
movq -0x60(%rbp), %rdi
testl %eax, %eax
je 0x12908
btl %r12d, %r9d
cmovbl %r14d, %r8d
addl %edx, %r14d
andl %r15d, %r14d
cmpl %esi, %r14d
jne 0x12880
movb $0x1, %al
movq -0x48(%rbp), %rdx
movl %edx, %ecx
cmpl %edx, %r8d
movq -0x80(%rbp), %r12
je 0x12923
jmp 0x12930
movl %r12d, %ecx
shrl %cl, %r9d
testb $0x2, %r9b
sete %al
movl %r14d, %esi
movl %r8d, %ecx
movq -0x80(%rbp), %r12
movq -0x48(%rbp), %rdx
cmpl %edx, %ecx
cmovel %esi, %ecx
testb %al, %al
cmovnel %esi, %ecx
movl %ecx, %r8d
movl %r8d, %eax
shrl $0x4, %eax
movl (%rbx,%rax,4), %edx
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
shrl %cl, %edx
movl %r8d, %r15d
testb $0x2, %dl
jne 0x1295b
testb $0x1, %dl
jne 0x12990
pushq $0x4
popq %r15
movl -0x64(%rbp), %ecx
jmp 0x12a11
movq 0x18(%r12), %rdx
movq %rdx, -0x38(%rbp)
movq %rdi, (%rdx,%r15,8)
pushq $0x3
popq %rdx
shll %cl, %edx
notl %edx
andl %edx, (%rbx,%rax,4)
movl 0x4(%r12), %r14d
movl 0x8(%r12), %eax
incl %r14d
movl %r14d, 0x4(%r12)
incl %eax
movl %eax, -0x58(%rbp)
movl %eax, 0x8(%r12)
jmp 0x129b4
movq 0x18(%r12), %rdx
movq %rdx, -0x38(%rbp)
movq %rdi, (%rdx,%r15,8)
pushq $0x3
popq %rdx
shll %cl, %edx
notl %edx
andl %edx, (%rbx,%rax,4)
movl 0x4(%r12), %r14d
incl %r14d
movl %r14d, 0x4(%r12)
callq 0x2430
movq -0x38(%rbp), %rcx
movq %rax, (%rcx,%r15,8)
movq -0xc8(%rbp), %rdx
movl 0x24(%rdx), %eax
movl -0x4c(%rbp), %ecx
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, -0x4c(%rbp)
movl -0x50(%rbp), %ecx
cmpl %eax, %ecx
cmovlel %eax, %ecx
movl %ecx, -0x50(%rbp)
movq 0x10(%rdx), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x2230
testl %eax, %eax
pushq $0x1
popq %rax
movl -0x54(%rbp), %ecx
cmovnel %eax, %ecx
movl %ecx, -0x54(%rbp)
movl %r14d, %eax
movq %rax, -0x90(%rbp)
pushq $0x4
popq %r15
movl %r14d, %ecx
movq -0xd0(%rbp), %rax
incq %rax
movq -0x48(%rbp), %rdx
movl %edx, %esi
movq -0x70(%rbp), %rdx
movl %edx, %r14d
jmp 0x125bb
movq -0xb0(%rbp), %rdi
callq 0x2050
cmpl $0x0, -0x54(%rbp)
movq -0x88(%rbp), %r15
jne 0x12aa0
movq 0x38(%r15), %rax
movq (%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x12aa0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rbx
movq %rbx, %rdi
callq 0x2170
movq %rsp, %r14
addq $0x26, %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movl -0x4c(%rbp), %ecx
incl %ecx
movl -0x50(%rbp), %r8d
incl %r8d
leaq 0x6dea(%rip), %rsi      # 0x19872
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2400
movq %r15, %rdi
movq %r14, %rsi
callq 0x12353
imulq $0x30, -0xa8(%rbp), %rbx
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0x12ac4
movq -0x30(%rbp), %rax
movq 0x10(%rax,%r14), %rdi
callq 0x2050
addq $0x30, %r14
jmp 0x12aab
movq -0x30(%rbp), %rdi
callq 0x2050
movl 0x4(%r12), %ebx
movq %r12, 0xa0(%r15)
movl (%r15), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x12b4c
movq 0x38(%r15), %rdx
movq (%rdx,%rcx,8), %rdx
movq %r12, 0x60(%rdx)
incq %rcx
jmp 0x12ae3
pushq $-0x1
popq %rbx
movq %r15, %rax
orq %r14, %rax
je 0x12b4c
movq %r13, -0x88(%rbp)
andl $0x0, -0x68(%rbp)
leaq -0xc0(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x1528c
movq %rax, %r12
movl (%r13), %eax
testl %eax, %eax
setne %cl
testq %r12, %r12
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x12b48
movq %r12, %rdi
callq 0x162c2
movl -0xc0(%rbp), %eax
testl %eax, %eax
je 0x12b5d
movl %ebx, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r15, %r15
je 0x12bb7
xorl %ebx, %ebx
leaq -0x68(%rbp), %r14
xorl %r13d, %r13d
movq $0x0, -0x30(%rbp)
movslq 0x20(%r15), %rax
cmpq %rax, %r13
jge 0x12c09
movq %r15, %rdi
movl %r13d, %esi
movq %r12, %rdx
callq 0x9339
testl %eax, %eax
je 0x12bae
movq 0x28(%r15), %rax
movq (%rax,%rbx), %rcx
movq -0x30(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
movq %r14, %rdx
callq 0x12ecb
movq %rax, -0x30(%rbp)
incq %r13
addq $0x18, %rbx
jmp 0x12b73
movq %r14, %rdi
callq 0x943a
movq %rax, %rbx
movq $0x0, -0x30(%rbp)
pushq $0x1
popq %r14
leaq -0x3c(%rbp), %r15
leaq -0x68(%rbp), %r13
movq %rbx, %rdi
movq %r12, %rsi
movl %r14d, %edx
callq 0x94db
testq %rax, %rax
je 0x12c01
movq -0x30(%rbp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x12ecb
movq %rax, -0x30(%rbp)
jmp 0x12bd6
movq %rbx, %rdi
callq 0x94ae
movq %r12, %rdi
callq 0x162c2
movl -0x3c(%rbp), %ebx
movq -0x88(%rbp), %r13
jmp 0x12543
leaq 0x6bef(%rip), %rdi      # 0x19816
leaq 0x6bb6(%rip), %rsi      # 0x197e4
leaq 0x6bf3(%rip), %rcx      # 0x19828
movl $0x1e1, %edx            # imm = 0x1E1
callq 0x21b0