// File: /workspace/github_c_makefile_star2_O3/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 0x2fb8d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r8
movq %rdi, %r14
cmpl $0x0, 0x8(%rdi)
je 0x2fb6e
movq 0x18(%r8), %rcx
movq 0x48(%r8), %r12
shrq $0x20, %rcx
movzbl %cl, %edx
movl 0x50(%r8), %eax
cmpl %eax, %edx
movq %r8, 0x10(%rsp)
jle 0x2f8e4
movslq %eax, %rsi
testl %edx, %edx
movzbl %cl, %eax
movl $0x1, %edi
cmovneq %rax, %rdi
leaq 0x98(%r8), %r9
leaq 0x7c1b9(%rip), %rax     # 0xaba7e
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x20, %ecx
xorl %r8d, %r8d
callq 0x114b1
movq 0x10(%rsp), %r8
movl %eax, 0x50(%r8)
testl %eax, %eax
jle 0x2f90d
movl $0x1c, %eax
xorl %ecx, %ecx
movq 0x98(%r8), %rdx
andl $0x7fffffff, (%rdx,%rax) # imm = 0x7FFFFFFF
incq %rcx
movslq 0x50(%r8), %rdx
addq $0x20, %rax
cmpq %rdx, %rcx
jl 0x2f8ef
movq 0x18(%r8), %rdx
movq %rdx, %rax
shrq $0x20, %rax
testb %al, %al
je 0x2fb48
movq 0x98(%r8), %rax
xorl %edi, %edi
xorl %r15d, %r15d
movzbl (%r12), %ecx
andl $0xf, %ecx
decl %ecx
cmpl $0x3, %ecx
ja 0x2f97d
leaq 0x7b2ee(%rip), %rsi     # 0xaac30
movslq (%rsi,%rcx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
leaq 0x2(%r12), %r10
movsbq 0x1(%r12), %rcx
jmp 0x2f982
leaq 0x5(%r12), %r10
movl 0x1(%r12), %ecx
jmp 0x2f982
leaq 0x9(%r12), %r10
movq 0x1(%r12), %rcx
jmp 0x2f982
leaq 0x3(%r12), %r10
movswq 0x1(%r12), %rcx
jmp 0x2f982
movq %r12, %r10
xorl %ecx, %ecx
movq %rdi, %r13
shlq $0x5, %r13
addq %r13, %rax
movl %ecx, (%rax)
movzbl (%r10), %ecx
andl $0xf, %ecx
movl %ecx, 0xc(%rax)
movzbl (%r10), %ebp
cmpl $0xef, %ebp
movq %rdi, 0x20(%rsp)
jbe 0x2f9d7
movzbl 0x1(%r10), %esi
andl $0xf, %esi
decl %esi
cmpl $0x3, %esi
ja 0x2fb41
leaq 0x7b27d(%rip), %r9      # 0xaac40
movslq (%r9,%rsi,4), %rsi
addq %r9, %rsi
jmpq *%rsi
movsbq 0x2(%r10), %rbp
addq $0x3, %r10
jmp 0x2f9dd
incq %r10
shrl $0x4, %ebp
shrq $0x28, %rdx
movl %ebp, 0x4(%rax)
leaq 0x9db35(%rip), %rsi     # 0xcd520
movb (%rcx,%rsi), %cl
shll %cl, %ebp
movl %ebp, 0x8(%rax)
movq %r10, 0x10(%rax)
movq %r10, 0x18(%rsp)
movl %r10d, %ecx
subl %r12d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, 0x1c(%rax)
imull %edx, %ebp
movl %ebp, 0x18(%rax)
movq 0x98(%r8), %rax
movq 0x10(%rax,%r13), %r12
movslq 0x8(%rax,%r13), %rbx
testq %r15, %r15
je 0x2fa72
leaq (%rax,%r13), %rcx
movl -0x8(%rax,%r13), %edi
addq -0x10(%rax,%r13), %rdi
movl 0x1c(%rcx), %edx
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
andq %r15, %rdx
movq %r12, %rsi
subq %rdx, %rsi
callq 0x4850
movq 0x10(%rsp), %r8
movq 0x98(%r8), %rax
movl -0x8(%rax,%r13), %ecx
addq -0x10(%rax,%r13), %rcx
movl 0x1c(%rax,%r13), %edx
andq %r15, %rdx
addq %rcx, %rdx
movq %rdx, 0x10(%rax,%r13)
movq 0x10(%rax,%r13), %r15
movl 0x70(%r14), %ecx
testl %ecx, %ecx
jle 0x2facc
subq %rbx, %r12
xorl %ebx, %ebx
movslq 0x8(%rax,%r13), %rdx
addq %rdx, %r12
movq 0x78(%r14), %rsi
movl %ebx, %edi
shrl $0x3, %edi
movzbl (%rsi,%rdi), %esi
movl %ebx, %edi
andl $0x7, %edi
btl %edi, %esi
jae 0x2fac6
movq %r15, %rdi
movq %r12, %rsi
callq 0x4850
movq 0x10(%rsp), %r8
movq 0x98(%r8), %rax
movslq 0x8(%rax,%r13), %rcx
addq %rcx, %r15
movl 0x70(%r14), %ecx
incl %ebx
cmpl %ecx, %ebx
jl 0x2fa84
movl 0x18(%rax,%r13), %ecx
movq 0x10(%rax,%r13), %rdx
addq %rdx, %rcx
movq %r15, %rsi
subq %rcx, %rsi
addq %rsi, 0x38(%r8)
movslq %ebp, %rcx
movq 0x18(%rsp), %r12
addq %rcx, %r12
movl %r15d, %ecx
subl %edx, %ecx
movl %ecx, 0x18(%rax,%r13)
movq 0x20(%rsp), %rdi
incq %rdi
movq 0x18(%r8), %rdx
movq %rdx, %rcx
shrq $0x20, %rcx
movzbl %cl, %ecx
cmpq %rcx, %rdi
jb 0x2f92c
jmp 0x2fb48
movl 0x2(%r10), %ebp
addq $0x6, %r10
jmp 0x2f9dd
movq 0x2(%r10), %rbp
addq $0xa, %r10
jmp 0x2f9dd
movswq 0x2(%r10), %rbp
addq $0x4, %r10
jmp 0x2f9dd
xorl %ebp, %ebp
jmp 0x2f9dd
orb $0x8, 0xbc(%r8)
movl 0x8(%r14), %eax
shlq $0x28, %rax
movabsq $0xffffffffff, %rcx     # imm = 0xFFFFFFFFFF
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, 0x18(%r8)
jmp 0x2fb7f
movzbl 0x1c(%r8), %eax
movl %eax, 0x1c(%r8)
movq $0x0, 0x38(%r8)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %eax, %eax
retq