// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2028, %rsp           # imm = 0x2028
movq %rsi, %rbx
movl %edx, 0xc(%rsp)
testl %edx, %edx
je 0x3e10e
movq %rcx, %r12
movabsq $0xff00000000, %rdx     # imm = 0xFF00000000
movq %rbx, 0x30(%rsp)
movq 0x18(%rbx), %rax
testq %rdx, %rax
je 0x3ddb9
movq %rax, %rcx
shrq $0x20, %rcx
movq 0x30(%rsp), %rsi
movq 0x48(%rsi), %rbx
movq %rax, %rsi
shrq $0x28, %rsi
movzbl %cl, %edi
leaq 0x5c(%rsp), %r8
leaq 0x6d224(%rip), %r9      # 0xaaedc
leaq 0x8f861(%rip), %r10     # 0xcd520
leaq 0x6d206(%rip), %r11     # 0xaaecc
movzbl (%rbx), %ecx
andl $0xf, %ecx
decl %ecx
cmpl $0x3, %ecx
ja 0x3dd05
movslq (%r11,%rcx,4), %rcx
addq %r11, %rcx
jmpq *%rcx
leaq 0x2(%rbx), %r14
movsbq 0x1(%rbx), %rcx
jmp 0x3dd0a
leaq 0x5(%rbx), %r14
movl 0x1(%rbx), %ecx
jmp 0x3dd0a
leaq 0x9(%rbx), %r14
movq 0x1(%rbx), %rcx
jmp 0x3dd0a
leaq 0x3(%rbx), %r14
movswq 0x1(%rbx), %rcx
jmp 0x3dd0a
movq %rbx, %r14
xorl %ecx, %ecx
movl %ecx, -0x1c(%r8)
movzbl (%r14), %ecx
andl $0xf, %ecx
movl %ecx, -0x10(%r8)
movzbl (%r14), %r15d
cmpl $0xef, %r15d
jbe 0x3dd4d
movzbl 0x1(%r14), %r15d
andl $0xf, %r15d
decl %r15d
cmpl $0x3, %r15d
ja 0x3ddb4
movslq (%r9,%r15,4), %r15
addq %r9, %r15
jmpq *%r15
movsbq 0x2(%r14), %r15
addq $0x3, %r14
jmp 0x3dd54
incq %r14
shrl $0x4, %r15d
movl %r15d, -0x18(%r8)
movb (%rcx,%r10), %cl
shll %cl, %r15d
movl %r15d, -0x14(%r8)
movq %r14, -0xc(%r8)
movl %r14d, %ecx
subl %ebx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, (%r8)
imull %esi, %r15d
movslq %r15d, %rcx
addq %rcx, %r14
movl %ecx, -0x4(%r8)
addq $0x20, %r8
movq %r14, %rbx
decq %rdi
jne 0x3dcc6
jmp 0x3ddb9
movl 0x2(%r14), %r15d
addq $0x6, %r14
jmp 0x3dd54
movq 0x2(%r14), %r15
addq $0xa, %r14
jmp 0x3dd54
movswq 0x2(%r14), %r15
addq $0x4, %r14
jmp 0x3dd54
xorl %r15d, %r15d
jmp 0x3dd54
movq %r12, 0x10(%rsp)
movl 0xc(%rsp), %r15d
testq %rdx, %rax
je 0x3e127
xorl %ebp, %ebp
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %r15, 0x20(%rsp)
movq %rbp, %rbx
shlq $0x5, %rbx
movl 0x40(%rsp,%rbx), %r14d
leaq 0x5(%rdi), %rax
cmpq %rax, %r12
movq %rbp, 0x38(%rsp)
jae 0x3de3d
movq %rax, %rcx
shrq %rcx
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rdx, %rax
movl $0x0, %r15d
cmovbeq %rcx, %r15
addq %rax, %r15
movq %rdi, (%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x4860
movq (%rsp), %rdi
movq %r15, %rcx
testq %rax, %rax
jne 0x3de43
movq %r13, %rax
movq %r12, %rcx
movq 0x10(%rsp), %r12
jmp 0x3de93
movq %r13, %rax
movq %r12, %rcx
movl %r14d, %edx
negl %edx
jo 0x3de60
cmpl $0x80000001, %r14d      # imm = 0x80000001
movq 0x10(%rsp), %r12
jne 0x3de72
movw $0x8111, (%rax,%rdi)    # imm = 0x8111
jmp 0x3de8b
movw $0x8011, (%rax,%rdi)    # imm = 0x8011
movl $0x2, %edx
movq 0x10(%rsp), %r12
jmp 0x3de90
leal 0x78(%r14), %edx
cmpl $0xf7, %edx
ja 0x3dfab
movb $0x11, (%rax,%rdi)
movb %r14b, 0x1(%rax,%rdi)
movl $0x2, %edx
addq %rdx, %rdi
movq 0x20(%rsp), %r15
leaq (%rsp,%rbx), %r8
addq $0x40, %r8
movl 0x4(%r8), %ebx
movl 0xc(%r8), %ebp
cmpl $0xe, %ebx
movq %r8, (%rsp)
jg 0x3df04
leaq 0x1(%rdi), %rsi
cmpq %rsi, %rcx
jae 0x3df60
movq %rcx, 0x18(%rsp)
movq %rsi, %rcx
shrq %rcx
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rdx, %rsi
movl $0x0, %r13d
cmovbeq %rcx, %r13
addq %rsi, %r13
movq %rdi, %r14
movq %rax, 0x28(%rsp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x4860
movq (%rsp), %r8
movq %r14, %rdi
testq %rax, %rax
jne 0x3df63
jmp 0x3df51
leaq 0x6(%rdi), %rsi
cmpq %rsi, %rcx
jae 0x3df72
movq %rcx, 0x18(%rsp)
movq %rsi, %rcx
shrq %rcx
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rdx, %rsi
movl $0x0, %r13d
cmovbeq %rcx, %r13
addq %rsi, %r13
movq %rdi, %r14
movq %rax, 0x28(%rsp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x4860
movq (%rsp), %r8
movq %r14, %rdi
testq %rax, %rax
jne 0x3df75
movq 0x18(%rsp), %rsi
movq 0x28(%rsp), %r14
jmp 0x3dfe9
movq %rcx, %r13
shll $0x4, %ebx
orl %ebp, %ebx
movb %bl, (%rax,%rdi)
movl $0x1, %ecx
jmp 0x3dfe0
movq %rcx, %r13
orb $-0x10, %bpl
movb %bpl, (%rax,%rdi)
cmpl $0x7f, %ebx
ja 0x3df92
movb $0x11, 0x1(%rax,%rdi)
movb %bl, 0x2(%rax,%rdi)
movl $0x3, %ecx
jmp 0x3dfe0
cmpl $0x7fff, %ebx           # imm = 0x7FFF
ja 0x3dfd2
movb $0x12, 0x1(%rax,%rdi)
movw %bx, 0x2(%rax,%rdi)
movl $0x4, %ecx
jmp 0x3dfe0
leal 0x7ff8(%r14), %edx
cmpl $0xfff7, %edx           # imm = 0xFFF7
ja 0x3e0fb
movb $0x12, (%rax,%rdi)
movw %r14w, 0x1(%rax,%rdi)
movl $0x3, %edx
jmp 0x3de90
movb $0x13, 0x1(%rax,%rdi)
movl %ebx, 0x2(%rax,%rdi)
movl $0x6, %ecx
addq %rcx, %rdi
movq %rax, %r14
movq %r13, %rsi
cmpl $0x0, 0xc(%rsp)
jle 0x3e0cf
xorl %ebx, %ebx
movslq (%r12,%rbx,4), %rbp
testq %rbp, %rbp
js 0x3e0c3
movslq 0x8(%r8), %r13
leaq (%rdi,%r13), %rax
addq $0x2, %rax
cmpq %rdi, %rax
jbe 0x3e070
imulq %r13, %rbp
addq 0x10(%r8), %rbp
cmpq %rax, %rsi
jae 0x3e08d
movq %rsi, 0x18(%rsp)
movq %rax, %rcx
shrq %rcx
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rdx, %rax
movl $0x0, %r15d
cmovbeq %rcx, %r15
addq %rax, %r15
movq %rdi, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x4860
movq %r12, %rdi
movq %rax, %r12
testq %rax, %rax
jne 0x3e093
movq 0x10(%rsp), %r12
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %rsi
jmp 0x3e0bf
movq %rsi, %r13
movq %rdi, %rbp
callq 0x4050
movq (%rsp), %r8
movq %rbp, %rdi
movq %r13, %rsi
movl $0x4b, (%rax)
jmp 0x3e0c3
movq %r14, %r12
movq %rsi, %r15
movq %rdi, %r14
addq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x43c0
movq %r14, %rdi
addq %r13, %rdi
movb $0x0, (%r12,%rdi)
movq %r12, %r14
movq %r15, %rsi
movq 0x10(%rsp), %r12
movq 0x20(%rsp), %r15
movq (%rsp), %r8
incq %rbx
cmpq %rbx, %r15
jne 0x3dff6
movq 0x38(%rsp), %rbp
incq %rbp
movq 0x30(%rsp), %rbx
movq 0x18(%rbx), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movzbl %cl, %ecx
movq %rsi, %r12
movq %r14, %r13
cmpq %rcx, %rbp
jb 0x3dddb
jmp 0x3e133
movb $0x13, (%rax,%rdi)
movl %r14d, 0x1(%rax,%rdi)
movl $0x5, %edx
jmp 0x3de90
movabsq $0xffffffffff, %rax     # imm = 0xFFFFFFFFFF
andq 0x18(%rbx), %rax
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %r14d, %r14d
jmp 0x3e178
xorl %r14d, %r14d
xorl %esi, %esi
xorl %edi, %edi
movq 0x30(%rsp), %rbx
movq %rdi, %r13
movq %rsi, %r12
xorl %ecx, %ecx
cmpl $0x0, 0xc(%rsp)
jle 0x3e15f
xorl %edx, %edx
movq 0x10(%rsp), %rdi
movl (%rdi,%rdx,4), %esi
notl %esi
shrl $0x1f, %esi
addl %esi, %ecx
incq %rdx
cmpq %rdx, %r15
jne 0x3e149
shlq $0x28, %rcx
movabsq $0xffffffffff, %rdx     # imm = 0xFFFFFFFFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, 0x18(%rbx)
testq %rcx, %rcx
jne 0x3e17e
movl %eax, %eax
movq %rax, 0x18(%rbx)
movq 0x48(%rbx), %rdi
callq 0x45c0
movq %r13, 0x38(%rbx)
movq %r12, 0x40(%rbx)
movq %r14, 0x48(%rbx)
andb $-0x9, 0xbc(%rbx)
xorl %eax, %eax
addq $0x2028, %rsp           # imm = 0x2028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq