// File: /workspace/github_c_makefile_star2_O1/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 $0x88, %rsp
movq %rcx, %r15
movq %rdi, -0x60(%rbp)
testq %rdx, %rdx
sete %al
testq %rcx, %rcx
sete %cl
orb %al, %cl
je 0x17a90
movq %rdx, %r14
movq %rsi, %rbx
movq %rsi, %rdi
callq 0x16143
movzbl (%rbx), %ecx
cmpl $0x2c, %ecx
je 0x1742c
cmpl $0x3a, %ecx
je 0x1742c
cmpb $0x3f, %cl
sete %cl
movq %r14, %rdx
orq %r15, %rdx
setne %dl
testb %cl, %dl
jne 0x1781f
testl %eax, %eax
je 0x1781f
leaq -0x90(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6694
movq %rax, %rbx
movslq (%r14), %r14
movl $0x30, %esi
movq %r14, %rdi
callq 0x2220
movq %rax, %r12
testq %r14, %r14
jle 0x17497
xorl %r14d, %r14d
xorl %r13d, %r13d
movq (%rbx,%r14,8), %rdi
movl %r13d, %eax
leaq (%rax,%rax,2), %rsi
shlq $0x4, %rsi
addq %r12, %rsi
callq 0x17aaf
cmpl $0x1, %eax
adcl $0x0, %r13d
movq (%rbx,%r14,8), %rdi
callq 0x2050
incq %r14
movslq -0x90(%rbp), %rax
cmpq %rax, %r14
jl 0x1745f
jmp 0x1749a
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x2050
testl %r13d, %r13d
jle 0x17817
xorps %xmm0, %xmm0
leaq -0x90(%rbp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl $0x1, %edi
movl $0x28, %esi
callq 0x2220
movq %rax, %r15
movl %r13d, %eax
movq %rax, -0xa0(%rbp)
xorl %eax, %eax
movl $0x7fffffff, -0x44(%rbp) # imm = 0x7FFFFFFF
movl $0x80000000, -0x48(%rbp) # imm = 0x80000000
movl $0x0, -0x4c(%rbp)
movq %r12, -0x98(%rbp)
movq %r13, -0x38(%rbp)
movq %r15, -0x30(%rbp)
movq %rax, -0xb0(%rbp)
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %r12, %rdi
movq %rdi, -0xa8(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x17f13
movq -0x80(%rbp), %rsi
movl 0x8(%r15), %eax
cmpl 0xc(%r15), %eax
jb 0x1755a
movl (%r15), %eax
movl 0x4(%r15), %ecx
addl %ecx, %ecx
cmpl %eax, %ecx
movq %rsi, %rbx
movl $0x0, %esi
sbbl %esi, %esi
orl $0x1, %esi
addl %eax, %esi
movq %r15, %rdi
callq 0x1b0f3
movq %rbx, %rsi
movl (%r15), %edi
movsbl (%rsi), %ebx
testl %ebx, %ebx
je 0x17586
movb 0x1(%rsi), %al
testb %al, %al
je 0x17588
leaq 0x2(%rsi), %rcx
movl %ebx, %edx
shll $0x5, %edx
subl %ebx, %edx
movsbl %al, %ebx
addl %edx, %ebx
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x1756f
jmp 0x17588
xorl %ebx, %ebx
leal -0x1(%rdi), %edx
movl %ebx, %r9d
andl %edx, %r9d
movq 0x10(%r15), %r8
movl %r9d, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %eax
leal (%r9,%r9), %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x17674
movl %ebx, %eax
shrl $0x3, %eax
shll $0x3, %ebx
xorl %eax, %ebx
orl $0x1, %ebx
andl %edx, %ebx
movq %rdi, -0x68(%rbp)
movl %edi, %r15d
movl %r9d, %r14d
movq %rsi, -0x40(%rbp)
movq %r8, -0x58(%rbp)
movq %r9, -0x70(%rbp)
movl %edx, -0x74(%rbp)
movl %r14d, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %r13d
leal (%r14,%r14), %r12d
andl $0x1e, %r12d
movl %r13d, %eax
movl %r12d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x1763a
testb $0x1, %al
jne 0x17622
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rdi
movq -0x40(%rbp), %rsi
callq 0x2230
movl -0x74(%rbp), %edx
movq -0x70(%rbp), %r9
movq -0x58(%rbp), %r8
movq -0x40(%rbp), %rsi
testl %eax, %eax
je 0x1763a
btl %r12d, %r13d
cmovbl %r14d, %r15d
addl %ebx, %r14d
andl %edx, %r14d
movl %r15d, %eax
cmpl %r9d, %r14d
jne 0x175d5
jmp 0x1763e
movq -0x68(%rbp), %rax
movl %eax, %r9d
movq -0x68(%rbp), %rdx
cmpl %edx, %eax
movq -0x98(%rbp), %r12
movq -0x38(%rbp), %r13
jne 0x17674
movl %r14d, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %eax
leal (%r14,%r14), %ecx
shrl %cl, %eax
cmpl %edx, %r15d
cmovel %r14d, %r15d
testb $0x2, %al
cmovel %r14d, %r15d
movl %r15d, %r9d
movl %r9d, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %edx
leal (%r9,%r9), %ecx
andl $0x1e, %ecx
shrl %cl, %edx
movl %r9d, %ebx
testb $0x2, %dl
jne 0x176ba
testb $0x1, %dl
movq -0x30(%rbp), %r15
je 0x1772c
movq 0x18(%r15), %rdx
movq %rsi, (%rdx,%rbx,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
movq 0x10(%r15), %rcx
andl %edx, (%rcx,%rax,4)
incl 0x4(%r15)
jmp 0x176de
movq -0x30(%rbp), %r15
movq 0x18(%r15), %rdx
movq %rsi, (%rdx,%rbx,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
movq 0x10(%r15), %rcx
andl %edx, (%rcx,%rax,4)
incl 0x4(%r15)
incl 0x8(%r15)
movq %rsi, %rdi
callq 0x2420
movq 0x18(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
movq -0xa8(%rbp), %rdx
movl 0x24(%rdx), %eax
movl -0x44(%rbp), %ecx
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, -0x44(%rbp)
movl -0x48(%rbp), %ecx
cmpl %eax, %ecx
cmovlel %eax, %ecx
movl %ecx, -0x48(%rbp)
movq 0x10(%rdx), %rdi
movq 0x10(%r12), %rsi
callq 0x2230
testl %eax, %eax
movl -0x4c(%rbp), %eax
movl $0x1, %ecx
cmovnel %ecx, %eax
movl %eax, -0x4c(%rbp)
movq -0xb0(%rbp), %rax
incq %rax
cmpq -0xa0(%rbp), %rax
jne 0x17502
movq -0x80(%rbp), %rdi
callq 0x2050
cmpl $0x0, -0x4c(%rbp)
jne 0x177ae
movq -0x60(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x177ae
movq 0x10(%r12), %rbx
movq %rbx, %rdi
callq 0x2170
movq %rsp, %r14
addq $0x26, %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movl -0x44(%rbp), %ecx
incl %ecx
movl -0x48(%rbp), %r8d
incl %r8d
leaq 0x810d(%rip), %rsi      # 0x1f8a2
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23f0
movq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0x17295
cmpl $0x2, %r13d
movl $0x1, %eax
cmovgel %r13d, %eax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rbx
xorl %r14d, %r14d
movq 0x10(%r12,%r14), %rdi
callq 0x2050
addq $0x30, %r14
cmpq %r14, %rbx
jne 0x177c6
movq %r12, %rdi
callq 0x2050
movl 0x4(%r15), %eax
movq -0x60(%rbp), %rcx
movq %r15, 0xa0(%rcx)
movslq (%rcx), %rdi
testq %rdi, %rdi
jle 0x17a81
movq 0x38(%rcx), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movq %r15, 0x60(%rsi)
incq %rdx
cmpq %rdx, %rdi
jne 0x17802
jmp 0x17a81
movl %r13d, %eax
jmp 0x17a81
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %r14, %rcx
orq %r15, %rcx
je 0x17a81
leaq -0x90(%rbp), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1b574
cmpl $0x0, (%r13)
setne %dl
movq %rax, -0x40(%rbp)
testq %rax, %rax
setne %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x17864
movq -0x40(%rbp), %rdi
callq 0x1ced4
movl -0x90(%rbp), %ecx
testl %ecx, %ecx
je 0x1787e
xorl %r13d, %r13d
xorl %r12d, %r12d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x17a79
testq %r14, %r14
movl %ecx, -0x70(%rbp)
je 0x1796b
cmpl $0x0, 0x20(%r14)
jle 0x17a42
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %ebx, %ebx
movq $0x0, -0x38(%rbp)
movq %r14, %rdi
movl %r15d, %esi
movq -0x40(%rbp), %rdx
callq 0xa504
testl %eax, %eax
je 0x17952
movq 0x28(%r14), %rax
movq (%rax,%r13), %rdi
cmpl %ebx, -0x38(%rbp)
jne 0x17929
leal (%rbx,%rbx), %ecx
testl %ebx, %ebx
movl $0x4, %eax
cmovel %eax, %ecx
movl %ecx, -0x30(%rbp)
movq %rdi, -0x58(%rbp)
movq %r12, %rdi
movslq %ecx, %r12
movq %r12, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2330
movslq %ebx, %rcx
leaq (%rcx,%rcx,2), %rdi
shlq $0x4, %rdi
addq %rax, %rdi
subl %ebx, %r12d
movslq %r12d, %rcx
movq %rax, %r12
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rdx
xorl %esi, %esi
callq 0x21e0
movq -0x58(%rbp), %rdi
movl -0x30(%rbp), %eax
movq %rax, -0x30(%rbp)
jmp 0x1792d
movq %rbx, -0x30(%rbp)
movq -0x38(%rbp), %rbx
movslq %ebx, %rax
leaq (%rax,%rax,2), %rsi
shlq $0x4, %rsi
addq %r12, %rsi
callq 0x17aaf
cmpl $0x1, %eax
adcl $0x0, %ebx
movq %rbx, -0x38(%rbp)
movq -0x30(%rbp), %rbx
incq %r15
movslq 0x20(%r14), %rax
addq $0x18, %r13
cmpq %rax, %r15
jl 0x178a8
jmp 0x17a64
movq %r15, %rdi
callq 0xa610
movq %rax, -0x30(%rbp)
movq %rax, %rdi
movq -0x40(%rbp), %rsi
movl $0x1, %edx
callq 0xa6c0
testq %rax, %rax
je 0x17a4f
movq %rax, %r15
xorl %r14d, %r14d
xorl %eax, %eax
xorl %ebx, %ebx
cmpl %eax, %ebx
jne 0x179fb
movq %rbx, -0x38(%rbp)
leal (%rax,%rax), %r13d
testl %eax, %eax
movq %rax, -0x58(%rbp)
movl $0x4, %eax
cmovel %eax, %r13d
movslq %r13d, %rbx
movq %rbx, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
movq %r14, %rdi
callq 0x2330
movq %rax, %r12
movq -0x58(%rbp), %rcx
movslq %ecx, %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %r12, %rdi
subl %ecx, %ebx
movslq %ebx, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdx
xorl %esi, %esi
callq 0x21e0
movq -0x38(%rbp), %rbx
jmp 0x17a01
movq %rax, %r13
movq %r14, %r12
movl %ebx, %eax
leaq (%rax,%rax,2), %rsi
shlq $0x4, %rsi
movq %r12, %r14
addq %r12, %rsi
movq %r15, %rdi
callq 0x17aaf
cmpl $0x1, %eax
adcl $0x0, %ebx
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl $0x1, %edx
callq 0xa6c0
movq %rax, %r15
testq %rax, %rax
movq %r13, %rax
jne 0x1799b
jmp 0x17a54
movq $0x0, -0x38(%rbp)
xorl %r12d, %r12d
jmp 0x17a64
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %rbx, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0xa693
movq %r14, %r12
movq -0x40(%rbp), %rdi
callq 0x1ced4
movq -0x38(%rbp), %r13
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl -0x70(%rbp), %ecx
testl %ecx, %ecx
je 0x174a2
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7daf(%rip), %rdi      # 0x1f846
leaq 0x7d76(%rip), %rsi      # 0x1f814
leaq 0x7db3(%rip), %rcx      # 0x1f858
movl $0x1e1, %edx            # imm = 0x1E1
callq 0x21b0