// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/vcf.c
// Function: bcf_unpack
int bcf_unpack(bcf1_t *b, int which)
{
    if ( !b->shared.l ) return 0; // Building a new BCF record from scratch
    uint8_t *ptr = (uint8_t*)b->shared.s, *ptr_ori;
    int 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))
    {
        kstring_t tmp;

        // ID
        tmp.l = 0; tmp.s = d->id; tmp.m = d->m_id;
        ptr_ori = ptr;
        ptr = bcf_fmt_sized_array(&tmp, ptr);
        b->unpack_size[0] = ptr - ptr_ori;
        kputc_('\0', &tmp);
        d->id = tmp.s; d->m_id = tmp.m;

        // REF and ALT are in a single block (d->als) and d->alleles are pointers into this block
        hts_expand(char*, b->n_allele, d->m_allele, d->allele); // NM: hts_expand() is a macro
        tmp.l = 0; tmp.s = d->als; tmp.m = d->m_als;
        ptr_ori = ptr;
        for (i = 0; i < b->n_allele; ++i) {
            // Use offset within tmp.s as realloc may change pointer
            d->allele[i] = (char *)(intptr_t)tmp.l;
            ptr = bcf_fmt_sized_array(&tmp, ptr);
            kputc_('\0', &tmp);
        }
        b->unpack_size[1] = ptr - ptr_ori;
        d->als = tmp.s; d->m_als = tmp.m;

        // Convert our offsets within tmp.s back to pointers again
        for (i = 0; i < b->n_allele; ++i)
            d->allele[i] = d->als + (ptrdiff_t)d->allele[i];
        b->unpacked |= BCF_UN_STR;
    }
    if ((which&BCF_UN_FLT) && !(b->unpacked&BCF_UN_FLT)) { // FILTER
        ptr = (uint8_t*)b->shared.s + b->unpack_size[0] + b->unpack_size[1];
        ptr_ori = 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_size[2] = ptr - ptr_ori;
        b->unpacked |= BCF_UN_FLT;
    }
    if ((which&BCF_UN_INFO) && !(b->unpacked&BCF_UN_INFO)) { // INFO
        ptr = (uint8_t*)b->shared.s + b->unpack_size[0] + b->unpack_size[1] + b->unpack_size[2];
        hts_expand(bcf_info_t, b->n_info, d->m_info, d->info);
        for (i = 0; i < d->m_info; ++i) d->info[i].vptr_free = 0;
        for (i = 0; i < b->n_info; ++i)
            ptr = bcf_unpack_info_core1(ptr, &d->info[i]);
        b->unpacked |= BCF_UN_INFO;
    }
    if ((which&BCF_UN_FMT) && b->n_sample && !(b->unpacked&BCF_UN_FMT)) { // FORMAT
        ptr = (uint8_t*)b->indiv.s;
        hts_expand(bcf_fmt_t, b->n_fmt, d->m_fmt, d->fmt);
        for (i = 0; i < d->m_fmt; ++i) d->fmt[i].p_free = 0;
        for (i = 0; i < b->n_fmt; ++i)
            ptr = bcf_unpack_fmt_core1(ptr, b->n_sample, &d->fmt[i]);
        b->unpacked |= BCF_UN_FMT;
    }
    return 0;
}

