// File: /workspace/github_c_makefile_star2_O1/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 0x30d22
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x0, 0x8(%rdi)
je 0x30d05
movq 0x18(%rbx), %rax
movq 0x48(%rbx), %r12
shrq $0x20, %rax
movzbl %al, %ecx
movslq 0x50(%rbx), %rsi
cmpl %esi, %ecx
jle 0x30a63
testl %ecx, %ecx
movzbl %al, %eax
movl $0x1, %edi
cmovneq %rax, %rdi
leaq 0x98(%rbx), %r9
leaq 0x7e084(%rip), %rax     # 0xaeace
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x20, %ecx
xorl %r8d, %r8d
callq 0x1183c
movl %eax, 0x50(%rbx)
cmpl $0x0, 0x50(%rbx)
jle 0x30a8e
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 0x30a70
movq 0x18(%rbx), %rax
movq %rax, %rcx
shrq $0x20, %rcx
testb %cl, %cl
je 0x30ce0
xorl %edi, %edi
xorl %r15d, %r15d
movzbl (%r12), %ecx
andl $0xf, %ecx
decl %ecx
cmpl $0x3, %ecx
ja 0x30af7
leaq 0x7d1a8(%rip), %rdx     # 0xadc64
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0x2(%r12), %r9
movsbq 0x1(%r12), %rcx
jmp 0x30afc
leaq 0x5(%r12), %r9
movl 0x1(%r12), %ecx
jmp 0x30afc
leaq 0x9(%r12), %r9
movq 0x1(%r12), %rcx
jmp 0x30afc
leaq 0x3(%r12), %r9
movswq 0x1(%r12), %rcx
jmp 0x30afc
movq %r12, %r9
xorl %ecx, %ecx
movq %rdi, %r13
shlq $0x5, %r13
movq 0x98(%rbx), %rdx
addq %r13, %rdx
movl %ecx, (%rdx)
movzbl (%r9), %ecx
andl $0xf, %ecx
movl %ecx, 0xc(%rdx)
movzbl (%r9), %r8d
cmpl $0xef, %r8d
movq %rdi, 0x20(%rsp)
jbe 0x30b59
movzbl 0x1(%r9), %esi
andl $0xf, %esi
decl %esi
cmpl $0x3, %esi
ja 0x30cd8
leaq 0x7d12f(%rip), %r8      # 0xadc74
movslq (%r8,%rsi,4), %rsi
addq %r8, %rsi
jmpq *%rsi
movsbq 0x2(%r9), %r8
addq $0x3, %r9
jmp 0x30b60
incq %r9
shrl $0x4, %r8d
shrq $0x28, %rax
movl %r8d, 0x4(%rdx)
leaq 0x9e9b1(%rip), %rsi     # 0xcf520
movb (%rcx,%rsi), %cl
shll %cl, %r8d
movl %r8d, 0x8(%rdx)
movq %r9, 0x10(%rdx)
movq %r9, 0x18(%rsp)
movl %r9d, %ecx
subl %r12d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, 0x1c(%rdx)
imull %eax, %r8d
movq %r8, 0x10(%rsp)
movl %r8d, 0x18(%rdx)
movq 0x98(%rbx), %rax
movq 0x10(%rax,%r13), %r12
movslq 0x8(%rax,%r13), %rbp
testq %r15, %r15
je 0x30bfa
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 0x98(%rbx), %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 0x98(%rbx), %rax
movq 0x10(%rax,%r13), %r15
cmpl $0x0, 0x70(%r14)
jle 0x30c5a
subq %rbp, %r12
xorl %ebp, %ebp
movq 0x98(%rbx), %rax
movslq 0x8(%rax,%r13), %rdx
addq %rdx, %r12
movq 0x78(%r14), %rax
movl %ebp, %ecx
shrl $0x3, %ecx
movzbl (%rax,%rcx), %eax
movl %ebp, %ecx
andl $0x7, %ecx
btl %ecx, %eax
jae 0x30c52
movq %r15, %rdi
movq %r12, %rsi
callq 0x4850
movq 0x98(%rbx), %rax
movslq 0x8(%rax,%r13), %rax
addq %rax, %r15
incl %ebp
cmpl 0x70(%r14), %ebp
jl 0x30c12
movq 0x98(%rbx), %rax
movl 0x18(%rax,%r13), %ecx
movq 0x10(%rax,%r13), %rdx
addq %rdx, %rcx
movq %r15, %rsi
subq %rcx, %rsi
addq %rsi, 0x38(%rbx)
movslq 0x10(%rsp), %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(%rbx), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movzbl %cl, %ecx
cmpq %rcx, %rdi
jb 0x30aa6
jmp 0x30ce0
movl 0x2(%r9), %r8d
addq $0x6, %r9
jmp 0x30b60
movq 0x2(%r9), %r8
addq $0xa, %r9
jmp 0x30b60
movswq 0x2(%r9), %r8
addq $0x4, %r9
jmp 0x30b60
xorl %r8d, %r8d
jmp 0x30b60
orb $0x8, 0xbc(%rbx)
movl 0x8(%r14), %ecx
shlq $0x28, %rcx
movabsq $0xffffffffff, %rdx     # imm = 0xFFFFFFFFFF
andq %rax, %rdx
orq %rcx, %rdx
movq %rdx, 0x18(%rbx)
jmp 0x30d14
movzbl 0x1c(%rbx), %eax
movl %eax, 0x1c(%rbx)
movq $0x0, 0x38(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %eax, %eax
retq