// File: /workspace/github_c_makefile_star2_O1/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, %r15
movabsq $0xffffffffff, %rdi     # imm = 0xFFFFFFFFFF
movl %edx, 0x14(%rsp)
testl %edx, %edx
je 0x3eeba
movq %rcx, %r12
movabsq $0xff00000000, %rax     # imm = 0xFF00000000
movq 0x18(%r15), %rdx
testq %rax, %rdx
je 0x3eb88
movq %rdx, %rcx
shrq $0x20, %rcx
movq 0x48(%r15), %r11
shrq $0x28, %rdx
movzbl %cl, %esi
leaq 0x5c(%rsp), %rdi
leaq 0x6f4a6(%rip), %r8      # 0xadf30
leaq 0x90a8f(%rip), %r9      # 0xcf520
leaq 0x6f488(%rip), %r10     # 0xadf20
movzbl (%r11), %ecx
andl $0xf, %ecx
decl %ecx
cmpl $0x3, %ecx
ja 0x3ead9
movslq (%r10,%rcx,4), %rcx
addq %r10, %rcx
jmpq *%rcx
leaq 0x2(%r11), %rbx
movsbq 0x1(%r11), %rcx
jmp 0x3eade
leaq 0x5(%r11), %rbx
movl 0x1(%r11), %ecx
jmp 0x3eade
leaq 0x9(%r11), %rbx
movq 0x1(%r11), %rcx
jmp 0x3eade
leaq 0x3(%r11), %rbx
movswq 0x1(%r11), %rcx
jmp 0x3eade
movq %r11, %rbx
xorl %ecx, %ecx
movl %ecx, -0x1c(%rdi)
movzbl (%rbx), %ecx
andl $0xf, %ecx
movl %ecx, -0x10(%rdi)
movzbl (%rbx), %r14d
cmpl $0xef, %r14d
jbe 0x3eb1e
movzbl 0x1(%rbx), %r14d
andl $0xf, %r14d
decl %r14d
cmpl $0x3, %r14d
ja 0x3eb83
movslq (%r8,%r14,4), %r14
addq %r8, %r14
jmpq *%r14
movsbq 0x2(%rbx), %r14
addq $0x3, %rbx
jmp 0x3eb25
incq %rbx
shrl $0x4, %r14d
movl %r14d, -0x18(%rdi)
movb (%rcx,%r9), %cl
shll %cl, %r14d
movl %r14d, -0x14(%rdi)
movq %rbx, -0xc(%rdi)
movl %ebx, %ecx
subl %r11d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, (%rdi)
imull %edx, %r14d
movslq %r14d, %rcx
addq %rcx, %rbx
movl %ecx, -0x4(%rdi)
addq $0x20, %rdi
movq %rbx, %r11
decq %rsi
jne 0x3ea98
jmp 0x3eb88
movl 0x2(%rbx), %r14d
addq $0x6, %rbx
jmp 0x3eb25
movq 0x2(%rbx), %r14
addq $0xa, %rbx
jmp 0x3eb25
movswq 0x2(%rbx), %r14
addq $0x4, %rbx
jmp 0x3eb25
xorl %r14d, %r14d
jmp 0x3eb25
movq 0x18(%r15), %rcx
movl 0x14(%rsp), %edx
movq %rdx, 0x20(%rsp)
testq %rax, %rcx
je 0x3eecd
xorl %ebx, %ebx
xorl %r14d, %r14d
movq $0x0, (%rsp)
xorl %esi, %esi
movq %r15, 0x28(%rsp)
movq %r12, 0x8(%rsp)
movq %rbx, 0x30(%rsp)
shlq $0x5, %rbx
movl 0x40(%rsp,%rbx), %r12d
movq %r14, %rbp
leaq 0x5(%r14), %r15
movq (%rsp), %r13
cmpq %r15, %r13
jae 0x3ec11
movq %r15, %rax
shrq %rax
movabsq $0x3fffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rcx, %r15
movl $0x0, %r13d
cmovbeq %rax, %r13
addq %r15, %r13
movq %rsi, %r14
movq %rsi, %rdi
movq %r13, %rsi
callq 0x4860
testq %rax, %rax
jne 0x3ec14
movq %r14, %rax
movq (%rsp), %r13
jmp 0x3ec52
movq %rsi, %rax
movl %r12d, %ecx
negl %ecx
jo 0x3ec2c
cmpl $0x80000001, %r12d      # imm = 0x80000001
jne 0x3ec34
movw $0x8111, (%rax,%rbp)    # imm = 0x8111
jmp 0x3ec4e
movw $0x8011, (%rax,%rbp)    # imm = 0x8011
jmp 0x3ec4e
leal 0x78(%r12), %ecx
cmpl $0xf7, %ecx
ja 0x3ee79
movb $0x11, (%rax,%rbp)
movb %r12b, 0x1(%rax,%rbp)
addq $0x2, %rbp
movq %rbp, %r15
leaq (%rsp,%rbx), %rcx
addq $0x40, %rcx
movl 0x4(%rcx), %ebx
movl 0xc(%rcx), %r12d
cmpl $0xe, %ebx
movq %rcx, 0x18(%rsp)
jg 0x3ecb8
leaq 0x1(%r15), %r14
cmpq %r14, %r13
jae 0x3ed05
movq %r14, %rdx
shrq %rdx
movabsq $0x3fffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rcx, %r14
movl $0x0, %esi
cmovbeq %rdx, %rsi
addq %r14, %rsi
movq %rax, %rbp
movq %rax, %rdi
movq %rsi, (%rsp)
callq 0x4860
movq 0x18(%rsp), %rcx
movq %rax, %rsi
testq %rax, %rax
jne 0x3ed0c
jmp 0x3ecfc
leaq 0x6(%r15), %r14
cmpq %r14, %r13
jae 0x3ed18
movq %r14, %rdx
shrq %rdx
movabsq $0x3fffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rcx, %r14
movl $0x0, %esi
cmovbeq %rdx, %rsi
addq %r14, %rsi
movq %rax, %rbp
movq %rax, %rdi
movq %rsi, (%rsp)
callq 0x4860
movq 0x18(%rsp), %rcx
movq %rax, %rsi
testq %rax, %rax
jne 0x3ed1f
movq %rbp, %rsi
movq %r13, (%rsp)
jmp 0x3ed3f
movq %rax, %rsi
movq %r13, (%rsp)
shll $0x4, %ebx
orl %r12d, %ebx
movb %bl, (%rsi,%r15)
jmp 0x3ed42
movq %rax, %rsi
movq %r13, (%rsp)
orb $-0x10, %r12b
movb %r12b, (%rsi,%r15)
cmpl $0x7f, %ebx
jg 0x3ee54
movb $0x11, 0x1(%rsi,%r15)
movb %bl, 0x2(%rsi,%r15)
addq $0x3, %r15
movq %r15, %r14
movq 0x8(%rsp), %r12
cmpl $0x0, 0x14(%rsp)
movq 0x20(%rsp), %r15
jle 0x3ee2b
xorl %ebx, %ebx
movslq (%r12,%rbx,4), %rbp
testq %rbp, %rbp
js 0x3ee1f
movslq 0x8(%rcx), %r13
leaq (%r14,%r13), %rax
addq $0x2, %rax
cmpq %r14, %rax
jbe 0x3edd1
imulq %r13, %rbp
addq 0x10(%rcx), %rbp
movq (%rsp), %r15
cmpq %rax, %r15
jae 0x3edef
movq %rax, %rcx
shrq %rcx
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rdx, %rax
movl $0x0, %r15d
cmovbeq %rcx, %r15
addq %rax, %r15
movq %rsi, 0x38(%rsp)
movq %rsi, %rdi
movq %r15, %rsi
callq 0x4860
movq %rax, %r12
testq %rax, %rax
jne 0x3edf2
movq 0x8(%rsp), %r12
movq 0x20(%rsp), %r15
movq 0x38(%rsp), %rsi
jmp 0x3ee1a
movq %r14, %r13
movq %rsi, %r14
callq 0x4050
movq 0x18(%rsp), %rcx
movq %r14, %rsi
movq %r13, %r14
movl $0x4b, (%rax)
jmp 0x3ee1f
movq %rsi, %r12
leaq (%r12,%r14), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x43c0
addq %r13, %r14
movb $0x0, (%r12,%r14)
movq %r12, %rsi
movq %r15, (%rsp)
movq 0x8(%rsp), %r12
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %rcx
incq %rbx
cmpq %rbx, %r15
jne 0x3ed59
movq 0x30(%rsp), %rbx
incq %rbx
movq 0x28(%rsp), %r15
movq 0x18(%r15), %rcx
movq %rcx, %rax
shrq $0x20, %rax
movzbl %al, %eax
cmpq %rax, %rbx
jb 0x3ebb7
jmp 0x3eeda
cmpl $0x7fff, %ebx           # imm = 0x7FFF
movq 0x8(%rsp), %r12
jg 0x3ee9c
movb $0x12, 0x1(%rsi,%r15)
movw %bx, 0x2(%rsi,%r15)
addq $0x4, %r15
movq %r15, %r14
jmp 0x3ed47
leal 0x7ff8(%r12), %ecx
cmpl $0xfff7, %ecx           # imm = 0xFFF7
ja 0x3eeac
movb $0x12, (%rax,%rbp)
movw %r12w, 0x1(%rax,%rbp)
addq $0x3, %rbp
jmp 0x3ec52
movb $0x13, 0x1(%rsi,%r15)
movl %ebx, 0x2(%rsi,%r15)
jmp 0x3ed47
movb $0x13, (%rax,%rbp)
movl %r12d, 0x1(%rax,%rbp)
jmp 0x3ec55
andq %rdi, 0x18(%r15)
xorl %ebx, %ebx
movq $0x0, (%rsp)
xorl %r14d, %r14d
jmp 0x3ef24
xorl %esi, %esi
movq $0x0, (%rsp)
xorl %r14d, %r14d
movq %rsi, %rbx
xorl %eax, %eax
cmpl $0x0, 0x14(%rsp)
jle 0x3ef10
xorl %edx, %edx
movabsq $0xffffffffff, %rdi     # imm = 0xFFFFFFFFFF
movq 0x20(%rsp), %r8
movl (%r12,%rdx,4), %esi
notl %esi
shrl $0x1f, %esi
addl %esi, %eax
incq %rdx
cmpq %rdx, %r8
jne 0x3eef7
shlq $0x28, %rax
jmp 0x3ef1a
movabsq $0xffffffffff, %rdi     # imm = 0xFFFFFFFFFF
andq %rdi, %rcx
orq %rax, %rcx
movq %rcx, 0x18(%r15)
movq 0x18(%r15), %rax
incq %rdi
cmpq %rdi, %rax
jae 0x3ef36
movl %eax, %eax
movq %rax, 0x18(%r15)
movq 0x48(%r15), %rdi
callq 0x45c0
movq %r14, 0x38(%r15)
movq (%rsp), %rax
movq %rax, 0x40(%r15)
movq %rbx, 0x48(%r15)
andb $-0x9, 0xbc(%r15)
xorl %eax, %eax
addq $0x2028, %rsp           # imm = 0x2028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq