// File: /workspace/github_c_makefile_star2_O2/lh3[P]bgt/vcf.c
// Function: bcf_unpack
int bcf_unpack(bcf1_t *b, int which)
{
	uint8_t *ptr = (uint8_t*)b->shared.s;
	int *offset, i;
	bcf_dec_t *d = &b->d;
	if (which & BCF_UN_FLT) which |= BCF_UN_STR;
	if (which & BCF_UN_INFO) which |= BCF_UN_SHR;
	if ((which&BCF_UN_STR) && !(b->unpacked&BCF_UN_STR)) { // ID
		kstring_t tmp;
		tmp.l = 0; tmp.m = d->m_str; tmp.s = d->id;
		ptr = bcf_fmt_sized_array(&tmp, ptr); kputc('\0', &tmp);
		// REF and ALT
		offset = (int*)alloca(b->n_allele * sizeof(int));
		for (i = 0; i < b->n_allele; ++i) {
			offset[i] = tmp.l;
			ptr = bcf_fmt_sized_array(&tmp, ptr);
			kputc('\0', &tmp);
		}
		hts_expand(char*, b->n_allele, d->m_allele, d->allele); // NM: hts_expand() is a macro
		for (i = 0; i < b->n_allele; ++i)
			d->allele[i] = tmp.s + offset[i];
		d->m_str = tmp.m; d->id = tmp.s; // write tmp back
		b->unpack_ptr = ptr;
		b->unpacked |= BCF_UN_STR;
	}
	if ((which&BCF_UN_FLT) && !(b->unpacked&BCF_UN_FLT)) { // FILTER
		ptr = b->unpack_ptr;
		if (*ptr>>4) {
			int type;
			d->n_flt = bcf_dec_size(ptr, &ptr, &type);
			hts_expand(int, d->n_flt, d->m_flt, d->flt);
			for (i = 0; i < d->n_flt; ++i)
				d->flt[i] = bcf_dec_int1(ptr, type, &ptr);
		} else ++ptr, d->n_flt = 0;
		b->unpack_ptr = ptr;
		b->unpacked |= BCF_UN_FLT;
	}
	if ((which&BCF_UN_INFO) && !(b->unpacked&BCF_UN_INFO)) { // INFO
		ptr = b->unpack_ptr;
		hts_expand(bcf_info_t, b->n_info, d->m_info, d->info);
		bcf_unpack_info_core(ptr, b->n_info, d->info);
		b->unpacked |= BCF_UN_INFO;
	}
	if ((which&BCF_UN_FMT) && b->n_sample && !(b->unpacked&BCF_UN_FMT)) { // FORMAT
		hts_expand(bcf_fmt_t, b->n_fmt, d->m_fmt, d->fmt);
		bcf_unpack_fmt_core((uint8_t*)b->indiv.s, b->n_sample, b->n_fmt, d->fmt);
		b->unpacked |= BCF_UN_FMT;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %r14d
movq %rdi, %rbx
movl %esi, %eax
shrl %eax
andl $0x1, %eax
testb $0x4, %r14b
pushq $0x7
popq %r15
cmovel %eax, %r15d
orl %esi, %r15d
testb $0x1, %r15b
je 0xc7eb
testb $0x1, 0x88(%rbx)
jne 0xc7eb
movl %r15d, -0x2c(%rbp)
movl %r14d, -0x30(%rbp)
movq 0x28(%rbx), %rsi
leaq -0x50(%rbp), %r12
andq $0x0, (%r12)
movslq 0x50(%rbx), %rax
movq %rax, 0x8(%r12)
movq 0x60(%rbx), %rax
movq %rax, 0x10(%r12)
movq %r12, %rdi
callq 0xb3ff
movq %rax, %r15
xorl %r13d, %r13d
xorl %edi, %edi
movq %r12, %rsi
callq 0xacb6
movq 0x10(%rbx), %rax
movl %eax, %ecx
shrl $0x10, %ecx
leal 0xf(,%rcx,4), %ecx
andl $-0x10, %ecx
movq %rsp, %r14
subq %rcx, %r14
movq %r14, %rsp
shrl $0x10, %eax
cmpq %rax, %r13
jae 0xc761
movl -0x50(%rbp), %eax
movl %eax, (%r14,%r13,4)
movq %r12, %rdi
movq %r15, %rsi
callq 0xb3ff
movq %rax, %r15
xorl %edi, %edi
movq %r12, %rsi
callq 0xacb6
incq %r13
movq 0x10(%rbx), %rax
jmp 0xc731
cmpl 0x54(%rbx), %eax
jle 0xc7a8
decl %eax
movl %eax, %ecx
sarl %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x8, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x10, %ecx
orl %eax, %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x54(%rbx)
movq 0x68(%rbx), %rdi
movslq %ecx, %rax
leaq 0x8(,%rax,8), %rsi
callq 0x2340
movq %rax, 0x68(%rbx)
movq -0x40(%rbp), %rax
xorl %ecx, %ecx
movzwl 0x12(%rbx), %edx
cmpq %rdx, %rcx
jae 0xc7cb
movslq (%r14,%rcx,4), %rdx
addq %rax, %rdx
movq 0x68(%rbx), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
jmp 0xc7ae
movl -0x48(%rbp), %ecx
movl %ecx, 0x50(%rbx)
movq %rax, 0x60(%rbx)
movq %r15, 0x90(%rbx)
orb $0x1, 0x88(%rbx)
movl -0x30(%rbp), %r14d
movl -0x2c(%rbp), %r15d
testb $0x2, %r15b
je 0xc8cb
movl 0x88(%rbx), %eax
testb $0x2, %al
jne 0xc8cb
movq 0x90(%rbx), %rdi
movq %rdi, -0x50(%rbp)
cmpb $0x10, (%rdi)
jae 0xc81f
incq %rdi
andl $0x0, 0x5c(%rbx)
jmp 0xc8bb
leaq -0x50(%rbp), %rsi
leaq -0x34(%rbp), %rdx
callq 0xb45d
movl %eax, 0x5c(%rbx)
cmpl 0x58(%rbx), %eax
jle 0xc876
decl %eax
movl %eax, %ecx
sarl %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x8, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x10, %ecx
orl %eax, %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x58(%rbx)
movq 0x70(%rbx), %rdi
movslq %ecx, %rax
leaq 0x4(,%rax,4), %rsi
callq 0x2340
movq %rax, 0x70(%rbx)
movq -0x50(%rbp), %rdi
movl -0x34(%rbp), %eax
xorl %ecx, %ecx
movslq 0x5c(%rbx), %rdx
cmpq %rdx, %rcx
jge 0xc8b5
cmpl $0x2, %eax
je 0xc89a
cmpl $0x1, %eax
jne 0xc8a3
movsbl (%rdi), %edx
incq %rdi
jmp 0xc8a9
movswl (%rdi), %edx
addq $0x2, %rdi
jmp 0xc8a9
movl (%rdi), %edx
addq $0x4, %rdi
movq 0x70(%rbx), %rsi
movl %edx, (%rsi,%rcx,4)
incq %rcx
jmp 0xc87f
movl 0x88(%rbx), %eax
movq %rdi, 0x90(%rbx)
orl $0x2, %eax
movl %eax, 0x88(%rbx)
testb $0x4, %r15b
je 0xc942
testb $0x4, 0x88(%rbx)
jne 0xc942
movq 0x90(%rbx), %r15
movzwl 0x10(%rbx), %esi
cmpl 0x4c(%rbx), %esi
jle 0xc92f
decl %esi
movl %esi, %eax
sarl %eax
orl %esi, %eax
movl %eax, %ecx
sarl $0x2, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x4, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x8, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x10, %eax
orl %ecx, %eax
incl %eax
movl %eax, 0x4c(%rbx)
movq 0x78(%rbx), %rdi
cltq
imulq $0x18, %rax, %rsi
callq 0x2340
movq %rax, %rdx
movq %rax, 0x78(%rbx)
movzwl 0x10(%rbx), %esi
jmp 0xc933
movq 0x78(%rbx), %rdx
movq %r15, %rdi
callq 0xc5c7
orb $0x4, 0x88(%rbx)
testb $0x8, %r14b
je 0xc9e5
movq 0x10(%rbx), %rsi
movq %rsi, %rax
shrq $0x28, %rax
je 0xc9e5
testb $0x8, 0x88(%rbx)
jne 0xc9e5
movq %rsi, %rax
shrq $0x20, %rax
movzbl %al, %edx
cmpl 0x48(%rbx), %edx
jle 0xc9ca
decl %edx
movl %edx, %eax
sarl %eax
orl %edx, %eax
movl %eax, %ecx
sarl $0x2, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x4, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x8, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x10, %eax
orl %ecx, %eax
incl %eax
movl %eax, 0x48(%rbx)
movq 0x80(%rbx), %rdi
cltq
imulq $0x18, %rax, %rsi
callq 0x2340
movq %rax, %rcx
movq %rax, 0x80(%rbx)
movq 0x10(%rbx), %rsi
movq %rsi, %rax
shrq $0x20, %rax
movzbl %al, %edx
jmp 0xc9d1
movq 0x80(%rbx), %rcx
movq 0x40(%rbx), %rdi
shrq $0x28, %rsi
callq 0xc52c
orb $0x8, 0x88(%rbx)
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq