// File: /workspace/github_c_makefile_star2_O3/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 $0x98, %rsp
movq %rcx, %r12
movq %rdi, -0xa8(%rbp)
testq %rdx, %rdx
sete %al
testq %rcx, %rcx
sete %cl
orb %al, %cl
je 0x18308
movq %rdx, %r15
movq %rsi, %r14
movq %rsi, %rdi
callq 0x16779
movzbl (%r14), %ecx
cmpl $0x2c, %ecx
je 0x17aa4
cmpl $0x3a, %ecx
je 0x17aa4
cmpb $0x3f, %cl
sete %cl
movq %r15, %rdx
orq %r12, %rdx
setne %dl
testb %cl, %dl
jne 0x180df
testl %eax, %eax
je 0x180df
leaq -0xa0(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6803
movq %rax, %r14
movslq (%rbx), %rbx
movl $0x30, %esi
movq %rbx, %rdi
callq 0x2220
movq %rax, %r13
testq %rbx, %rbx
jle 0x17b0c
xorl %r15d, %r15d
xorl %ebx, %ebx
movq (%r14,%r15,8), %rdi
movl %ebx, %eax
leaq (%rax,%rax,2), %rsi
shlq $0x4, %rsi
addq %r13, %rsi
callq 0x18327
cmpl $0x1, %eax
adcl $0x0, %ebx
movq (%r14,%r15,8), %rdi
callq 0x2050
incq %r15
movslq -0xa0(%rbp), %rax
cmpq %rax, %r15
jl 0x17ad6
jmp 0x17b0e
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x2050
testl %ebx, %ebx
jle 0x180ce
xorpd %xmm0, %xmm0
leaq -0xa0(%rbp), %rax
movapd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl $0x1, %edi
movl $0x28, %esi
callq 0x2220
movq %rax, -0x38(%rbp)
movl %ebx, %eax
movq %rax, -0x88(%rbp)
movl $0x7fffffff, -0x4c(%rbp) # imm = 0x7FFFFFFF
movl $0x80000000, -0x50(%rbp) # imm = 0x80000000
xorl %ebx, %ebx
xorl %r12d, %r12d
movl $0x0, -0x64(%rbp)
xorl %r15d, %r15d
xorl %r14d, %r14d
movl $0x0, -0x58(%rbp)
xorl %eax, %eax
movl $0x0, -0x54(%rbp)
movq %r13, -0x40(%rbp)
movq %rax, -0xb8(%rbp)
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %r13, %rdi
movq %rdi, -0xb0(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0x18791
movq -0x90(%rbp), %rsi
cmpl %r14d, -0x58(%rbp)
jb 0x17def
leal (%r15,%r15), %eax
cmpl %r12d, %eax
movl $0x0, %eax
sbbl %eax, %eax
orl $0x1, %eax
addl %r12d, %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 $0x4, %ecx
cmovael %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x7228(%rip), %xmm0     # 0x1ee38
addsd 0x7228(%rip), %xmm0     # 0x1ee40
cvttsd2si %xmm0, %rdx
cmpl %edx, %r15d
jae 0x17def
movq %rsi, -0x60(%rbp)
movq %rdx, -0x70(%rbp)
movl %ecx, %r13d
shrl $0x2, %r13d
andl $-0x4, %r13d
cmpl $0x10, %eax
movl $0x4, %eax
cmovbl %eax, %r13d
movq %r13, %rdi
movq %rcx, -0x30(%rbp)
callq 0x22e0
movq %rax, %rbx
movq %rax, %rdi
movl $0xaa, %esi
movq %r13, %rdx
callq 0x21e0
movq -0x30(%rbp), %rcx
cmpl %ecx, %r12d
movq -0x38(%rbp), %r8
jae 0x17c96
movq 0x18(%r8), %rdi
movl -0x30(%rbp), %esi
shlq $0x3, %rsi
callq 0x2330
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movq %rax, 0x18(%r8)
testl %r12d, %r12d
je 0x17dbb
leal -0x1(%rcx), %eax
xorl %edx, %edx
movq 0x10(%r8), %rsi
movl %edx, %r9d
shrl $0x4, %r9d
movl (%rsi,%r9,4), %r10d
leal (%rdx,%rdx), %ecx
andl $0x1e, %ecx
movl %r10d, %edi
shrl %cl, %edi
testb $0x3, %dil
jne 0x17d8b
movq 0x18(%r8), %rdi
movl %edx, %r8d
movq (%rdi,%r8,8), %r8
btsl %ecx, %r10d
movl %r10d, (%rsi,%r9,4)
movsbl (%r8), %r9d
testl %r9d, %r9d
je 0x17d04
movb 0x1(%r8), %cl
testb %cl, %cl
je 0x17d07
leaq 0x2(%r8), %r10
movl %r9d, %r11d
shll $0x5, %r11d
subl %r9d, %r11d
movsbl %cl, %r9d
addl %r11d, %r9d
movb (%r10), %cl
incq %r10
testb %cl, %cl
jne 0x17ce7
jmp 0x17d07
xorl %r9d, %r9d
movl %r9d, %ecx
shrl $0x3, %ecx
leal (,%r9,8), %r11d
xorl %ecx, %r11d
orl $0x1, %r11d
andl %eax, %r11d
movl %r9d, %r14d
andl %eax, %r14d
movl %r14d, %r10d
leal (%r14,%r14), %ecx
andl $0x1e, %ecx
movl $0x2, %r15d
shll %cl, %r15d
shrl $0x4, %r10d
movl (%rbx,%r10,4), %r13d
leal (%r14,%r11), %r9d
testl %r13d, %r15d
je 0x17d1f
notl %r15d
andl %r15d, %r13d
movl %r13d, (%rbx,%r10,4)
movl %r14d, %r9d
cmpl %r12d, %r14d
jae 0x17d83
movl (%rsi,%r10,4), %r11d
movl %r11d, %r14d
shrl %cl, %r14d
testb $0x3, %r14b
jne 0x17d83
movq (%rdi,%r9,8), %r14
movq %r8, (%rdi,%r9,8)
btsl %ecx, %r11d
movl %r11d, (%rsi,%r10,4)
movq %r14, %r8
jmp 0x17cd2
movq %r8, (%rdi,%r9,8)
movq -0x38(%rbp), %r8
incl %edx
cmpl %r12d, %edx
jne 0x17c9b
movq -0x30(%rbp), %rcx
cmpl %ecx, %r12d
jbe 0x17dbb
movq 0x18(%r8), %rdi
movl -0x30(%rbp), %esi
shlq $0x3, %rsi
callq 0x2330
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movq %rax, 0x18(%r8)
movq 0x10(%r8), %rdi
movq %rcx, %r14
callq 0x2050
movq -0x38(%rbp), %rdi
movq %rbx, 0x10(%rdi)
movl %r14d, (%rdi)
movl -0x64(%rbp), %eax
movl %eax, 0x8(%rdi)
movq -0x70(%rbp), %rcx
movl %ecx, 0xc(%rdi)
movl %eax, %r15d
movl %eax, -0x58(%rbp)
movq -0x40(%rbp), %r13
movq -0x60(%rbp), %rsi
jmp 0x17dfe
movq %r12, -0x30(%rbp)
movl %r14d, %eax
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rdi
movsbl (%rsi), %r12d
testl %r12d, %r12d
je 0x17e2d
movb 0x1(%rsi), %al
testb %al, %al
je 0x17e30
leaq 0x2(%rsi), %rcx
movl %r12d, %edx
shll $0x5, %edx
subl %r12d, %edx
movsbl %al, %r12d
addl %edx, %r12d
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x17e12
jmp 0x17e30
xorl %r12d, %r12d
movq -0x30(%rbp), %rdx
leal -0x1(%rdx), %r10d
movl %r12d, %r9d
andl %r10d, %r9d
movl %r9d, %eax
shrl $0x4, %eax
movl (%rbx,%rax,4), %eax
leal (%r9,%r9), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x17e59
movl %r9d, %r8d
jmp 0x17f2c
movq %r15, -0x80(%rbp)
movl %r12d, %eax
shrl $0x3, %eax
shll $0x3, %r12d
xorl %eax, %r12d
orl $0x1, %r12d
andl %r10d, %r12d
movl %edx, %r8d
movl %r9d, %r15d
movq %rsi, -0x60(%rbp)
movq %r9, -0xc0(%rbp)
movl %r10d, -0x74(%rbp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%rbx,%rax,4), %r14d
leal (%r15,%r15), %r13d
andl $0x1e, %r13d
movl %r14d, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x17f01
testb $0x1, %al
jne 0x17ed7
movq 0x18(%rdi), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, -0x48(%rbp)
callq 0x2230
movl -0x74(%rbp), %r10d
movq -0xc0(%rbp), %r9
movq -0x48(%rbp), %r8
movq -0x60(%rbp), %rsi
movq -0x38(%rbp), %rdi
testl %eax, %eax
je 0x17f01
btl %r13d, %r14d
cmovbl %r15d, %r8d
addl %r12d, %r15d
andl %r10d, %r15d
cmpl %r9d, %r15d
jne 0x17e86
movb $0x1, %al
movq -0x30(%rbp), %rdx
movl %edx, %ecx
cmpl %edx, %r8d
movq -0x40(%rbp), %r13
movq -0x80(%rbp), %r15
je 0x17f1c
jmp 0x17f2c
movl %r13d, %ecx
shrl %cl, %r14d
testb $0x2, %r14b
sete %al
movl %r15d, %r9d
movl %r8d, %ecx
movq -0x40(%rbp), %r13
movq -0x80(%rbp), %r15
cmpl -0x30(%rbp), %ecx
cmovel %r9d, %ecx
testb %al, %al
cmovnel %r9d, %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
testb $0x2, %dl
jne 0x17f70
testb $0x1, %dl
je 0x17fed
movq 0x18(%rdi), %r15
movl %r8d, %r14d
movq %rsi, (%r15,%r14,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
andl %edx, (%rbx,%rax,4)
movl 0x4(%rdi), %r12d
incl %r12d
movl %r12d, 0x4(%rdi)
jmp 0x17f9d
movq 0x18(%rdi), %r15
movl %r8d, %r14d
movq %rsi, (%r15,%r14,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
andl %edx, (%rbx,%rax,4)
movl 0x4(%rdi), %r12d
movl 0x8(%rdi), %eax
incl %r12d
movl %r12d, 0x4(%rdi)
incl %eax
movl %eax, -0x58(%rbp)
movl %eax, 0x8(%rdi)
movq %rsi, %rdi
callq 0x2420
movq %rax, (%r15,%r14,8)
movq -0xb0(%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 0x10(%r13), %rsi
callq 0x2230
testl %eax, %eax
movl $0x1, %eax
movl -0x54(%rbp), %ecx
cmovnel %eax, %ecx
movl %ecx, -0x54(%rbp)
movl %r12d, -0x64(%rbp)
movl %r12d, %r15d
movq -0xb8(%rbp), %rax
incq %rax
movq -0x30(%rbp), %r12
movq -0x70(%rbp), %rcx
movl %ecx, %r14d
cmpq -0x88(%rbp), %rax
jne 0x17b85
movq -0x90(%rbp), %rdi
callq 0x2050
cmpl $0x0, -0x54(%rbp)
movq -0xa8(%rbp), %r15
jne 0x1807e
movq 0x38(%r15), %rax
movq (%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x1807e
movq 0x10(%r13), %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 0x785c(%rip), %rsi      # 0x1f8c2
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23f0
movq %r15, %rdi
movq %r14, %rsi
callq 0x17908
leaq 0x10(%r13), %rbx
movq -0x88(%rbp), %r14
movq (%rbx), %rdi
callq 0x2050
addq $0x30, %rbx
decq %r14
jne 0x18089
movq %r13, %rdi
callq 0x2050
movq -0x38(%rbp), %rdi
movl 0x4(%rdi), %ebx
movq %rdi, 0xa0(%r15)
movslq (%r15), %rax
testq %rax, %rax
jle 0x180ce
movq 0x38(%r15), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movq %rdi, 0x60(%rsi)
incq %rdx
cmpq %rdx, %rax
jne 0x180be
movl %ebx, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %r15, %rax
orq %r12, %rax
je 0x180ce
leaq -0xa0(%rbp), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x1bb84
movl (%r13), %esi
testl %esi, %esi
setne %cl
movq %rax, -0x38(%rbp)
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x18127
movq -0x38(%rbp), %rdi
callq 0x1d0fd
movl -0xa0(%rbp), %esi
testl %esi, %esi
jne 0x180ce
testq %r15, %r15
je 0x18205
cmpl $0x0, 0x20(%r15)
jle 0x182dd
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %ebx, %ebx
movl $0x0, -0x48(%rbp)
movq %r15, %rdi
movl %r12d, %esi
movq -0x38(%rbp), %rdx
callq 0xa785
testl %eax, %eax
je 0x181ec
movq 0x28(%r15), %rax
movq (%rax,%r14), %rdi
cmpl -0x48(%rbp), %ebx
jne 0x181d3
leal (%rbx,%rbx), %ecx
testl %ebx, %ebx
movl $0x4, %eax
cmovel %eax, %ecx
movq %rdi, -0x30(%rbp)
movq %r13, %rdi
movl %ecx, -0x48(%rbp)
movslq %ecx, %r13
movq %r13, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2330
movslq %ebx, %rcx
movq %rcx, -0x60(%rbp)
leaq (%rcx,%rcx,2), %rdi
shlq $0x4, %rdi
addq %rax, %rdi
subl %ebx, %r13d
movslq %r13d, %rcx
movq %rax, %r13
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rdx
xorl %esi, %esi
callq 0x21e0
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rdi
jmp 0x181d6
movslq %ebx, %rax
leaq (%rax,%rax,2), %rsi
shlq $0x4, %rsi
addq %r13, %rsi
callq 0x18327
cmpl $0x1, %eax
adcl $0x0, %ebx
incq %r12
movslq 0x20(%r15), %rax
addq $0x18, %r14
cmpq %rax, %r12
jl 0x18151
jmp 0x182fa
movq %r12, %rdi
callq 0xa891
movq %rax, %r15
movq %rax, %rdi
movq -0x38(%rbp), %rsi
movl $0x1, %edx
callq 0xa936
testq %rax, %rax
je 0x182e4
movq %rax, %r12
movq $0x0, -0x40(%rbp)
xorl %ebx, %ebx
movl $0x0, -0x48(%rbp)
movq %r15, -0x30(%rbp)
cmpl -0x48(%rbp), %ebx
jne 0x1829a
leal (%rbx,%rbx), %ecx
testl %ebx, %ebx
movl $0x4, %eax
cmovel %eax, %ecx
movl %ecx, -0x48(%rbp)
movslq %ecx, %r15
movq %r15, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
movq -0x40(%rbp), %rdi
callq 0x2330
movq %rax, %r13
movl %ebx, %r14d
leaq (%r14,%r14,2), %rdi
shlq $0x4, %rdi
addq %rax, %rdi
subl %ebx, %r15d
movslq %r15d, %rax
movq -0x30(%rbp), %r15
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdx
xorl %esi, %esi
callq 0x21e0
jmp 0x182a1
movl %ebx, %r14d
movq -0x40(%rbp), %r13
leaq (%r14,%r14,2), %rsi
shlq $0x4, %rsi
movq %r13, -0x40(%rbp)
addq %r13, %rsi
movq %r12, %rdi
callq 0x18327
cmpl $0x1, %eax
adcl $0x0, %ebx
movq %r15, %rdi
movq -0x38(%rbp), %rsi
movl $0x1, %edx
callq 0xa936
movq %rax, %r12
testq %rax, %rax
jne 0x18242
jmp 0x182ee
xorl %ebx, %ebx
xorl %r13d, %r13d
jmp 0x182fa
xorl %ebx, %ebx
movq $0x0, -0x40(%rbp)
movq %r15, %rdi
callq 0xa909
movq -0x40(%rbp), %r13
movq -0x38(%rbp), %rdi
callq 0x1d0fd
jmp 0x17b16
leaq 0x7557(%rip), %rdi      # 0x1f866
leaq 0x751e(%rip), %rsi      # 0x1f834
leaq 0x755b(%rip), %rcx      # 0x1f878
movl $0x1e1, %edx            # imm = 0x1E1
callq 0x21b0