// File: /workspace/github_c_makefile_star2_O1/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, %r13
testq %rsi, %rsi
je 0x3e2b0
leaq 0x6e897(%rip), %rdi     # 0xacb37
movq %r14, %rsi
callq 0x46e0
testl %eax, %eax
je 0x3e3bf
movl 0x8(%r13), %ebx
leal 0x7(%rbx), %eax
testl %ebx, %ebx
cmovnsl %ebx, %eax
sarl $0x3, %eax
incl %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x42f0
movq %rax, 0x78(%r13)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x3e7d4
movl %ebx, 0x70(%r13)
testq %r14, %r14
je 0x3e3c6
cmpb $0x5e, (%r14)
jne 0x3e31c
cmpl $0x0, 0x8(%r13)
jle 0x3e31c
xorl %eax, %eax
movl %eax, %ecx
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
movq 0x78(%r13), %rcx
movl %eax, %esi
shrl $0x3, %esi
orb %dl, (%rcx,%rsi)
incl %eax
cmpl 0x8(%r13), %eax
jl 0x3e2fc
xorl %edi, %edi
cmpb $0x5e, (%r14)
sete %dil
addq %r14, %rdi
leaq 0x8(%rsp), %rdx
movl %r15d, %esi
callq 0xb182
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x3e7d4
movq %rax, %r15
cmpl $0x0, 0x8(%rsp)
jle 0x3e460
xorl %r12d, %r12d
xorl %ebx, %ebx
movq (%r15,%r12,8), %rdx
movq %r13, %rdi
movl $0x2, %esi
callq 0x2e585
testl %eax, %eax
js 0x3e39a
cmpl 0x8(%r13), %eax
jge 0x3e7e5
movl %eax, %ecx
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
cmpb $0x5e, (%r14)
movq 0x78(%r13), %rcx
movb (%rcx,%rax), %sil
jne 0x3e3a6
notb %dl
andb %dl, %sil
jmp 0x3e3a9
leal 0x1(%r12), %eax
testl %ebx, %ebx
cmovel %eax, %ebx
jmp 0x3e3ad
orb %dl, %sil
movb %sil, (%rcx,%rax)
incq %r12
movslq 0x8(%rsp), %rax
cmpq %rax, %r12
jl 0x3e357
jmp 0x3e462
xorl %ebp, %ebp
jmp 0x3e7d4
movq 0x38(%r13), %r14
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
testq %rax, %rax
je 0x3e7d4
movq %rax, %r15
movl $0x0, 0x8(%r13)
cmpl $0x0, (%r14)
je 0x3e427
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x10(%r14), %rax
movl %ebp, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
movl %ebx, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x3e41d
movq 0x18(%r14), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x45c0
incl %ebp
addl $0x2, %ebx
cmpl (%r14), %ebp
jne 0x3e3f7
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(%r13)
movq %r13, %rdi
callq 0x2bc46
movl %eax, %ebp
sarl $0x1f, %ebp
jmp 0x3e7d4
xorl %ebx, %ebx
movl %ebx, 0xc(%rsp)
cmpl $0x0, 0x8(%rsp)
jle 0x3e485
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rdi
callq 0x45c0
incq %rbx
movslq 0x8(%rsp), %rax
cmpq %rax, %rbx
jl 0x3e46f
movq %r15, %rdi
callq 0x45c0
movl $0x0, 0x8(%r13)
movl 0x70(%r13), %eax
testl %eax, %eax
movl 0xc(%rsp), %ebx
jle 0x3e4c4
movq 0x78(%r13), %rcx
xorl %edx, %edx
movl %edx, %esi
shrl $0x3, %esi
movzbl (%rcx,%rsi), %esi
movl %edx, %edi
andl $0x7, %edi
btl %edi, %esi
jae 0x3e4be
incl 0x8(%r13)
incl %edx
cmpl %edx, %eax
jne 0x3e4a7
movslq 0x8(%r13), %rdi
testq %rdi, %rdi
je 0x3e5af
shlq $0x3, %rdi
callq 0x46a0
testq %rax, %rax
je 0x3e7d4
movq %rax, %rbx
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
testq %rax, %rax
je 0x3e5c7
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x70(%r13)
jle 0x3e5d4
xorl %r14d, %r14d
leaq 0x1c(%rsp), %r15
xorl %ebp, %ebp
movq 0x20(%rsp), %r12
movq 0x78(%r13), %rax
movl %r14d, %ecx
shrl $0x3, %ecx
movzbl (%rax,%rcx), %eax
movl %r14d, %ecx
andl $0x7, %ecx
btl %ecx, %eax
jae 0x3e59d
movq 0x40(%r13), %rax
movq (%rax,%r14,8), %rcx
movslq %ebp, %rdx
movq %rcx, (%rbx,%rdx,8)
movq (%rax,%r14,8), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x3e804
cmpl $0x0, 0x1c(%rsp)
js 0x3e7bf
movq 0x20(%r12), %rcx
cltq
imulq $0x38, %rax, %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rdx, 0x30(%rcx,%rax)
movups 0x6fa5d(%rip), %xmm0    # 0xadfd8
movups %xmm0, 0x20(%rcx,%rax)
movups 0x6fa41(%rip), %xmm0    # 0xadfc8
movups %xmm0, 0x10(%rcx,%rax)
movups 0x6fa25(%rip), %xmm0    # 0xadfb8
movups %xmm0, (%rcx,%rax)
movl %ebp, 0x30(%rcx,%rax)
incl %ebp
incq %r14
movslq 0x70(%r13), %rax
cmpq %rax, %r14
jl 0x3e51d
jmp 0x3e5d6
movq 0x78(%r13), %rdi
callq 0x45c0
movq $0x0, 0x78(%r13)
movl %ebx, %ebp
jmp 0x3e7d4
movq %rbx, %rdi
callq 0x45c0
jmp 0x3e7d4
xorl %ebp, %ebp
movq %r13, 0x40(%rsp)
movq 0x38(%r13), %r8
testl %ebp, %ebp
movq %rbx, 0x10(%rsp)
movq %r8, 0x38(%rsp)
jle 0x3e71f
movl %ebp, %eax
movq %rax, 0x48(%rsp)
xorl %r9d, %r9d
movl (%r8), %edx
movl $0x0, %r13d
testl %edx, %edx
je 0x3e6e0
movq (%rbx,%r9,8), %rbx
movb (%rbx), %cl
testb %cl, %cl
movq %r9, 0x30(%rsp)
je 0x3e63d
leaq 0x1(%rbx), %rax
movl $0x811c9dc5, %r12d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r12d, %ecx
imull $0x1000193, %ecx, %r12d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x3e625
jmp 0x3e643
movl $0x811c9dc5, %r12d      # imm = 0x811C9DC5
movq %rdx, 0x28(%rsp)
decl %edx
andl %edx, %r12d
movq 0x10(%r8), %rsi
movl $0x1, %r15d
movl %r12d, %r13d
movl %edx, 0x18(%rsp)
movq %rsi, 0x50(%rsp)
movl %r13d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %ebp
leal (,%r13,2), %r14d
andl $0x1e, %r14d
movl %ebp, %eax
movl %r14d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x3e6c4
testb $0x1, %al
jne 0x3e6ac
movq 0x18(%r8), %rax
movl %r13d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rbx, %rsi
callq 0x46e0
movq 0x50(%rsp), %rsi
movl 0x18(%rsp), %edx
movq 0x38(%rsp), %r8
testl %eax, %eax
je 0x3e6c4
addl %r15d, %r13d
andl %edx, %r13d
incl %r15d
cmpl %r12d, %r13d
jne 0x3e663
movq 0x28(%rsp), %rdx
movl %edx, %r13d
jmp 0x3e6d6
movl %r14d, %ecx
shrl %cl, %ebp
testb $0x3, %bpl
movq 0x28(%rsp), %rdx
cmovnel %edx, %r13d
movq 0x10(%rsp), %rbx
movq 0x30(%rsp), %r9
cmpl %edx, %r13d
jae 0x3e711
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 0x3e711
btsl %r13d, %esi
movl %esi, (%rax,%rdx,4)
decl 0x4(%r8)
incq %r9
cmpq 0x48(%rsp), %r9
jne 0x3e5fb
cmpl $0x0, (%r8)
movq 0x40(%rsp), %r15
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
je 0x3e76c
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x10(%r8), %rax
movl %r14d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
movl %ebx, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x3e75e
movq 0x18(%r8), %rax
movq (%rax,%r14,8), %rdi
callq 0x45c0
movq 0x38(%rsp), %r8
incq %r14
movl (%r8), %eax
addl $0x2, %ebx
cmpq %rax, %r14
jne 0x3e734
movq 0x18(%r8), %rdi
movq %r8, %rbx
callq 0x45c0
movq 0x10(%rbx), %rdi
callq 0x45c0
movq 0x20(%rbx), %rdi
callq 0x45c0
movq %rbx, %rdi
callq 0x45c0
movq 0x20(%rsp), %rax
movq %rax, 0x38(%r15)
movq 0x40(%r15), %rdi
callq 0x45c0
movq 0x10(%rsp), %rax
movq %rax, 0x40(%r15)
movq %r15, %rdi
callq 0x2bc46
testl %eax, %eax
js 0x3e7d4
movl 0xc(%rsp), %ebp
jmp 0x3e7d4
movq %rbx, %rdi
callq 0x45c0
movq %r12, %rdi
callq 0x2f668
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x70948(%rip), %rdi     # 0xaf134
leaq 0x6fe30(%rip), %rsi     # 0xae623
leaq 0x70954(%rip), %rcx     # 0xaf14e
movl $0x1393, %edx           # imm = 0x1393
callq 0x42e0