// Assembly:
cmpq $0x0, 0x20(%rdi)
je 0x2b5bc
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, %eax
shrl %eax
andl $0x1, %eax
testb $0x4, %bpl
pushq $0x7
popq %r15
cmovel %eax, %r15d
orl %esi, %r15d
pushq $0x1
popq %r14
testb $0x1, %r15b
je 0x2b329
testb $0x1, 0xbc(%rbx)
jne 0x2b329
movq 0x30(%rbx), %r12
leaq 0x20(%rsp), %r13
andq $0x0, (%r13)
movq 0x78(%rbx), %rax
movq %rax, 0x10(%r13)
movslq 0x58(%rbx), %rax
movq %rax, 0x8(%r13)
movq %r13, %rdi
movq %r12, %rsi
callq 0x284ff
movq %rax, 0x10(%rsp)
movq %rax, 0x18(%rsp)
subl %r12d, %eax
movl %eax, 0xc0(%rbx)
xorl %edi, %edi
movq %r13, %rsi
callq 0x284c4
movq 0x10(%r13), %rax
movq %rax, 0x78(%rbx)
movl 0x8(%r13), %eax
movl %eax, 0x58(%rbx)
movl 0x18(%rbx), %eax
movl %eax, %edi
shrl $0x10, %edi
movslq 0x60(%rbx), %rsi
cmpl %esi, %edi
jle 0x2b278
cmpl $0x10000, %eax          # imm = 0x10000
cmovbl %r14d, %edi
leaq 0x88(%rbx), %r9
leaq 0x5b844(%rip), %rax     # 0x86aa7
movq %rax, (%rsp)
pushq $0x4
popq %rdx
pushq $0x8
popq %rcx
xorl %r8d, %r8d
callq 0xef4f
movl %eax, 0x60(%rbx)
leaq 0x20(%rsp), %r12
andq $0x0, (%r12)
movq 0x80(%rbx), %rax
movq %rax, 0x10(%r12)
movslq 0x5c(%rbx), %rax
movq %rax, 0x8(%r12)
xorl %r14d, %r14d
movq 0x18(%rsp), %r13
movq 0x18(%rbx), %rax
movl %eax, %ecx
shrl $0x10, %ecx
cmpq %rcx, %r14
jae 0x2b2da
movq 0x20(%rsp), %rax
movq 0x88(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq %r12, %rdi
movq %r13, %rsi
callq 0x284ff
movq %rax, %r13
xorl %edi, %edi
movq %r12, %rsi
callq 0x284c4
incq %r14
jmp 0x2b29f
subl 0x18(%rsp), %r13d
movl %r13d, 0xc4(%rbx)
movq 0x30(%rsp), %rcx
movq %rcx, 0x80(%rbx)
movl 0x28(%rsp), %ecx
movl %ecx, 0x5c(%rbx)
xorl %ecx, %ecx
pushq $0x1
popq %r14
shrl $0x10, %eax
cmpq %rax, %rcx
jae 0x2b322
movq 0x80(%rbx), %rax
movq 0x88(%rbx), %rdx
addq %rax, (%rdx,%rcx,8)
incq %rcx
movq 0x18(%rbx), %rax
jmp 0x2b2ff
orb $0x1, 0xbc(%rbx)
testb $0x2, %r15b
je 0x2b40c
movl 0xbc(%rbx), %eax
testb $0x2, %al
jne 0x2b40c
movslq 0xc0(%rbx), %rcx
addq 0x30(%rbx), %rcx
movslq 0xc4(%rbx), %rdx
leaq (%rcx,%rdx), %rdi
movq %rdi, 0x10(%rsp)
cmpb $0x10, (%rdx,%rcx)
jae 0x2b36f
leaq 0x1(%rdi), %rcx
andl $0x0, 0x68(%rbx)
jmp 0x2b3fb
leaq 0x10(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %rdi, 0x18(%rsp)
callq 0x2855d
movl %eax, 0x68(%rbx)
movslq 0x64(%rbx), %rsi
cmpl %esi, %eax
jle 0x2b3b8
cmpl $0x2, %eax
cmovgel %eax, %r14d
leaq 0x70(%rbx), %r9
leaq 0x5b707(%rip), %rax     # 0x86aa7
movq %rax, (%rsp)
pushq $0x4
popq %rcx
movq %r14, %rdi
movq %rcx, %rdx
xorl %r8d, %r8d
callq 0xef4f
movl %eax, 0x64(%rbx)
movl 0x20(%rsp), %r14d
xorl %r13d, %r13d
leaq 0x10(%rsp), %r12
movslq 0x68(%rbx), %rax
cmpq %rax, %r13
jge 0x2b3eb
movq 0x10(%rsp), %rdi
movl %r14d, %esi
movq %r12, %rdx
callq 0x2b5bf
movq 0x70(%rbx), %rcx
movl %eax, (%rcx,%r13,4)
incq %r13
jmp 0x2b3c5
movq 0x10(%rsp), %rcx
movl 0xbc(%rbx), %eax
movq 0x18(%rsp), %rdi
subl %edi, %ecx
movl %ecx, 0xc8(%rbx)
orl $0x2, %eax
movl %eax, 0xbc(%rbx)
pushq $0x1
popq %r12
testb $0x4, %r15b
je 0x2b4dd
testb $0x4, 0xbc(%rbx)
jne 0x2b4dd
movslq 0xc0(%rbx), %r14
addq 0x30(%rbx), %r14
movslq 0xc4(%rbx), %rax
movslq 0xc8(%rbx), %r15
addq %rax, %r15
movq 0x18(%rbx), %rcx
movzwl %cx, %edx
movl 0x54(%rbx), %eax
cmpl %eax, %edx
jle 0x2b480
movslq %eax, %rsi
testl %edx, %edx
movzwl %cx, %edi
cmoveq %r12, %rdi
leaq 0x90(%rbx), %r9
leaq 0x5b63c(%rip), %rax     # 0x86aa7
movq %rax, (%rsp)
pushq $0x4
popq %rdx
pushq $0x28
popq %rcx
xorl %r8d, %r8d
callq 0xef4f
movl %eax, 0x54(%rbx)
pushq $0x1c
popq %rcx
addq %r15, %r14
xorl %edx, %edx
cltq
cmpq %rax, %rdx
jge 0x2b4a9
movq 0x90(%rbx), %rax
andl $0x7fffffff, (%rax,%rcx) # imm = 0x7FFFFFFF
incq %rdx
movl 0x54(%rbx), %eax
addq $0x28, %rcx
jmp 0x2b488
xorl %r15d, %r15d
xorl %r13d, %r13d
movzwl 0x18(%rbx), %eax
cmpq %rax, %r13
jae 0x2b4d6
movq 0x90(%rbx), %rsi
addq %r15, %rsi
movq %r14, %rdi
callq 0x2b607
movq %rax, %r14
incq %r13
addq $0x28, %r15
jmp 0x2b4af
orb $0x4, 0xbc(%rbx)
testb $0x8, %bpl
je 0x2b5ae
movq 0x18(%rbx), %rcx
movq %rcx, %rax
shrq $0x28, %rax
je 0x2b5ae
testb $0x8, 0xbc(%rbx)
jne 0x2b5ae
movq 0x48(%rbx), %r14
shrq $0x20, %rcx
movzbl %cl, %edx
movl 0x50(%rbx), %eax
cmpl %eax, %edx
jle 0x2b546
movslq %eax, %rsi
testl %edx, %edx
movzbl %cl, %edi
cmoveq %r12, %rdi
leaq 0x98(%rbx), %r9
leaq 0x5b576(%rip), %rax     # 0x86aa7
movq %rax, (%rsp)
pushq $0x4
popq %rdx
pushq $0x20
popq %rcx
xorl %r8d, %r8d
callq 0xef4f
movl %eax, 0x50(%rbx)
pushq $0x1c
popq %rcx
xorl %edx, %edx
cltq
cmpq %rax, %rdx
jge 0x2b56c
movq 0x98(%rbx), %rax
andl $0x7fffffff, (%rax,%rcx) # imm = 0x7FFFFFFF
incq %rdx
movl 0x50(%rbx), %eax
addq $0x20, %rcx
jmp 0x2b54b
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x18(%rbx), %rsi
movq %rsi, %rax
shrq $0x20, %rax
movzbl %al, %eax
cmpq %rax, %r12
jae 0x2b5a7
shrq $0x28, %rsi
movq 0x98(%rbx), %rdx
addq %r15, %rdx
movq %r14, %rdi
callq 0x2635c
movq %rax, %r14
incq %r12
addq $0x20, %r15
jmp 0x2b572
orb $0x8, 0xbc(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %eax, %eax
retq