// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: bcf_subset
int bcf_subset(const bcf_hdr_t *h, bcf1_t *v, int n, int *imap)
{
    kstring_t ind;
    ind.s = 0; ind.l = ind.m = 0;
    if (n) {
        bcf_fmt_t fmt[MAX_N_FMT];
        int i, j;
        uint8_t *ptr = (uint8_t*)v->indiv.s;
        for (i = 0; i < v->n_fmt; ++i)
            ptr = bcf_unpack_fmt_core1(ptr, v->n_sample, &fmt[i]);
        for (i = 0; i < (int)v->n_fmt; ++i) {
            bcf_fmt_t *f = &fmt[i];
            bcf_enc_int1(&ind, f->id);
            bcf_enc_size(&ind, f->n, f->type);
            for (j = 0; j < n; ++j)
                if (imap[j] >= 0) kputsn((char*)(f->p + imap[j] * f->size), f->size, &ind);
        }
        for (i = j = 0; j < n; ++j) if (imap[j] >= 0) ++i;
        v->n_sample = i;
    } else v->n_sample = 0;
    if ( !v->n_sample ) v->n_fmt = 0;
    free(v->indiv.s);
    v->indiv = ind;
    v->unpacked &= ~BCF_UN_FMT;    // only BCF is ready for output, VCF will need to unpack again
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2040, %rsp           # imm = 0x2040
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x4d830
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x2030(%rbp)
movl $0x0, -0x2024(%rbp)
movl -0x2024(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
andq $0xff, %rcx
cmpl %ecx, %eax
jge 0x4d6a9
movq -0x2030(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x28, %rax
movl %eax, %esi
movslq -0x2024(%rbp), %rax
leaq -0x2020(%rbp), %rdx
shlq $0x5, %rax
addq %rax, %rdx
callq 0x414a0
movq %rax, -0x2030(%rbp)
movl -0x2024(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2024(%rbp)
jmp 0x4d645
movl $0x0, -0x2024(%rbp)
movl -0x2024(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
andq $0xff, %rcx
cmpl %ecx, %eax
jge 0x4d7ab
movslq -0x2024(%rbp), %rcx
leaq -0x2020(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x2038(%rbp)
movq -0x2038(%rbp), %rax
movl (%rax), %esi
leaq -0x38(%rbp), %rdi
callq 0x44a50
movq -0x2038(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x2038(%rbp), %rax
movl 0xc(%rax), %edx
leaq -0x38(%rbp), %rdi
callq 0x448b0
movl $0x0, -0x2028(%rbp)
movl -0x2028(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4d795
movq -0x20(%rbp), %rax
movslq -0x2028(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x4d782
movq -0x2038(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movslq -0x2028(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x2038(%rbp), %rcx
imull 0x8(%rcx), %eax
cltq
addq %rax, %rdi
movq -0x2038(%rbp), %rax
movslq 0x8(%rax), %rsi
leaq -0x38(%rbp), %rdx
callq 0x43970
jmp 0x4d784
movl -0x2028(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2028(%rbp)
jmp 0x4d729
jmp 0x4d797
movl -0x2024(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2024(%rbp)
jmp 0x4d6b3
movl $0x0, -0x2028(%rbp)
movl $0x0, -0x2024(%rbp)
movl -0x2028(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4d7fd
movq -0x20(%rbp), %rax
movslq -0x2028(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x4d7ea
movl -0x2024(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2024(%rbp)
jmp 0x4d7ec
movl -0x2028(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2028(%rbp)
jmp 0x4d7bf
movl -0x2024(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0xffffff, %rdx         # imm = 0xFFFFFF
shlq $0x28, %rdx
movabsq $0xffffffffff, %rsi     # imm = 0xFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
jmp 0x4d84a
movq -0x10(%rbp), %rax
movabsq $0xffffffffff, %rcx     # imm = 0xFFFFFFFFFF
andq 0x18(%rax), %rcx
orq $0x0, %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x28, %rax
cmpl $0x0, %eax
jne 0x4d875
movq -0x10(%rbp), %rax
movabsq $-0xff00000001, %rcx    # imm = 0xFFFFFF00FFFFFFFF
andq 0x18(%rax), %rcx
orq $0x0, %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x45a0
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x38(%rax)
movq -0x30(%rbp), %rcx
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rcx
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movl 0xbc(%rax), %ecx
andl $-0x9, %ecx
movl %ecx, 0xbc(%rax)
xorl %eax, %eax
addq $0x2040, %rsp           # imm = 0x2040
popq %rbp
retq
nopl (%rax)