// File: /workspace/github_c_makefile_star2_O0/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
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1e308
cmpq $0x0, -0x28(%rbp)
jne 0x1e30a
jmp 0x1e329
leaq 0xa1d6(%rip), %rdi      # 0x284e7
leaq 0xa19d(%rip), %rsi      # 0x284b5
movl $0x1e1, %edx            # imm = 0x1E1
leaq 0xa1d5(%rip), %rcx      # 0x284f9
callq 0x21b0
movq -0x18(%rbp), %rdi
callq 0x1cb80
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
je 0x1e37f
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
je 0x1e37f
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3f, %eax
je 0x1e35f
cmpl $0x0, -0x30(%rbp)
jne 0x1e37f
cmpq $0x0, -0x20(%rbp)
jne 0x1e409
cmpq $0x0, -0x28(%rbp)
jne 0x1e409
cmpl $0x0, -0x30(%rbp)
je 0x1e409
movq -0x18(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x88f0
movq %rax, -0x48(%rbp)
movslq -0x4c(%rbp), %rdi
movl $0x30, %esi
callq 0x2230
movq %rax, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1e3fb
movq -0x48(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x40(%rbp), %rsi
movslq -0x34(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rsi
callq 0x1e7e0
cmpl $0x0, %eax
jne 0x1e3df
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x48(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2040
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1e3a9
movq -0x48(%rbp), %rdi
callq 0x2040
jmp 0x1e52a
cmpq $0x0, -0x20(%rbp)
jne 0x1e41b
cmpq $0x0, -0x28(%rbp)
je 0x1e51c
movl $0x0, -0x54(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x22f50
movq %rax, -0x60(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x1e449
cmpq $0x0, -0x60(%rbp)
je 0x1e449
movq -0x60(%rbp), %rdi
callq 0x23c00
cmpl $0x0, -0x50(%rbp)
je 0x1e45b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1e7ca
cmpq $0x0, -0x20(%rbp)
je 0x1e4c4
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0x1e4c2
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x60(%rbp), %rdx
callq 0xe1d0
cmpl $0x0, %eax
je 0x1e4b5
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
leaq -0x34(%rbp), %rsi
leaq -0x54(%rbp), %rdx
callq 0x1ecc0
movq %rax, -0x40(%rbp)
jmp 0x1e4b7
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1e469
jmp 0x1e511
movq -0x28(%rbp), %rdi
callq 0xe380
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl $0x1, %edx
callq 0xe490
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
je 0x1e508
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rcx
leaq -0x34(%rbp), %rsi
leaq -0x54(%rbp), %rdx
callq 0x1ecc0
movq %rax, -0x40(%rbp)
jmp 0x1e4d1
movq -0x68(%rbp), %rdi
callq 0xe440
movq -0x60(%rbp), %rdi
callq 0x23c00
jmp 0x1e528
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1e7ca
jmp 0x1e52a
cmpl $0x0, -0x34(%rbp)
jle 0x1e7c4
movl $0x0, -0x78(%rbp)
movl $0x7fffffff, -0x7c(%rbp) # imm = 0x7FFFFFFF
movl $0x80000000, -0x80(%rbp) # imm = 0x80000000
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x21e0
callq 0x226f0
movq %rax, -0x88(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x1e6a5
movq -0x40(%rbp), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1ed90
movq -0x88(%rbp), %rdi
movq -0x90(%rbp), %rsi
leaq -0x74(%rbp), %rdx
callq 0x1ee60
movl %eax, -0xa4(%rbp)
cmpl $0x0, -0x74(%rbp)
je 0x1e695
movq -0x90(%rbp), %rdi
callq 0x2440
movq %rax, %rdx
movq -0x88(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xa4(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x7c(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x24(%rcx), %eax
jge 0x1e603
movl -0x7c(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x1e61b
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x80(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x24(%rcx), %eax
jle 0x1e646
movl -0x80(%rbp), %eax
movl %eax, -0xb8(%rbp)
jmp 0x1e65e
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0x80(%rbp)
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x2240
cmpl $0x0, %eax
je 0x1e693
movl $0x1, -0x78(%rbp)
jmp 0x1e695
jmp 0x1e697
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1e56f
movq -0x90(%rbp), %rdi
callq 0x2040
cmpl $0x0, -0x78(%rbp)
jne 0x1e72c
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x1e72c
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2170
movq %rax, %rcx
addq $0x26, %rcx
andq $-0x10, %rcx
movq %rsp, %rax
subq %rcx, %rax
movq %rax, %rsp
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdx
movl -0x7c(%rbp), %ecx
addl $0x1, %ecx
movl -0x80(%rbp), %r8d
addl $0x1, %r8d
leaq 0x9e2e(%rip), %rsi      # 0x28543
movb $0x0, %al
callq 0x2410
movq -0x10(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x1e0b0
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x1e75e
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x2040
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1e733
movq -0x40(%rbp), %rdi
callq 0x2040
movq -0x88(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x88(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa0(%rax)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1e7c2
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x2c(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x60(%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1e78d
jmp 0x1e7c4
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)