// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/vcf.c
// Function: bcf_hdr_subset
bcf_hdr_t *bcf_hdr_subset(const bcf_hdr_t *h0, int n, char *const* samples, int *imap)
{
    void *names_hash = khash_str2int_init();
    kstring_t htxt = {0,0,0};
    kstring_t str = {0,0,0};
    bcf_hdr_t *h = bcf_hdr_init("w");
    int r = 0;
    if (!h || !names_hash) {
        hts_log_error("Failed to allocate bcf header");
        goto err;
    }
    if (bcf_hdr_format(h0, 1, &htxt) < 0) {
        hts_log_error("Failed to get header text");
        goto err;
    }
    bcf_hdr_set_version(h,bcf_hdr_get_version(h0));
    int j;
    for (j=0; j<n; j++) imap[j] = -1;
    if ( bcf_hdr_nsamples(h0) > 0) {
        char *p = find_chrom_header_line(htxt.s);
        int i = 0, end = n? 8 : 7;
        while ((p = strchr(p, '\t')) != 0 && i < end) ++i, ++p;
        if (i != end) {
            hts_log_error("Wrong number of columns in header #CHROM line");
            goto err;
        }
        r |= kputsn(htxt.s, p - htxt.s, &str) < 0;
        for (i = 0; i < n; ++i) {
            if ( khash_str2int_has_key(names_hash,samples[i]) )
            {
                hts_log_error("Duplicate sample name \"%s\"", samples[i]);
                goto err;
            }
            imap[i] = bcf_hdr_id2int(h0, BCF_DT_SAMPLE, samples[i]);
            if (imap[i] < 0) continue;
            r |= kputc('\t', &str) < 0;
            r |= kputs(samples[i], &str) < 0;
            r |= khash_str2int_inc(names_hash,samples[i]) < 0;
        }
    } else r |= kputsn(htxt.s, htxt.l, &str) < 0;
    while (str.l && (!str.s[str.l-1] || str.s[str.l-1]=='\n') ) str.l--; // kill trailing zeros and newlines
    r |= kputc('\n',&str) < 0;
    if (r) {
        hts_log_error("%s", strerror(errno));
        goto err;
    }
    if ( bcf_hdr_parse(h, str.s) < 0 ) {
        bcf_hdr_destroy(h);
        h = NULL;
    }
    free(str.s);
    free(htxt.s);
    khash_str2int_destroy(names_hash);
    return h;

 err:
    ks_free(&str);
    ks_free(&htxt);
    khash_str2int_destroy(names_hash);
    bcf_hdr_destroy(h);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, %r15
movq %rdx, 0x60(%rsp)
movl %esi, %ebp
movq %rdi, %rbx
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
movq %rax, %r13
pxor %xmm0, %xmm0
movdqa %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
leaq 0x6c8d8(%rip), %rdi     # 0xa9401
callq 0x2df79
movq %rax, %r14
testq %rax, %rax
setne %al
testq %r13, %r13
setne %cl
testb %al, %cl
je 0x3cca5
leaq 0x70(%rsp), %rdx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x2f5bf
testl %eax, %eax
js 0x3ccb5
movq %rbx, %rdi
callq 0x2de43
movq %r14, 0x28(%rsp)
movq %r14, %rdi
movq %rax, %rsi
callq 0x2de88
testl %ebp, %ebp
jle 0x3cb8e
movl %ebp, %edx
shlq $0x2, %rdx
movq %r15, %rdi
movl $0xff, %esi
callq 0x4250
cmpl $0x0, 0x8(%rbx)
movq 0x80(%rsp), %r12
jle 0x3cd6c
movq %rbx, 0xa0(%rsp)
leaq 0x70447(%rip), %rsi     # 0xacff6
movl $0x7, %edx
movq %r12, %rdi
callq 0x4200
movq %r12, %rdi
testl %eax, %eax
je 0x3cbdd
leaq 0x7042b(%rip), %rsi     # 0xacff5
movq %r12, %rdi
callq 0x40d0
leaq 0x1(%rax), %rdi
testq %rax, %rax
cmoveq %rax, %rdi
cmpl $0x1, %ebp
movl $0x8, %ebx
sbbl $0x0, %ebx
movl $0x9, %esi
callq 0x4180
testq %rax, %rax
je 0x3cd45
movq %rax, %rdi
movl $0x1, %r14d
incq %rdi
movl $0x9, %esi
callq 0x4180
movq %rax, %rdi
leal 0x1(%r14), %eax
testq %rdi, %rdi
je 0x3cc25
cmpl %ebx, %r14d
movl %eax, %r14d
jb 0x3cc04
subl %ebx, %eax
cmpl $0x1, %eax
jne 0x3cd45
movq %r15, 0x98(%rsp)
movabsq $0x3fffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFFF
subq %r12, %rdi
movq %rdi, %rax
addq $0x2, %rax
je 0x3cdf6
movq %rdi, %r14
movq %rax, %rdi
shrq %rdi
xorl %r15d, %r15d
cmpq %rcx, %rax
cmovaq %r15, %rdi
addq %rax, %rdi
movq %rdi, 0x10(%rsp)
callq 0x46a0
testq %rax, %rax
je 0x3ce19
movq %rax, %rbx
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x43c0
movq %r14, %rcx
movb $0x0, (%rbx,%r14)
movl %ecx, %eax
shrl $0x1f, %eax
movl %eax, 0xc(%rsp)
movq %rbx, %r15
jmp 0x3ce2c
leaq 0x6f3c6(%rip), %rsi     # 0xac072
leaq 0x6ed08(%rip), %rdx     # 0xab9bb
jmp 0x3ccc3
leaq 0x6f3b6(%rip), %rsi     # 0xac072
leaq 0x6f3be(%rip), %rdx     # 0xac081
xorl %r15d, %r15d
movl $0x1, %edi
xorl %eax, %eax
callq 0x942d
movq %r15, %rdi
callq 0x45c0
movq 0x80(%rsp), %rdi
callq 0x45c0
pxor %xmm0, %xmm0
movdqa %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
testq %r13, %r13
je 0x3cd25
movq 0x18(%r13), %rdi
callq 0x45c0
movq 0x10(%r13), %rdi
callq 0x45c0
movq 0x20(%r13), %rdi
callq 0x45c0
movq %r13, %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x2e474
xorl %r14d, %r14d
movq %r14, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6f326(%rip), %rsi     # 0xac072
leaq 0x6f348(%rip), %rdx     # 0xac09b
xorl %r15d, %r15d
movl $0x1, %edi
xorl %eax, %eax
callq 0x942d
movq 0x28(%rsp), %r14
jmp 0x3ccd2
movq 0x70(%rsp), %rcx
movq %rcx, %rax
addq $0x2, %rax
je 0x3cdca
movq %rcx, %r14
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rbp
shrq %rbp
xorl %ebx, %ebx
testq %rcx, %rcx
cmovneq %rbx, %rbp
addq %rax, %rbp
movq %rbp, %rdi
callq 0x46a0
testq %rax, %rax
je 0x3cde4
movq %rax, %r15
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x43c0
movq %r14, %rcx
movb $0x0, (%r15,%r14)
movl %ecx, %eax
shrl $0x1f, %eax
movl %eax, 0xc(%rsp)
jmp 0x3d30f
callq 0x4050
movl $0x4b, (%rax)
movl $0x1, 0xc(%rsp)
xorl %r15d, %r15d
xorl %ebx, %ebx
jmp 0x3cdef
movl $0x1, 0xc(%rsp)
xorl %r15d, %r15d
xorl %ecx, %ecx
jmp 0x3d33d
callq 0x4050
movl $0x4b, (%rax)
movl $0x1, 0xc(%rsp)
xorl %ecx, %ecx
movq $0x0, 0x10(%rsp)
xorl %r15d, %r15d
jmp 0x3ce2c
movl $0x1, 0xc(%rsp)
xorl %ecx, %ecx
movq $0x0, 0x10(%rsp)
testl %ebp, %ebp
jle 0x3d30a
movl %ebp, %eax
movq %rax, 0x90(%rsp)
xorl %r14d, %r14d
movq %r13, 0x20(%rsp)
movq 0x10(%rsp), %rbp
movq %rbp, 0x10(%rsp)
movq %rcx, 0x18(%rsp)
movq %r15, 0x30(%rsp)
movq 0x60(%rsp), %rax
movq %r14, 0x50(%rsp)
movq (%rax,%r14,8), %r8
movl (%r13), %edx
movl $0x0, %r14d
testl %edx, %edx
je 0x3cf31
movb (%r8), %cl
testb %cl, %cl
je 0x3cea3
leaq 0x1(%r8), %rax
movl $0x811c9dc5, %r15d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r15d, %ecx
imull $0x1000193, %ecx, %r15d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x3ce8b
jmp 0x3cea9
movl $0x811c9dc5, %r15d      # imm = 0x811C9DC5
movq %rdx, 0x58(%rsp)
leal -0x1(%rdx), %r12d
andl %r12d, %r15d
movq 0x10(%r13), %rsi
movl $0x1, %r13d
movl %r15d, %r14d
movq %r8, 0x38(%rsp)
movq %rsi, 0x68(%rsp)
movl %r14d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %ebp
leal (%r14,%r14), %ebx
andl $0x1e, %ebx
movl %ebp, %eax
movl %ebx, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x3cf20
testb $0x1, %al
jne 0x3cf10
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movl %r14d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r8, %rsi
callq 0x46e0
movq 0x68(%rsp), %rsi
movq 0x38(%rsp), %r8
testl %eax, %eax
je 0x3cf20
addl %r13d, %r14d
andl %r12d, %r14d
incl %r13d
cmpl %r15d, %r14d
jne 0x3cecc
jmp 0x3cf3a
movl %ebx, %ecx
shrl %cl, %ebp
testb $0x3, %bpl
movq 0x58(%rsp), %rdx
cmovnel %edx, %r14d
cmpl %edx, %r14d
jne 0x3d41f
movq 0xa0(%rsp), %rdi
movl $0x2, %esi
movq %r8, %rdx
callq 0x2d3d9
movq 0x98(%rsp), %rcx
movq 0x50(%rsp), %r14
movl %eax, (%rcx,%r14,4)
testl %eax, %eax
js 0x3cfbf
movq 0x18(%rsp), %rcx
leaq 0x2(%rcx), %rax
movq 0x10(%rsp), %rbp
cmpq %rax, %rbp
movq 0x20(%rsp), %r13
movq 0x30(%rsp), %r15
jae 0x3cfd8
movq %rax, %rcx
shrq %rcx
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rdx, %rax
movl $0x0, %ebx
cmovbeq %rcx, %rbx
addq %rax, %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4860
movq 0x18(%rsp), %rcx
testq %rax, %rax
jne 0x3cfde
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x3cff5
movq 0x20(%rsp), %r13
movq 0x30(%rsp), %r15
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rbp
jmp 0x3d2f7
movq %rbp, %rbx
movq %r15, %rax
movw $0x9, (%rax,%rcx)
incq %rcx
movl $0x9, 0x44(%rsp)
movq %rbx, %rbp
movq %rax, %r15
movq %rcx, 0x18(%rsp)
movq 0x60(%rsp), %rax
movq (%rax,%r14,8), %r12
testq %r12, %r12
je 0x3d067
movq %r12, %rdi
callq 0x41c0
movq 0x18(%rsp), %rcx
leaq (%rcx,%rax), %rdi
addq $0x2, %rdi
cmpq %rcx, %rdi
jbe 0x3d074
movq %rax, 0x48(%rsp)
cmpq %rdi, %rbp
jae 0x3d086
movq %rdi, %rcx
shrq %rcx
movabsq $0x3fffffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rdx, %rdi
movl $0x0, %esi
cmovbeq %rcx, %rsi
addq %rdi, %rsi
movq %r15, %rdi
movq %rsi, 0x38(%rsp)
callq 0x4860
movq 0x18(%rsp), %rcx
movq %rax, %rbx
testq %rax, %rax
jne 0x3d08e
jmp 0x3d07f
callq 0x4050
movl $0xe, (%rax)
jmp 0x3d07f
callq 0x4050
movl $0x4b, (%rax)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x3d0c2
movq %rbp, 0x38(%rsp)
movq %r15, %rbx
leaq (%rbx,%rcx), %rdi
movq %r12, %rsi
movq 0x48(%rsp), %r12
movq %r12, %rdx
movq %rcx, %r14
callq 0x43c0
addq %r12, %r14
movq %r14, 0x18(%rsp)
movb $0x0, (%rbx,%r14)
movq 0x50(%rsp), %r14
movq 0x38(%rsp), %rbp
movq %rbx, %r15
movq %r12, %rbx
movq 0x60(%rsp), %rax
movq (%rax,%r14,8), %rsi
movl 0x8(%r13), %eax
cmpl 0xc(%r13), %eax
jb 0x3d0ff
movq %rsi, %r12
movl (%r13), %esi
movl 0x4(%r13), %eax
addl %eax, %eax
cmpl %eax, %esi
jbe 0x3d0ea
decl %esi
jmp 0x3d0ec
incl %esi
movq %r13, %rdi
callq 0x41b01
testl %eax, %eax
movq %r12, %rsi
js 0x3d20b
movq %r15, 0x30(%rsp)
movb (%rsi), %cl
testb %cl, %cl
je 0x3d12c
leaq 0x1(%rsi), %rax
movl $0x811c9dc5, %r15d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r15d, %ecx
imull $0x1000193, %ecx, %r15d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x3d114
jmp 0x3d132
movl $0x811c9dc5, %r15d      # imm = 0x811C9DC5
movl (%r13), %r12d
leal -0x1(%r12), %edx
andl %edx, %r15d
movq 0x10(%r13), %r10
movl %r15d, %eax
shrl $0x4, %eax
movl (%r10,%rax,4), %eax
leal (%r15,%r15), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x3d15e
movl %r15d, %r12d
jmp 0x3d24f
movq %rbx, 0x48(%rsp)
movq %rbp, 0x10(%rsp)
movl $0x1, %r14d
movl %r15d, %ebp
movq %r12, 0x88(%rsp)
movq %rsi, 0x38(%rsp)
movq %r10, 0x68(%rsp)
movl %edx, 0x58(%rsp)
movl %ebp, %eax
shrl $0x4, %eax
movl (%r10,%rax,4), %r13d
leal (,%rbp,2), %ebx
andl $0x1e, %ebx
movl %r13d, %eax
movl %ebx, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x3d215
testb $0x1, %al
jne 0x3d1cf
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x46e0
movl 0x58(%rsp), %edx
movq 0x68(%rsp), %r10
movq 0x38(%rsp), %rsi
testl %eax, %eax
je 0x3d215
btl %ebx, %r13d
cmovbl %ebp, %r12d
addl %r14d, %ebp
andl %edx, %ebp
incl %r14d
cmpl %r15d, %ebp
jne 0x3d187
movb $0x1, %al
movq 0x88(%rsp), %rdx
movl %edx, %ecx
cmpl %edx, %r12d
movq 0x20(%rsp), %r13
movq 0x10(%rsp), %rbp
movq 0x50(%rsp), %r14
movq 0x48(%rsp), %rbx
je 0x3d23b
jmp 0x3d24f
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
jmp 0x3d2e5
movl %ebx, %ecx
shrl %cl, %r13d
testb $0x2, %r13b
sete %al
movl %r12d, %ecx
movl %ebp, %r15d
movq 0x20(%rsp), %r13
movq 0x10(%rsp), %rbp
movq 0x50(%rsp), %r14
movq 0x48(%rsp), %rbx
cmpl 0x88(%rsp), %ecx
cmovel %r15d, %ecx
testb %al, %al
cmovnel %r15d, %ecx
movl %ecx, %r12d
movl %r12d, %edx
shrl $0x4, %edx
movl (%r10,%rdx,4), %r9d
leal (%r12,%r12), %ecx
andl $0x1e, %ecx
movl %r9d, %edi
shrl %cl, %edi
movl %r12d, %eax
testb $0x2, %dil
jne 0x3d282
testb $0x1, %dil
movq 0x30(%rsp), %r15
jne 0x3d2bb
movq 0x20(%r13), %rcx
movl (%rcx,%rax,4), %ecx
jmp 0x3d2e5
movq 0x18(%r13), %rdi
movl $0x3, %r8d
shll %cl, %r8d
movq %rsi, (%rdi,%rax,8)
notl %r8d
andl %r8d, %r9d
movl %r9d, (%r10,%rdx,4)
movq 0x4(%r13), %rcx
movq %rcx, %xmm0
psubd 0x6ba12(%rip), %xmm0    # 0xa8cc0
movq %xmm0, 0x4(%r13)
movq 0x30(%rsp), %r15
jmp 0x3d2de
movl $0x3, %edi
shll %cl, %edi
movq 0x18(%r13), %rcx
movq %rsi, (%rcx,%rax,8)
notl %edi
andl %edi, %r9d
movl %r9d, (%r10,%rdx,4)
movl 0x4(%r13), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x4(%r13)
movq 0x20(%r13), %rdx
movl %ecx, (%rdx,%rax,4)
orl 0x44(%rsp), %ebx
orl %ecx, %ebx
shrl $0x1f, %ebx
orl %ebx, 0xc(%rsp)
movq 0x18(%rsp), %rcx
incq %r14
cmpq 0x90(%rsp), %r14
jne 0x3ce4b
jmp 0x3d30f
movq 0x10(%rsp), %rbp
testq %rcx, %rcx
je 0x3d338
movq 0x28(%rsp), %r14
movzbl -0x1(%r15,%rcx), %eax
cmpl $0xa, %eax
je 0x3d32c
testl %eax, %eax
jne 0x3d417
decq %rcx
jne 0x3d319
movq %rbp, %rbx
xorl %ecx, %ecx
jmp 0x3d342
xorl %ecx, %ecx
movq %rbp, %rbx
movq 0x28(%rsp), %r14
leaq 0x2(%rcx), %rax
cmpq %rax, %rbx
jae 0x3d37e
movq %rcx, %rbx
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
xorl %esi, %esi
testq %rcx, %rcx
cmoveq %rdx, %rsi
addq %rax, %rsi
movq %r15, %rdi
callq 0x4860
movq %rbx, %rcx
testq %rax, %rax
jne 0x3d381
movl $0x1, %ecx
jmp 0x3d38c
movq %r15, %rax
movw $0xa, (%rax,%rcx)
xorl %ecx, %ecx
movq %rax, %r15
orl 0xc(%rsp), %ecx
je 0x3d3c0
callq 0x4050
movl (%rax), %edi
callq 0x4140
leaq 0x6eccd(%rip), %rsi     # 0xac072
leaq 0x6e1c4(%rip), %rdx     # 0xab570
movl $0x1, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x942d
jmp 0x3ccd2
movq %r14, %rdi
movq %r15, %rsi
callq 0x2d4f2
testl %eax, %eax
jns 0x3d3da
movq %r14, %rdi
callq 0x2e474
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x45c0
movq 0x80(%rsp), %rdi
callq 0x45c0
movq 0x18(%r13), %rdi
callq 0x45c0
movq 0x10(%r13), %rdi
callq 0x45c0
movq 0x20(%r13), %rdi
callq 0x45c0
movq %r13, %rdi
callq 0x45c0
jmp 0x3cd30
movq %rbp, %rbx
jmp 0x3d342
leaq 0x6ec4c(%rip), %rsi     # 0xac072
leaq 0x6ec9c(%rip), %rdx     # 0xac0c9
movl $0x1, %edi
movq %r8, %rcx
xorl %eax, %eax
callq 0x942d
movq 0x28(%rsp), %r14
movq 0x20(%rsp), %r13
movq 0x30(%rsp), %r15
jmp 0x3ccd2