// File: /workspace/github_cpp_makefile_star2_O3/auton1[P]viterbi/bcf_entry_setters.cpp
// Function: bcf_entry::set_indv_GENOTYPE_and_PHASE(unsigned int, unsigned int const&, unsigned int const&)
void bcf_entry::set_indv_GENOTYPE_and_PHASE(unsigned int indv, const unsigned int &pos, const unsigned int &size)
{
	int8_t tmp, tmp2;
	unsigned int cur_pos = pos;
	char phased[2] = {'/', '|'};
	ploidy.resize(N_indv);
	ploidy[indv] = 0;

	for (unsigned int ui=0; ui<size; ui++)
	{
		tmp = *reinterpret_cast<const int8_t*>(&line[cur_pos]);
		if ( tmp == (int8_t)0x81 )
			break;
		ploidy[indv]++;
		cur_pos += sizeof(int8_t);
	}

	if (ploidy[indv] == 0)
	{
		set_indv_GENOTYPE_alleles(indv, make_pair(-2, -2));
	}
	else if (ploidy[indv] == 1)
	{
		set_indv_PHASE(indv, '|');
		tmp = *reinterpret_cast<const int8_t*>(&line[pos]);
		if (tmp == (int8_t)0x80)
			tmp = -1;
		else
			tmp = (tmp >> 1) - 1;
		set_indv_GENOTYPE_alleles(indv, make_pair(tmp, -2));
	}
	else if (ploidy[indv] == 2)
	{
		tmp = *reinterpret_cast<const int8_t*>(&line[pos]);
		tmp2 = *reinterpret_cast<const int8_t*>(&line[pos+sizeof(int8_t)]);

		if (tmp == (int8_t)0x80)
			tmp = -1;
		else
			tmp = (tmp >> 1) - 1;

		if (tmp2 == (int8_t)0x80)
		{
			tmp2 = -1;
			set_indv_PHASE(indv, '/');
		}
		else
		{
			char phase = phased[ tmp2 & (int8_t)1 ];
			tmp2 = (tmp2 >> 1) - 1;
			set_indv_PHASE(indv, phase);
		}
		set_indv_GENOTYPE_alleles(indv, make_pair((int)tmp, (int)tmp2));
	}
	else if (ploidy[indv] > 2)
		LOG.error("Polyploidy found, and is not supported by vcftools: " + CHROM + ":" + header::int2str(POS));
	parsed_GT[indv] = true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %r12
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rbx
movl (%rdx), %r13d
addq $0x4e8, %rdi            # imm = 0x4E8
movl 0x8(%rbx), %esi
callq 0xc17a
movl %ebp, %r14d
movq 0x4e8(%rbx), %rcx
movl $0x0, (%rcx,%r14,4)
cmpl $0x0, (%r12)
je 0x27c16
movq 0x3c0(%rbx), %rdx
xorl %eax, %eax
leal (%rax,%r13), %esi
cmpb $-0x7f, (%rdx,%rsi)
je 0x27c04
incl %eax
movl %eax, (%rcx,%r14,4)
cmpl (%r12), %eax
jb 0x27bee
cmpl $0x2, %eax
je 0x27c72
cmpl $0x1, %eax
je 0x27c2d
testl %eax, %eax
jne 0x27cca
movabsq $-0x100000002, %rax     # imm = 0xFFFFFFFEFFFFFFFE
leaq 0x8(%rsp), %rdx
movq %rax, (%rdx)
jmp 0x27d6f
movq %rbx, %rdi
movl %ebp, %esi
movl $0x7c, %edx
callq 0x27fbc
movl (%r15), %eax
movq 0x3c0(%rbx), %rcx
movb (%rcx,%rax), %al
movl %eax, %ecx
sarb %cl
decb %cl
cmpb $-0x80, %al
movzbl %cl, %eax
movl $0xff, %ecx
cmovnel %eax, %ecx
movsbl %cl, %eax
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
movl $0xfffffffe, 0x4(%rdx)  # imm = 0xFFFFFFFE
jmp 0x27d6f
movl (%r15), %eax
movq 0x3c0(%rbx), %rcx
movb (%rcx,%rax), %dl
movzbl 0x1(%rcx,%rax), %r12d
movl %edx, %eax
sarb %al
decb %al
cmpb $-0x80, %dl
movzbl %al, %eax
movl $0xff, %r15d
cmovnel %eax, %r15d
cmpq $0x80, %r12
jne 0x27d2b
movq %rbx, %rdi
movl %ebp, %esi
movl $0x2f, %edx
callq 0x27fbc
movabsq $-0x100000002, %rax     # imm = 0xFFFFFFFEFFFFFFFE
addq $0x2, %rax
jmp 0x27d5e
cmpl $0x3, %eax
jl 0x27d79
leaq 0x3e0(%rbx), %rdx
leaq 0x11fd1(%rip), %rsi     # 0x39cb2
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0xb777
leaq 0x12398(%rip), %rsi     # 0x3a08d
movq %r15, %rdi
callq 0x5870
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x27da7
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x27dae
movl %r12d, %eax
andl $0x1, %eax
leaq 0x11f58(%rip), %rcx     # 0x39c90
movsbl (%rax,%rcx), %edx
sarb %r12b
movq %rbx, %rdi
movl %ebp, %esi
callq 0x27fbc
movsbq %r12b, %rcx
shlq $0x20, %rcx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
addq %rcx, %rax
movsbq %r15b, %rcx
movl %ecx, %ecx
orq %rax, %rcx
leaq 0x8(%rsp), %rdx
movq %rcx, (%rdx)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x27f4a
movq 0x560(%rbx), %rax
movl %r14d, %edx
movl $0x1, %esi
movl %r14d, %ecx
shlq %cl, %rsi
shrl $0x6, %edx
orq %rsi, (%rax,%rdx,8)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl 0x400(%rbx), %esi
leaq 0x48(%rsp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x1720e
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r8
movq 0x50(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r15, %rcx
je 0x27dfd
movq 0x18(%rsp), %rdi
movq 0x48(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x27e20
leaq 0x58(%rsp), %r9
movl $0xf, %edi
cmpq %r9, %rsi
je 0x27e1b
movq 0x58(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x27e2c
leaq 0x8(%rsp), %rdi
callq 0x50f0
jmp 0x27e3a
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x54d0
leaq 0x38(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x27e5e
movq %rsi, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x27e64
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x21620(%rip), %rdi     # 0x494a8
leaq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x36ec8
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x27eaa
callq 0x5410
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x27ebd
callq 0x5410
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x27ecc
callq 0x5410
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x27d79
callq 0x5410
jmp 0x27d79
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x27f03
callq 0x5410
jmp 0x27f03
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x27f1b
callq 0x5410
jmp 0x27f1b
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x27f2f
callq 0x5410
jmp 0x27f2f
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x27f42
callq 0x5410
movq %rbx, %rdi
callq 0x57d0