// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/vcf.c
// Function: bcf_subset_format
int bcf_subset_format(const bcf_hdr_t *hdr, bcf1_t *rec)
{
    if ( !hdr->keep_samples ) return 0;
    if ( !bcf_hdr_nsamples(hdr) )
    {
        rec->indiv.l = rec->n_sample = 0;
        return 0;
    }

    int i, j;
    uint8_t *ptr = (uint8_t*)rec->indiv.s, *dst = NULL, *src;
    bcf_dec_t *dec = &rec->d;
    hts_expand(bcf_fmt_t, rec->n_fmt, dec->m_fmt, dec->fmt);
    for (i=0; i<dec->m_fmt; ++i) dec->fmt[i].p_free = 0;

    for (i=0; i<rec->n_fmt; i++)
    {
        ptr = bcf_unpack_fmt_core1(ptr, rec->n_sample, &dec->fmt[i]);
        src = dec->fmt[i].p - dec->fmt[i].size;
        if ( dst )
        {
            memmove(dec->fmt[i-1].p + dec->fmt[i-1].p_len, dec->fmt[i].p - dec->fmt[i].p_off, dec->fmt[i].p_off);
            dec->fmt[i].p = dec->fmt[i-1].p + dec->fmt[i-1].p_len + dec->fmt[i].p_off;
        }
        dst = dec->fmt[i].p;
        for (j=0; j<hdr->nsamples_ori; j++)
        {
            src += dec->fmt[i].size;
            if ( !bit_array_test(hdr->keep_samples,j) ) continue;
            memmove(dst, src, dec->fmt[i].size);
            dst += dec->fmt[i].size;
        }
        rec->indiv.l -= dec->fmt[i].p_len - (dst - dec->fmt[i].p);
        dec->fmt[i].p_len = dst - dec->fmt[i].p;
    }
    rec->unpacked |= BCF_UN_FMT;

    rec->n_sample = bcf_hdr_nsamples(hdr);
    return 0;
}

// Assembly:
cmpq $0x0, 0x78(%rdi)
je 0x26359
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x0, 0x8(%rdi)
je 0x2633f
movq 0x18(%rbx), %rcx
movq 0x48(%rbx), %r15
shrq $0x20, %rcx
movzbl %cl, %edx
movl 0x50(%rbx), %eax
cmpl %eax, %edx
jle 0x261d9
movslq %eax, %rsi
testl %edx, %edx
movzbl %cl, %eax
pushq $0x1
popq %rdi
cmovneq %rax, %rdi
leaq 0x98(%rbx), %r9
leaq 0x6060a(%rip), %rax     # 0x867ce
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 0x261ff
movq 0x98(%rbx), %rax
andl $0x7fffffff, (%rax,%rcx) # imm = 0x7FFFFFFF
incq %rdx
movl 0x50(%rbx), %eax
addq $0x20, %rcx
jmp 0x261de
xorl %ebp, %ebp
xorl %r12d, %r12d
movq 0x18(%rbx), %rsi
movq %rsi, %rax
shrq $0x20, %rax
movzbl %al, %eax
cmpq %rax, %rbp
jae 0x2631a
shrq $0x28, %rsi
movq %rbp, 0x8(%rsp)
shlq $0x5, %rbp
movq 0x98(%rbx), %rdx
addq %rbp, %rdx
movq %r15, %rdi
callq 0x2635c
movq %rax, 0x10(%rsp)
movq 0x98(%rbx), %rax
movq 0x10(%rax,%rbp), %r13
movslq 0x8(%rax,%rbp), %r15
testq %r12, %r12
je 0x26298
leaq (%rax,%rbp), %rcx
movl -0x8(%rax,%rbp), %edi
addq -0x10(%rax,%rbp), %rdi
movl 0x1c(%rcx), %edx
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
andq %r12, %rdx
movq %r13, %rsi
subq %rdx, %rsi
callq 0x4850
movq 0x98(%rbx), %rax
movl -0x8(%rax,%rbp), %ecx
addq -0x10(%rax,%rbp), %rcx
movl 0x1c(%rax,%rbp), %edx
andq %r12, %rdx
addq %rcx, %rdx
movq %rdx, 0x10(%rax,%rbp)
subq %r15, %r13
movq 0x10(%rax,%rbp), %r12
xorl %r15d, %r15d
cmpl 0x70(%r14), %r15d
jge 0x262e9
movslq 0x8(%rax,%rbp), %rdx
addq %rdx, %r13
movq 0x78(%r14), %rcx
movl %r15d, %esi
shrl $0x3, %esi
movzbl (%rcx,%rsi), %ecx
movl %r15d, %esi
andl $0x7, %esi
btl %esi, %ecx
jae 0x262e4
movq %r12, %rdi
movq %r13, %rsi
callq 0x4850
movq 0x98(%rbx), %rax
movslq 0x8(%rax,%rbp), %rcx
addq %rcx, %r12
incl %r15d
jmp 0x262a3
movl 0x18(%rax,%rbp), %ecx
movq 0x10(%rax,%rbp), %rdx
addq %rdx, %rcx
movq %r12, %rsi
subq %rcx, %rsi
addq %rsi, 0x38(%rbx)
movl %r12d, %ecx
subl %edx, %ecx
movl %ecx, 0x18(%rax,%rbp)
movq 0x8(%rsp), %rbp
incq %rbp
movq 0x10(%rsp), %r15
jmp 0x26204
orb $0x8, 0xbc(%rbx)
movl 0x8(%r14), %eax
shlq $0x28, %rax
movabsq $0xffffffffff, %rcx     # imm = 0xFFFFFFFFFF
andq %rcx, %rsi
orq %rax, %rsi
movq %rsi, 0x18(%rbx)
jmp 0x2634b
movzbl 0x1c(%rbx), %eax
movl %eax, 0x1c(%rbx)
andq $0x0, 0x38(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %eax, %eax
retq