// File: /workspace/github_c_makefile_star2_O2/lh3[P]bgt/bgt.c
// Function: bgt_gen_gt
void bgt_gen_gt(const bcf_hdr_t *h, bcf1_t *b, int m, const uint8_t **a, int32_t *mgs)
{
	int id, i, m2 = m;
	b->indiv.l = 0;
	if (mgs) {
		for (i = m2 = 0; i < m; ++i)
			m2 += (mgs[i] <= 1);
		if (m2 == 0) return;
	}
	id = bcf_id2int(h, BCF_DT_ID, "GT");
	b->n_fmt = 1; b->n_sample = m2;
	bcf_enc_int1(&b->indiv, id);
	bcf_enc_size(&b->indiv, 2, BCF_BT_INT8);
	ks_resize(&b->indiv, b->indiv.l + b->n_sample*2 + 1);
	if (mgs) {
		for (i = 0; i < m<<1; ++i)
			if (mgs[i>>1] <= 1)
				b->indiv.s[b->indiv.l++] = bgt_bits2gt[a[1][i]<<1 | a[0][i]];
	} else {
		for (i = 0; i < m<<1; ++i)
			b->indiv.s[b->indiv.l++] = bgt_bits2gt[a[1][i]<<1 | a[0][i]];
	}
	b->indiv.s[b->indiv.l] = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r15
movq %rcx, %r14
movq %rsi, %rbx
andq $0x0, 0x30(%rsi)
movl %edx, %r12d
testq %r8, %r8
je 0x11d0d
xorl %eax, %eax
testl %edx, %edx
movl $0x0, %ecx
cmovgl %edx, %ecx
xorl %r12d, %r12d
cmpq %rax, %rcx
je 0x11d04
xorl %esi, %esi
cmpl $0x2, (%r15,%rax,4)
setl %sil
addl %esi, %r12d
incq %rax
jmp 0x11cec
testl %r12d, %r12d
je 0x11ee5
movl %edx, 0xc(%rsp)
leaq 0x30(%rbx), %rbp
leaq 0x65a4(%rip), %rdx      # 0x182c0
xorl %esi, %esi
callq 0xcee5
movl %eax, %r13d
movl 0x10(%rbx), %eax
shlq $0x28, %r12
orq %rax, %r12
btsq $0x20, %r12
movq %r12, 0x10(%rbx)
movl %r13d, %eax
negl %eax
jno 0x11d5b
pushq $0x11
popq %rdi
movq %rbp, %rsi
callq 0x11b3c
pushq $-0x80
popq %rdi
movq %rbp, %rsi
callq 0x11b3c
movq %rbp, %r12
jmp 0x11d7f
leal 0x7f(%r13), %eax
cmpl $0xfe, %eax
ja 0x11d85
pushq $0x11
popq %rdi
movq %rbp, %r12
movq %rbp, %rsi
callq 0x11b3c
movl %r13d, %edi
movq %rbp, %rsi
callq 0x11b3c
movl 0xc(%rsp), %ebp
jmp 0x11dda
movl %r13d, %eax
addl $0x7fff, %eax           # imm = 0x7FFF
cmpl $0xfffe, %eax           # imm = 0xFFFE
movq %rbp, %r12
movl 0xc(%rsp), %ebp
ja 0x11db6
leaq 0x12(%rsp), %rax
movw %r13w, (%rax)
movq %rax, %r13
pushq $0x12
popq %rdi
movq %r12, %rsi
callq 0x11b3c
pushq $0x2
jmp 0x11dce
leaq 0x14(%rsp), %rax
movl %r13d, (%rax)
movq %rax, %r13
pushq $0x13
popq %rdi
movq %r12, %rsi
callq 0x11b3c
pushq $0x4
popq %rsi
movq %r13, %rdi
movq %r12, %rdx
callq 0x11a85
pushq $0x21
popq %rdi
movq %r12, %rsi
callq 0x11b3c
movq 0x10(%rbx), %rax
movq 0x30(%rbx), %rcx
shrq $0x28, %rax
leaq (%rcx,%rax,2), %rdx
incq %rdx
cmpq %rdx, 0x38(%rbx)
jae 0x11e47
leaq (%rcx,%rax,2), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x38(%rbx)
movq 0x40(%rbx), %rdi
callq 0x2340
movq %rax, 0x40(%rbx)
addl %ebp, %ebp
xorl %eax, %eax
testl %ebp, %ebp
cmovgl %ebp, %eax
xorl %ecx, %ecx
leaq 0xf547(%rip), %rdx      # 0x213a0
testq %r15, %r15
je 0x11ed4
cmpq %rcx, %rax
je 0x11ed9
movl %ecx, %esi
shrl %esi
cmpl $0x1, (%r15,%rsi,4)
jg 0x11e9d
movq (%r14), %rsi
movq 0x8(%r14), %rdi
movzbl (%rdi,%rcx), %edi
movzbl (%rsi,%rcx), %esi
shll $0x2, %esi
shll $0x3, %edi
orl %esi, %edi
movb (%rdi,%rdx), %sil
movq 0x30(%rbx), %rdi
movq 0x40(%rbx), %r8
leaq 0x1(%rdi), %r9
movq %r9, 0x30(%rbx)
movb %sil, (%r8,%rdi)
incq %rcx
jmp 0x11e5e
movq (%r14), %rsi
movq 0x8(%r14), %rdi
movzbl (%rdi,%rcx), %edi
movzbl (%rsi,%rcx), %esi
shll $0x2, %esi
shll $0x3, %edi
orl %esi, %edi
movb (%rdi,%rdx), %sil
movq 0x30(%rbx), %rdi
movq 0x40(%rbx), %r8
leaq 0x1(%rdi), %r9
movq %r9, 0x30(%rbx)
movb %sil, (%r8,%rdi)
incq %rcx
cmpq %rcx, %rax
jne 0x11ea2
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movb $0x0, (%rcx,%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq