// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/vcf.c
// Function: bcf_hdr_set_samples
int bcf_hdr_set_samples(bcf_hdr_t *hdr, const char *samples, int is_file)
{
    if ( samples && !strcmp("-",samples) ) return 0;            // keep all samples

    int i, narr = bit_array_size(bcf_hdr_nsamples(hdr));
    hdr->keep_samples = (uint8_t*) calloc(narr,1);
    if (!hdr->keep_samples) return -1;

    hdr->nsamples_ori = bcf_hdr_nsamples(hdr);
    if ( !samples )
    {
        // exclude all samples
        khint_t k;
        vdict_t *d = (vdict_t*)hdr->dict[BCF_DT_SAMPLE], *new_dict;
        new_dict = kh_init(vdict);
        if (!new_dict) return -1;

        bcf_hdr_nsamples(hdr) = 0;

        for (k = kh_begin(d); k != kh_end(d); ++k)
            if (kh_exist(d, k)) free((char*)kh_key(d, k));
        kh_destroy(vdict, d);
        hdr->dict[BCF_DT_SAMPLE] = new_dict;
        if (bcf_hdr_sync(hdr) < 0) return -1;

        return 0;
    }

    if ( samples[0]=='^' )
        for (i=0; i<bcf_hdr_nsamples(hdr); i++) bit_array_set(hdr->keep_samples,i);

    int idx, n, ret = 0;
    char **smpls = hts_readlist(samples[0]=='^'?samples+1:samples, is_file, &n);
    if ( !smpls ) return -1;
    for (i=0; i<n; i++)
    {
        idx = bcf_hdr_id2int(hdr,BCF_DT_SAMPLE,smpls[i]);
        if ( idx<0 )
        {
            if ( !ret ) ret = i+1;
            continue;
        }
        assert( idx<bcf_hdr_nsamples(hdr) );
        if (  samples[0]=='^' )
            bit_array_clear(hdr->keep_samples, idx);
        else
            bit_array_set(hdr->keep_samples, idx);
    }
    for (i=0; i<n; i++) free(smpls[i]);
    free(smpls);

    bcf_hdr_nsamples(hdr) = 0;
    for (i=0; i<hdr->nsamples_ori; i++)
        if ( bit_array_test(hdr->keep_samples,i) ) bcf_hdr_nsamples(hdr)++;

    if ( !bcf_hdr_nsamples(hdr) ) { free(hdr->keep_samples); hdr->keep_samples=NULL; }
    else
    {
        // Make new list and dictionary with desired samples
        char **samples = (char**) malloc(sizeof(char*)*bcf_hdr_nsamples(hdr));
        vdict_t *new_dict, *d;
        int k, res;
        if (!samples) return -1;

        new_dict = kh_init(vdict);
        if (!new_dict) {
            free(samples);
            return -1;
        }
        idx = 0;
        for (i=0; i<hdr->nsamples_ori; i++) {
            if ( bit_array_test(hdr->keep_samples,i) ) {
                samples[idx] = hdr->samples[i];
                k = kh_put(vdict, new_dict, hdr->samples[i], &res);
                if (res < 0) {
                    free(samples);
                    kh_destroy(vdict, new_dict);
                    return -1;
                }
                kh_val(new_dict, k) = bcf_idinfo_def;
                kh_val(new_dict, k).id = idx;
                idx++;
            }
        }

        // Delete desired samples from old dictionary, so we don't free them
        d = (vdict_t*)hdr->dict[BCF_DT_SAMPLE];
        for (i=0; i < idx; i++) {
            int k = kh_get(vdict, d, samples[i]);
            if (k < kh_end(d)) kh_del(vdict, d, k);
        }

        // Free everything else
        for (k = kh_begin(d); k != kh_end(d); ++k)
            if (kh_exist(d, k)) free((char*)kh_key(d, k));
        kh_destroy(vdict, d);
        hdr->dict[BCF_DT_SAMPLE] = new_dict;

        free(hdr->samples);
        hdr->samples = samples;

        if (bcf_hdr_sync(hdr) < 0)
            return -1;
    }

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
je 0x3d484
movzbl (%r14), %eax
subl $0x2d, %eax
jne 0x3d47a
movzbl 0x1(%r14), %eax
negl %eax
testl %eax, %eax
je 0x3d504
movl 0x8(%rbx), %r12d
leal 0x7(%r12), %eax
testl %r12d, %r12d
cmovnsl %r12d, %eax
sarl $0x3, %eax
incl %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x42f0
movq %rax, 0x78(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x3d90e
movl %r12d, 0x70(%rbx)
testq %r14, %r14
je 0x3d50b
cmpb $0x5e, (%r14)
jne 0x3d5ad
testl %r12d, %r12d
jle 0x3d5b1
xorl %eax, %eax
movl %eax, %ecx
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
movq 0x78(%rbx), %rcx
movl %eax, %esi
shrl $0x3, %esi
orb %dl, (%rcx,%rsi)
incl %eax
cmpl 0x8(%rbx), %eax
jl 0x3d4d6
xorl %edi, %edi
cmpb $0x5e, (%r14)
sete %dil
jmp 0x3d5b6
xorl %ebp, %ebp
jmp 0x3d90e
movq 0x38(%rbx), %r14
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
testq %rax, %rax
je 0x3d90e
movq %rax, %r15
movl $0x0, 0x8(%rbx)
movl (%r14), %eax
testl %eax, %eax
je 0x3d574
xorl %ebp, %ebp
xorl %r12d, %r12d
movq 0x10(%r14), %rcx
movl %r12d, %edx
shrl $0x4, %edx
movl (%rcx,%rdx,4), %edx
movl %ebp, %ecx
andb $0x1e, %cl
shrl %cl, %edx
testb $0x3, %dl
jne 0x3d569
movq 0x18(%r14), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x45c0
movl (%r14), %eax
incl %r12d
addl $0x2, %ebp
cmpl %eax, %r12d
jne 0x3d53d
movq 0x18(%r14), %rdi
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
movq %r15, 0x38(%rbx)
movq %rbx, %rdi
callq 0x2ab97
movl %eax, %ebp
sarl $0x1f, %ebp
jmp 0x3d90e
xorl %edi, %edi
jmp 0x3d5b6
movl $0x1, %edi
addq %r14, %rdi
leaq 0x4(%rsp), %rdx
movl %r15d, %esi
callq 0xae3b
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x3d90e
movq %rax, %r15
cmpl $0x0, 0x4(%rsp)
jle 0x3d66b
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%r15,%r12,8), %rdx
movq %rbx, %rdi
movl $0x2, %esi
callq 0x2d3d9
testl %eax, %eax
js 0x3d62a
cmpl 0x8(%rbx), %eax
jge 0x3d9f1
movl %eax, %ecx
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
cmpb $0x5e, (%r14)
movq 0x78(%rbx), %rcx
movb (%rcx,%rax), %sil
jne 0x3d638
notb %dl
andb %dl, %sil
jmp 0x3d63b
leal 0x1(%r12), %eax
testl %r13d, %r13d
cmovel %eax, %r13d
jmp 0x3d63f
orb %dl, %sil
movb %sil, (%rcx,%rax)
incq %r12
movslq 0x4(%rsp), %rax
cmpq %rax, %r12
jl 0x3d5e8
testl %eax, %eax
jle 0x3d66e
xorl %r14d, %r14d
movq (%r15,%r14,8), %rdi
callq 0x45c0
incq %r14
movslq 0x4(%rsp), %rax
cmpq %rax, %r14
jl 0x3d653
jmp 0x3d66e
xorl %r13d, %r13d
movq %r15, %rdi
callq 0x45c0
movl $0x0, 0x8(%rbx)
movl 0x70(%rbx), %r15d
testl %r15d, %r15d
jle 0x3d8fa
movq 0x78(%rbx), %rcx
xorl %eax, %eax
xorl %edx, %edx
movl %edx, %esi
shrl $0x3, %esi
movzbl (%rcx,%rsi), %esi
movl %edx, %edi
andl $0x7, %edi
btl %edi, %esi
jae 0x3d6aa
incl %eax
movl %eax, 0x8(%rbx)
incl %edx
cmpl %edx, %r15d
jne 0x3d692
testl %eax, %eax
je 0x3d8fa
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x46a0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x3d90e
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x3d91f
testl %r15d, %r15d
movq %rbx, 0x30(%rsp)
jle 0x3d92b
movl %r13d, 0x14(%rsp)
xorl %r12d, %r12d
leaq 0x24(%rsp), %r14
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
movq 0x78(%rbx), %rax
movl %r12d, %ecx
shrl $0x3, %ecx
movzbl (%rax,%rcx), %eax
movl %r12d, %ecx
andl $0x7, %ecx
btl %ecx, %eax
jae 0x3d797
movq 0x40(%rbx), %rax
movq (%rax,%r12,8), %rsi
movslq %ebp, %rax
movq 0x8(%rsp), %rcx
movq %rsi, (%rcx,%rax,8)
movq 0x28(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0x3da10
cmpl $0x0, 0x24(%rsp)
js 0x3d9d5
movq 0x20(%r15), %rcx
cltq
imulq $0x38, %rax, %rax
movq %r13, 0x30(%rcx,%rax)
movups 0x6d817(%rip), %xmm0    # 0xaaf88
movups %xmm0, 0x20(%rcx,%rax)
movups 0x6d7fb(%rip), %xmm0    # 0xaaf78
movups %xmm0, 0x10(%rcx,%rax)
movups 0x6d7df(%rip), %xmm0    # 0xaaf68
movups %xmm0, (%rcx,%rax)
movl %ebp, 0x30(%rcx,%rax)
incl %ebp
movl 0x70(%rbx), %r15d
incq %r12
movslq %r15d, %rax
cmpq %rax, %r12
jl 0x3d713
movq 0x38(%rbx), %r8
testl %ebp, %ebp
jle 0x3d8ee
movl %ebp, %eax
movq %rax, 0x40(%rsp)
movq $0x0, 0x18(%rsp)
movq %r8, 0x48(%rsp)
movl (%r8), %edx
movl $0x0, %r13d
testl %edx, %edx
je 0x3d8a5
movq 0x8(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movb (%rsi), %cl
testb %cl, %cl
je 0x3d80b
leaq 0x1(%rsi), %rax
movl $0x811c9dc5, %ebp       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %ebp, %ecx
imull $0x1000193, %ecx, %ebp  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x3d7f5
jmp 0x3d810
movl $0x811c9dc5, %ebp       # imm = 0x811C9DC5
movq %rdx, 0x38(%rsp)
decl %edx
andl %edx, %ebp
movq 0x10(%r8), %rdi
movl $0x1, %r12d
movl %ebp, %r13d
movl %edx, 0x20(%rsp)
movq %rdi, 0x50(%rsp)
movl %r13d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r14d
leal (,%r13,2), %r15d
andl $0x1e, %r15d
movl %r14d, %eax
movl %r15d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x3d892
testb $0x1, %al
jne 0x3d882
movq 0x18(%r8), %rax
movl %r13d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rsi, %rbx
callq 0x46e0
movq 0x50(%rsp), %rdi
movl 0x20(%rsp), %edx
movq %rbx, %rsi
movq 0x48(%rsp), %r8
movq 0x30(%rsp), %rbx
testl %eax, %eax
je 0x3d892
addl %r12d, %r13d
andl %edx, %r13d
incl %r12d
cmpl %ebp, %r13d
jne 0x3d82f
jmp 0x3d8d6
movl %r15d, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x38(%rsp), %rdx
cmovnel %edx, %r13d
cmpl %edx, %r13d
jae 0x3d8d6
movq 0x10(%r8), %rax
movl %r13d, %edx
shrl $0x4, %edx
movl (%rax,%rdx,4), %esi
addl %r13d, %r13d
andl $0x1e, %r13d
movl %esi, %edi
movl %r13d, %ecx
shrl %cl, %edi
testb $0x3, %dil
jne 0x3d8d6
btsl %r13d, %esi
movl %esi, (%rax,%rdx,4)
decl 0x4(%r8)
movq 0x18(%rsp), %rcx
incq %rcx
movq %rcx, 0x18(%rsp)
cmpq 0x40(%rsp), %rcx
jne 0x3d7c7
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl 0x14(%rsp), %r13d
jmp 0x3d92f
movq 0x78(%rbx), %rdi
callq 0x45c0
movq $0x0, 0x78(%rbx)
movl %r13d, %ebp
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
callq 0x45c0
jmp 0x3d90e
movq 0x38(%rbx), %r8
movl (%r8), %eax
testl %eax, %eax
je 0x3d97f
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x10(%r8), %rcx
movl %r15d, %edx
shrl $0x4, %edx
movl (%rcx,%rdx,4), %edx
movl %r14d, %ecx
andb $0x1e, %cl
shrl %cl, %edx
testb $0x3, %dl
jne 0x3d971
movq 0x18(%r8), %rax
movq (%rax,%r15,8), %rdi
movq %r8, %rbx
callq 0x45c0
movq %rbx, %r8
movq 0x30(%rsp), %rbx
movl (%r8), %eax
incq %r15
movl %eax, %ecx
addl $0x2, %r14d
cmpq %rcx, %r15
jne 0x3d93c
movq 0x18(%r8), %rdi
movq %r8, %r14
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
movq 0x28(%rsp), %rax
movq %rax, 0x38(%rbx)
movq 0x40(%rbx), %rdi
callq 0x45c0
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rbx)
movq %rbx, %rdi
callq 0x2ab97
testl %eax, %eax
jns 0x3d90b
jmp 0x3d90e
movq 0x8(%rsp), %rdi
callq 0x45c0
movq %r15, %rdi
callq 0x2e446
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x3d90e
leaq 0x6e6ec(%rip), %rdi     # 0xac0e4
leaq 0x6dbd4(%rip), %rsi     # 0xab5d3
leaq 0x6e6f8(%rip), %rcx     # 0xac0fe
movl $0x1393, %edx           # imm = 0x1393
callq 0x42e0