// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0xc(%rax)
movq -0x10(%rbp), %rax
movabsq $0xffffffffff, %rcx     # imm = 0xFFFFFFFFFF
andq 0x10(%rax), %rcx
orq $0x0, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movabsq $-0xff00000001, %rcx    # imm = 0xFFFFFF00FFFFFFFF
andq 0x10(%rax), %rcx
orq $0x0, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
andq $-0x10000, %rcx         # imm = 0xFFFF0000
orq $0x0, %rcx
movq %rcx, 0x10(%rax)
xorl %eax, %eax
cmpl $0x0, -0x14(%rbp)
movb %al, -0x21(%rbp)
je 0x180ab
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
shrl $0x1d, %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %dl
movl $0x2, %ecx
movl $0x3, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x10(%rax), %rcx
andq $0xffff, %rdx           # imm = 0xFFFF
shlq $0x10, %rdx
movabsq $-0xffff0001, %rsi      # imm = 0xFFFFFFFF0000FFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
movl $0x7, %edx
callq 0x18400
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, %esi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
callq 0x11360
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
addq (%rcx), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
subq %rcx, %rax
movl %eax, %esi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdx
callq 0x11360
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
shrq $0x10, %rax
andq $0xffff, %rax           # imm = 0xFFFF
cmpl $0x2, %eax
jle 0x181a4
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movl $0x3, %esi
leaq 0x10257(%rip), %rdx     # 0x283f6
callq 0x11360
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x10ef0
movq -0x10(%rbp), %rax
movl $0x0, 0x88(%rax)
cmpl $0x0, -0x18(%rbp)
jl 0x183f9
movq -0x10(%rbp), %rax
movabsq $-0xff00000001, %rcx    # imm = 0xFFFFFF00FFFFFFFF
andq 0x10(%rax), %rcx
movabsq $0x100000000, %rdx      # imm = 0x100000000
orq %rdx, %rcx
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
sarl %ecx
movq -0x10(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x10(%rax), %rcx
andq $0xffffff, %rdx         # imm = 0xFFFFFF
shlq $0x28, %rdx
movabsq $0xffffffffff, %rsi     # imm = 0xFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movl -0x18(%rbp), %esi
callq 0x184d0
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x18400
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
shrq $0x28, %rax
shll %eax
cltq
addq %rax, %rsi
addq $0x1, %rsi
callq 0x185b0
cmpl $0x0, -0x14(%rbp)
je 0x182f9
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
shrq $0x28, %rcx
shll %ecx
cmpl %ecx, %eax
jge 0x182f4
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x16117(%rip), %rax     # 0x2e3d0
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl 0x30(%rcx), %ecx
shrl $0x1f, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rsi
movq 0x30(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x30(%rsi)
movb %dl, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1828b
jmp 0x183e5
cmpl $0x0, -0x1c(%rbp)
je 0x18371
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
shrq $0x28, %rcx
shll %ecx
cmpl %ecx, %eax
jge 0x1836f
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x160a4(%rip), %rax     # 0x2e3d8
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl 0x30(%rcx), %ecx
shrl $0x1f, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rsi
movq 0x30(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x30(%rsi)
movb %dl, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x18306
jmp 0x183e3
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
shrq $0x28, %rcx
shll %ecx
cmpl %ecx, %eax
jge 0x183e1
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x1602e(%rip), %rax     # 0x2e3d4
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl 0x30(%rcx), %ecx
shrl $0x1f, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rsi
movq 0x30(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x30(%rsi)
movb %dl, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x18378
jmp 0x183e3
jmp 0x183e5
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x30(%rcx), %rcx
movb $0x0, (%rax,%rcx)
addq $0x30, %rsp
popq %rbp
retq
nop