// File: /workspace/github_c_makefile_star2_O0/lh3[P]bgt/bgt.c
// Function: bgt_add_group_core
int bgt_add_group_core(bgt_t *bgt, int n, char *const* samples, const char *expr)
{
	int i, size = 0;
	const fmf_t *f = bgt->f->f;

	if (n == BGT_SET_ALL_SAMPLES) {
		for (i = 0; i < f->n_rows; ++i)
			bgt->gtag[i] = 1;
		size = f->n_rows;
		bgt->n_groups = 1;
	} else if (n > 0 || expr != 0) {
		int err, absent;
		khash_t(s2i) *h;
		kexpr_t *ke = 0;

		if (expr) {
			ke = ke_parse(expr, &err);
			if (err && ke) {
				ke_destroy(ke);
				ke = 0;
			}
			if (ke == 0) return -1;
		}
		h = kh_init(s2i);
		for (i = 0; i < n; ++i)
			kh_put(s2i, h, samples[i], &absent);
		for (i = 0, size = 0; i < f->n_rows; ++i) {
			int to_add = 0;
			if (ke && fmf_test(f, i, ke)) to_add = 1;
			if (kh_get(s2i, h, f->rows[i].name) != kh_end(h)) {
				int mgs = bgt->f->mgs[i] >= 0? bgt->f->mgs[i] : bgt->mgs_def;
				if (mgs == 1 || mgs == 0) to_add = 1;
			}
			if (to_add) ++size, bgt->gtag[i] = bgt->n_groups + 1;
		}
		kh_destroy(s2i, h);
		ke_destroy(ke);
		++bgt->n_groups;
	} else return -1;
	return size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x1c8ce
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0x1c8b4
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x2c(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c88a
movq -0x38(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x38(%rax)
jmp 0x1ca94
cmpl $0x0, -0x14(%rbp)
jg 0x1c8df
cmpq $0x0, -0x28(%rbp)
je 0x1ca89
movq $0x0, -0x50(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1c932
movq -0x28(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x22f50
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x1c91d
cmpq $0x0, -0x50(%rbp)
je 0x1c91d
movq -0x50(%rbp), %rdi
callq 0x23c00
movq $0x0, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x1c930
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ca9a
jmp 0x1c932
movb $0x0, %al
callq 0x7a30
movq %rax, -0x48(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1c970
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x40(%rbp), %rdx
callq 0x8140
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c944
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x2c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0x1ca68
movl $0x0, -0x54(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x1c9b8
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x50(%rbp), %rdx
callq 0xe1d0
cmpl $0x0, %eax
je 0x1c9b8
movl $0x1, -0x54(%rbp)
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x7b20
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
je 0x1ca30
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movslq -0x2c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x1ca0b
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x5c(%rbp)
jmp 0x1ca15
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x58(%rbp)
cmpl $0x1, -0x58(%rbp)
je 0x1ca27
cmpl $0x0, -0x58(%rbp)
jne 0x1ca2e
movl $0x1, -0x54(%rbp)
jmp 0x1ca30
cmpl $0x0, -0x54(%rbp)
je 0x1ca58
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %edx
addl $0x1, %edx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x2c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x1ca5a
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c97e
movq -0x48(%rbp), %rdi
callq 0x7a50
movq -0x50(%rbp), %rdi
callq 0x23c00
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
jmp 0x1ca92
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ca9a
jmp 0x1ca94
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)