// File: /workspace/github_c_makefile_star2_O3/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
movq 0x20(%rdi), %rax
movq %rax, (%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 0x136ae
movb 0x33(%r14), %al
andb $0x20, %al
shrb $0x5, %al
movzbl %al, %eax
shll $0x10, %eax
orq $0x20000, %rax          # imm = 0x20000
jmp 0x136b3
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 $0x2, 0x20(%rbx)
jb 0x136d9
movq 0x28(%rbx), %rax
movl $0x1, %edx
xorl %ecx, %ecx
jmp 0x136fb
movq $0x2, 0x20(%rbx)
movq 0x28(%rbx), %rdi
movl $0x2, %esi
callq 0x2330
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x18(%rbx)
movb $0x7, (%rax,%rcx)
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 0xd000
movl 0x10(%r14), %esi
addl (%r14), %esi
movq 0x18(%r14), %rdx
subl %edx, %esi
movq %r13, %rdi
callq 0xd000
cmpl $0x30000, 0x10(%rbx)    # imm = 0x30000
jb 0x13755
leaq 0xbe08(%rip), %rdx      # 0x1f550
movq %r13, %rdi
movl $0x3, %esi
callq 0xd000
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xc4ee
movl $0x0, 0x88(%rbx)
testl %r12d, %r12d
js 0x13c70
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
ja 0x137c8
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rcx
cmpq 0x38(%rbx), %rcx
jae 0x137f0
movq 0x40(%rbx), %rax
jmp 0x1383d
cmpl $0x7fff, %r12d          # imm = 0x7FFF
ja 0x13865
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rcx
cmpq 0x38(%rbx), %rcx
jae 0x138e2
movq 0x40(%rbx), %rax
jmp 0x1392f
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x38(%rbx)
movq 0x40(%rbx), %rdi
callq 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0x30(%rbx)
movb $0x11, (%rax,%rdx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rcx
cmpq 0x38(%rbx), %rcx
jae 0x13880
movq 0x40(%rbx), %rax
jmp 0x138cd
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rcx
cmpq 0x38(%rbx), %rcx
jae 0x1395e
movq 0x40(%rbx), %rax
jmp 0x139ab
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x38(%rbx)
movq 0x40(%rbx), %rdi
callq 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0x30(%rbx)
movb %r12b, (%rax,%rdx)
movq 0x40(%rbx), %rax
addq 0x30(%rbx), %rax
jmp 0x13a8b
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x38(%rbx)
movq 0x40(%rbx), %rdi
callq 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0x30(%rbx)
movb $0x12, (%rax,%rdx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x30(%rbx), %rcx
leaq 0x3(%rcx), %rax
cmpq 0x38(%rbx), %rax
jae 0x139d6
movq 0x40(%rbx), %rax
jmp 0x13a1f
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x38(%rbx)
movq 0x40(%rbx), %rdi
callq 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0x30(%rbx)
movb $0x13, (%rax,%rdx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x30(%rbx), %rcx
leaq 0x5(%rcx), %rax
cmpq 0x38(%rbx), %rax
jae 0x13a2e
movq 0x40(%rbx), %rax
jmp 0x13a77
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), %rcx
movw %r12w, (%rax,%rcx)
movq 0x30(%rbx), %rax
addq $0x2, %rax
jmp 0x13a83
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), %rcx
movl %r12d, (%rax,%rcx)
movq 0x30(%rbx), %rax
addq $0x4, %rax
movq %rax, 0x30(%rbx)
addq 0x40(%rbx), %rax
movb $0x0, (%rax)
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rcx
cmpq 0x38(%rbx), %rcx
jae 0x13aa2
movq 0x40(%rbx), %rax
jmp 0x13aef
movq %rcx, %rax
shrq %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x38(%rbx)
movq 0x40(%rbx), %rdi
callq 0x2330
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0x30(%rbx)
movb $0x21, (%rax,%rdx)
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 0x13b65
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 0x13bc6
cmpq %rax, 0x10(%rbx)
jb 0x13c64
xorl %eax, %eax
leaq 0xba34(%rip), %rcx      # 0x1f5bb
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 0x13b87
jmp 0x13c64
movq 0x10(%rbx), %rcx
testl %ebp, %ebp
je 0x13c1c
cmpq %rax, %rcx
jb 0x13c64
xorl %eax, %eax
leaq 0xb9e3(%rip), %rcx      # 0x1f5c3
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 0x13be0
jmp 0x13c64
cmpq %rax, %rcx
jb 0x13c64
xorl %eax, %eax
leaq 0xb995(%rip), %rcx      # 0x1f5bf
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 0x13c2a
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