// File: /workspace/github_c_makefile_star2_O1/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 0x39508
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
movl $0x7, %r14d
cmovel %eax, %r14d
orl %esi, %r14d
testb $0x1, %r14b
je 0x390f8
testb $0x1, 0xbc(%rbx)
jne 0x390f8
movq 0x30(%rbx), %r15
leaq 0x10(%rsp), %r12
movq $0x0, (%r12)
movq 0x78(%rbx), %rax
movq %rax, 0x10(%r12)
movslq 0x58(%rbx), %rax
movq %rax, 0x8(%r12)
movq %r12, %rdi
movq %r15, %rsi
callq 0x342c1
movq %rax, %r13
subl %r15d, %eax
movl %eax, 0xc0(%rbx)
movq (%r12), %rax
incq %rax
cmpq %rax, 0x8(%r12)
jae 0x38f6b
movq %rax, %rcx
shrq %rcx
xorl %r15d, %r15d
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rdx, %rax
cmovbeq %rcx, %r15
addq %rax, %r15
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x4860
testq %rax, %rax
je 0x38f82
movq %rax, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x0, (%rcx,%rax)
movl %ebp, 0x2c(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x78(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0x58(%rbx)
movl 0x18(%rbx), %eax
movl %eax, %edi
shrl $0x10, %edi
movslq 0x60(%rbx), %rsi
cmpl %esi, %edi
jle 0x38fda
cmpl $0x10000, %eax          # imm = 0x10000
movl $0x1, %eax
cmovbl %eax, %edi
leaq 0x88(%rbx), %r9
leaq 0x75ddd(%rip), %rax     # 0xaed9e
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x8, %ecx
xorl %r8d, %r8d
callq 0x1183c
movl %eax, 0x60(%rbx)
movq $0x0, 0x10(%rsp)
movq 0x80(%rbx), %rax
movq %rax, 0x20(%rsp)
movslq 0x5c(%rbx), %rax
movq %rax, 0x18(%rsp)
cmpw $0x0, 0x1a(%rbx)
movq %r13, 0x30(%rsp)
movq %r13, %r15
je 0x390a7
xorl %ebp, %ebp
leaq 0x10(%rsp), %r12
movq 0x30(%rsp), %r15
movq 0x10(%rsp), %rax
movq 0x88(%rbx), %rcx
movq %rax, (%rcx,%rbp,8)
movq %r12, %rdi
movq %r15, %rsi
callq 0x342c1
movq %rax, %r15
movq 0x10(%rsp), %rax
incq %rax
cmpq %rax, 0x18(%rsp)
jae 0x39080
movq %rax, %rcx
shrq %rcx
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rdx, %rax
movl $0x0, %r13d
cmovbeq %rcx, %r13
addq %rax, %r13
movq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x4860
testq %rax, %rax
je 0x39097
movq %rax, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rsp)
movb $0x0, (%rcx,%rax)
incq %rbp
movzwl 0x1a(%rbx), %eax
cmpq %rax, %rbp
jb 0x39017
subl 0x30(%rsp), %r15d
movl %r15d, 0xc4(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x80(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0x5c(%rbx)
cmpw $0x0, 0x1a(%rbx)
je 0x390ed
xorl %eax, %eax
movq 0x80(%rbx), %rcx
movq 0x88(%rbx), %rdx
addq %rcx, (%rdx,%rax,8)
incq %rax
movzwl 0x1a(%rbx), %ecx
cmpq %rcx, %rax
jb 0x390cf
orb $0x1, 0xbc(%rbx)
movl 0x2c(%rsp), %ebp
testb $0x2, %r14b
je 0x3922e
testb $0x2, 0xbc(%rbx)
jne 0x3922e
movslq 0xc0(%rbx), %rax
addq 0x30(%rbx), %rax
movslq 0xc4(%rbx), %rcx
leaq (%rax,%rcx), %r15
movzbl (%rcx,%rax), %r13d
cmpl $0x10, %r13d
jae 0x39140
leaq 0x1(%r15), %r12
movl $0x0, 0x68(%rbx)
jmp 0x3921d
cmpb $-0x11, %r13b
jbe 0x39174
movzbl 0x1(%r15), %eax
andl $0xf, %eax
decl %eax
cmpl $0x3, %eax
ja 0x39533
leaq 0x74cd8(%rip), %rcx     # 0xade38
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x3(%r15), %r12
movsbq 0x2(%r15), %rax
jmp 0x3917e
leaq 0x1(%r15), %r12
movl %r13d, %eax
shrl $0x4, %eax
movl %eax, 0x68(%rbx)
movslq 0x64(%rbx), %rsi
cmpl %esi, %eax
jle 0x391b8
cmpl $0x2, %eax
movl $0x1, %edi
cmovgel %eax, %edi
leaq 0x70(%rbx), %r9
leaq 0x75bff(%rip), %rax     # 0xaed9e
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x1183c
movl %eax, 0x64(%rbx)
cmpl $0x0, 0x68(%rbx)
jle 0x3921d
andb $0xf, %r13b
movq 0x70(%rbx), %rax
xorl %ecx, %ecx
movzbl %r13b, %edx
decl %edx
leaq 0x74c73(%rip), %rsi     # 0xade48
cmpl $0x3, %edx
ja 0x3920c
movslq (%rsi,%rdx,4), %rdi
addq %rsi, %rdi
jmpq *%rdi
movsbq (%r12), %rdi
incq %r12
jmp 0x3920e
movl (%r12), %edi
addq $0x4, %r12
jmp 0x3920e
movq (%r12), %rdi
addq $0x8, %r12
jmp 0x3920e
movswq (%r12), %rdi
addq $0x2, %r12
jmp 0x3920e
xorl %edi, %edi
movl %edi, (%rax,%rcx,4)
incq %rcx
movslq 0x68(%rbx), %rdi
cmpq %rdi, %rcx
jl 0x391d5
subl %r15d, %r12d
movl %r12d, 0xc8(%rbx)
orb $0x2, 0xbc(%rbx)
testb $0x4, %r14b
je 0x3930c
testb $0x4, 0xbc(%rbx)
jne 0x3930c
movslq 0xc0(%rbx), %r14
addq 0x30(%rbx), %r14
movslq 0xc4(%rbx), %r15
movslq 0xc8(%rbx), %r12
movq 0x18(%rbx), %rax
movzwl %ax, %ecx
movslq 0x54(%rbx), %rsi
cmpl %esi, %ecx
jle 0x392a2
testl %ecx, %ecx
movzwl %ax, %eax
movl $0x1, %edi
cmovneq %rax, %rdi
leaq 0x90(%rbx), %r9
leaq 0x75b15(%rip), %rax     # 0xaed9e
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x28, %ecx
xorl %r8d, %r8d
callq 0x1183c
movl %eax, 0x54(%rbx)
cmpl $0x0, 0x54(%rbx)
jle 0x392cd
movl $0x1c, %eax
xorl %ecx, %ecx
movq 0x90(%rbx), %rdx
andl $0x7fffffff, (%rdx,%rax) # imm = 0x7FFFFFFF
incq %rcx
movslq 0x54(%rbx), %rdx
addq $0x28, %rax
cmpq %rdx, %rcx
jl 0x392af
cmpw $0x0, 0x18(%rbx)
je 0x39305
addq %r12, %r15
addq %r15, %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x90(%rbx), %rsi
addq %r15, %rsi
movq %r14, %rdi
callq 0x3953d
movq %rax, %r14
incq %r12
movzwl 0x18(%rbx), %eax
addq $0x28, %r15
cmpq %rax, %r12
jb 0x392e0
orb $0x4, 0xbc(%rbx)
testb $0x8, %bpl
je 0x394fa
movq 0x18(%rbx), %rax
movq %rax, %rcx
shrq $0x28, %rcx
je 0x394fa
testb $0x8, 0xbc(%rbx)
jne 0x394fa
movq 0x48(%rbx), %r14
shrq $0x20, %rax
movzbl %al, %ecx
movslq 0x50(%rbx), %rsi
cmpl %esi, %ecx
jle 0x3937c
testl %ecx, %ecx
movzbl %al, %eax
movl $0x1, %edi
cmovneq %rax, %rdi
leaq 0x98(%rbx), %r9
leaq 0x75a3b(%rip), %rax     # 0xaed9e
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x20, %ecx
xorl %r8d, %r8d
callq 0x1183c
movl %eax, 0x50(%rbx)
cmpl $0x0, 0x50(%rbx)
jle 0x393a7
movl $0x1c, %eax
xorl %ecx, %ecx
movq 0x98(%rbx), %rdx
andl $0x7fffffff, (%rdx,%rax) # imm = 0x7FFFFFFF
incq %rcx
movslq 0x50(%rbx), %rdx
addq $0x20, %rax
cmpq %rdx, %rcx
jl 0x39389
movq 0x18(%rbx), %rdx
movq %rdx, %rax
shrq $0x20, %rax
testb %al, %al
je 0x394f3
movl $0x1c, %eax
xorl %esi, %esi
leaq 0x74aa0(%rip), %rdi     # 0xade68
leaq 0x96151(%rip), %r8      # 0xcf520
leaq 0x74a82(%rip), %r9      # 0xade58
movzbl (%r14), %ecx
andl $0xf, %ecx
decl %ecx
cmpl $0x3, %ecx
ja 0x39417
movslq (%r9,%rcx,4), %rcx
addq %r9, %rcx
jmpq *%rcx
leaq 0x2(%r14), %r10
movsbq 0x1(%r14), %rcx
jmp 0x3941c
leaq 0x5(%r14), %r10
movl 0x1(%r14), %ecx
jmp 0x3941c
leaq 0x9(%r14), %r10
movq 0x1(%r14), %rcx
jmp 0x3941c
leaq 0x3(%r14), %r10
movswq 0x1(%r14), %rcx
jmp 0x3941c
movq %r14, %r10
xorl %ecx, %ecx
movq 0x98(%rbx), %r11
movl %ecx, -0x1c(%r11,%rax)
movzbl (%r10), %ecx
andl $0xf, %ecx
movl %ecx, -0x10(%r11,%rax)
movzbl (%r10), %r15d
cmpl $0xef, %r15d
jbe 0x3946c
movzbl 0x1(%r10), %r15d
andl $0xf, %r15d
decl %r15d
cmpl $0x3, %r15d
ja 0x394ee
movslq (%rdi,%r15,4), %r15
addq %rdi, %r15
jmpq *%r15
movsbq 0x2(%r10), %r15
addq $0x3, %r10
jmp 0x39473
incq %r10
shrl $0x4, %r15d
movl %r15d, -0x18(%r11,%rax)
movb (%rcx,%r8), %cl
shll %cl, %r15d
shrq $0x28, %rdx
movl %r15d, -0x14(%r11,%rax)
movq %r10, -0xc(%r11,%rax)
movl %r10d, %ecx
subl %r14d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, (%r11,%rax)
imull %edx, %r15d
movslq %r15d, %rcx
addq %rcx, %r10
movl %ecx, -0x4(%r11,%rax)
incq %rsi
movq 0x18(%rbx), %rdx
movq %rdx, %rcx
shrq $0x20, %rcx
movzbl %cl, %ecx
addq $0x20, %rax
movq %r10, %r14
cmpq %rcx, %rsi
jb 0x393d6
jmp 0x394f3
movl 0x2(%r10), %r15d
addq $0x6, %r10
jmp 0x39473
movq 0x2(%r10), %r15
addq $0xa, %r10
jmp 0x39473
movswq 0x2(%r10), %r15
addq $0x4, %r10
jmp 0x39473
xorl %r15d, %r15d
jmp 0x39473
orb $0x8, 0xbc(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %eax, %eax
retq
leaq 0x6(%r15), %r12
movl 0x2(%r15), %eax
jmp 0x3917e
leaq 0xa(%r15), %r12
movq 0x2(%r15), %rax
jmp 0x3917e
leaq 0x4(%r15), %r12
movswq 0x2(%r15), %rax
jmp 0x3917e
xorl %eax, %eax
movq %r15, %r12
jmp 0x3917e