// File: /workspace/github_c_makefile_star2_O1/lh3[P]bgt/atomic.c
// Function: bcf_atom2bcf2
void bcf_atom2bcf2(const bcf_atom_t *a, bcf1_t *b, int write_M, int id_GT, int use_missing)
{
	static uint8_t conv[4] = { 1<<1, 2<<1, 0<<1, 3<<1 };
	static uint8_t conv_no_M[4] = { 1<<1, 2<<1, 0<<1, 1<<1 };
	static uint8_t conv_no_M_missing[4] = { 1<<1, 2<<1, 0<<1, 0<<1 };
	b->rid = a->rid, b->pos = a->pos, b->rlen = a->rlen;
	b->qual = 0, b->n_info = b->n_fmt = b->n_sample = 0;
	b->n_allele = write_M && a->has_multi? 3 : 2;
	b->shared.l = b->indiv.l = 0;
	bcf_enc_size(&b->shared, 0, BCF_BT_CHAR); // empty ID
	bcf_enc_vchar(&b->shared, a->alt - a->ref.s - 1, a->ref.s);
	bcf_enc_vchar(&b->shared, a->ref.s + a->ref.l - a->alt, a->alt);
	if (b->n_allele > 2) bcf_enc_vchar(&b->shared, 3, "<M>");
	bcf_enc_vint(&b->shared, 0, 0, -1); // empty FILTER
	b->unpacked = 0;

	if (id_GT >= 0) {
		int i;
		b->n_fmt = 1; b->n_sample = a->n_gt>>1;
		bcf_enc_int1(&b->indiv, id_GT);
		bcf_enc_size(&b->indiv, 2, BCF_BT_INT8);
		ks_resize(&b->indiv, b->indiv.l + b->n_sample*2 + 1);
		if (write_M) {
			for (i = 0; i < b->n_sample<<1; ++i)
				b->indiv.s[b->indiv.l++] = conv[a->gt[i]] | a->phased;
		} else {
			if (use_missing)
				for (i = 0; i < b->n_sample<<1; ++i)
					b->indiv.s[b->indiv.l++] = conv_no_M_missing[a->gt[i]] | a->phased;
			else
				for (i = 0; i < b->n_sample<<1; ++i)
					b->indiv.s[b->indiv.l++] = conv_no_M[a->gt[i]] | a->phased;
		}
		b->indiv.s[b->indiv.l] = 0;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebp
movl %ecx, %r12d
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
movl 0x20(%rdi), %eax
movl %eax, (%rsi)
movl 0x24(%rdi), %eax
movl %eax, 0x4(%rsi)
movl 0x28(%rdi), %eax
movl %eax, 0x8(%rsi)
movl $0x0, 0xc(%rsi)
movzwl 0x12(%rsi), %eax
shll $0x10, %eax
movq %rax, 0x10(%rsi)
testl %edx, %edx
je 0x132e1
movb 0x33(%r14), %al
andb $0x20, %al
shrb $0x5, %al
movzbl %al, %eax
shll $0x10, %eax
orq $0x20000, %rax          # imm = 0x20000
jmp 0x132e6
movl $0x20000, %eax          # imm = 0x20000
movq %rax, 0x10(%rbx)
xorl %eax, %eax
movq %rax, 0x30(%rbx)
leaq 0x18(%rbx), %r13
movq %rax, 0x18(%rbx)
cmpq $0x1, 0x20(%rbx)
ja 0x13319
movq $0x2, 0x20(%rbx)
movq 0x28(%rbx), %rdi
movl $0x2, %esi
callq 0x2330
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rax
movq 0x28(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x18(%rbx)
movb $0x7, (%rcx,%rax)
movq 0x18(%rbx), %rax
movq 0x28(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x10(%r14), %rdx
movl %edx, %esi
notl %esi
addl 0x18(%r14), %esi
movq %r13, %rdi
callq 0xce10
movl 0x10(%r14), %esi
addl (%r14), %esi
movq 0x18(%r14), %rdx
subl %edx, %esi
movq %r13, %rdi
callq 0xce10
cmpl $0x30000, 0x10(%rbx)    # imm = 0x30000
jb 0x1337f
leaq 0xc1d3(%rip), %rdx      # 0x1f545
movq %r13, %rdi
movl $0x3, %esi
callq 0xce10
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xc356
movl $0x0, 0x88(%rbx)
testl %r12d, %r12d
js 0x13876
movabsq $-0xff00000001, %rax    # imm = 0xFFFFFF00FFFFFFFF
andq 0x10(%rbx), %rax
btsq $0x20, %rax
movq %rax, 0x10(%rbx)
movl 0x2c(%r14), %ecx
shrl %ecx
shlq $0x28, %rcx
movabsq $0x1ffffffff, %rdx      # imm = 0x1FFFFFFFF
andq %rax, %rdx
orq %rcx, %rdx
movq %rdx, 0x10(%rbx)
cmpl $0x7f, %r12d
jg 0x134c7
movq 0x30(%rbx), %rax
incq %rax
cmpq 0x38(%rbx), %rax
jb 0x13434
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 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x30(%rbx)
movb $0x11, (%rcx,%rax)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x30(%rbx), %rax
incq %rax
cmpq 0x38(%rbx), %rax
jb 0x134a6
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 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x30(%rbx)
movb %r12b, (%rcx,%rax)
movq 0x40(%rbx), %rax
addq 0x30(%rbx), %rax
jmp 0x13694
cmpl $0x7fff, %r12d          # imm = 0x7FFF
jg 0x135b3
movq 0x30(%rbx), %rax
incq %rax
cmpq 0x38(%rbx), %rax
jb 0x13526
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 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x30(%rbx)
movb $0x12, (%rcx,%rax)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x30(%rbx), %rax
addq $0x3, %rax
cmpq 0x38(%rbx), %rax
jb 0x13599
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 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movw %r12w, (%rcx,%rax)
movq 0x30(%rbx), %rax
addq $0x2, %rax
jmp 0x1368c
movq 0x30(%rbx), %rax
incq %rax
cmpq 0x38(%rbx), %rax
jb 0x13605
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 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x30(%rbx)
movb $0x13, (%rcx,%rax)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x30(%rbx), %rax
addq $0x5, %rax
cmpq 0x38(%rbx), %rax
jb 0x13678
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 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movl %r12d, (%rcx,%rax)
movq 0x30(%rbx), %rax
addq $0x4, %rax
movq %rax, 0x30(%rbx)
addq 0x40(%rbx), %rax
movb $0x0, (%rax)
movq 0x30(%rbx), %rax
incq %rax
cmpq 0x38(%rbx), %rax
jb 0x136e9
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 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x30(%rbx)
movb $0x21, (%rcx,%rax)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x10(%rbx), %rax
movq 0x30(%rbx), %rcx
shrq $0x28, %rax
leaq (%rcx,%rax,2), %rdx
incq %rdx
cmpq %rdx, 0x38(%rbx)
jae 0x1376b
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 0x2330
movq %rax, 0x40(%rbx)
movabsq $0x10000000000, %rax    # imm = 0x10000000000
testl %r15d, %r15d
je 0x137cc
cmpq %rax, 0x10(%rbx)
jb 0x1386a
xorl %eax, %eax
leaq 0xbe23(%rip), %rcx      # 0x1f5b0
movq 0x38(%r14), %rdx
movzbl (%rdx,%rax), %edx
movl 0x30(%r14), %esi
shrl $0x1f, %esi
orb (%rdx,%rcx), %sil
movq 0x30(%rbx), %rdx
movq 0x40(%rbx), %rdi
leaq 0x1(%rdx), %r8
movq %r8, 0x30(%rbx)
movb %sil, (%rdi,%rdx)
incq %rax
movq 0x10(%rbx), %rdx
shrq $0x27, %rdx
andl $-0x2, %edx
cmpq %rdx, %rax
jb 0x1378d
jmp 0x1386a
movq 0x10(%rbx), %rcx
testl %ebp, %ebp
je 0x13822
cmpq %rax, %rcx
jb 0x1386a
xorl %eax, %eax
leaq 0xbdd2(%rip), %rcx      # 0x1f5b8
movq 0x38(%r14), %rdx
movzbl (%rdx,%rax), %edx
movl 0x30(%r14), %esi
shrl $0x1f, %esi
orb (%rdx,%rcx), %sil
movq 0x30(%rbx), %rdx
movq 0x40(%rbx), %rdi
leaq 0x1(%rdx), %r8
movq %r8, 0x30(%rbx)
movb %sil, (%rdi,%rdx)
incq %rax
movq 0x10(%rbx), %rdx
shrq $0x27, %rdx
andl $-0x2, %edx
cmpq %rdx, %rax
jb 0x137e6
jmp 0x1386a
cmpq %rax, %rcx
jb 0x1386a
xorl %eax, %eax
leaq 0xbd84(%rip), %rcx      # 0x1f5b4
movq 0x38(%r14), %rdx
movzbl (%rdx,%rax), %edx
movl 0x30(%r14), %esi
shrl $0x1f, %esi
orb (%rdx,%rcx), %sil
movq 0x30(%rbx), %rdx
movq 0x40(%rbx), %rdi
leaq 0x1(%rdx), %r8
movq %r8, 0x30(%rbx)
movb %sil, (%rdi,%rdx)
incq %rax
movq 0x10(%rbx), %rdx
shrq $0x27, %rdx
andl $-0x2, %edx
cmpq %rdx, %rax
jb 0x13830
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movb $0x0, (%rcx,%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq