// File: /workspace/github_c_makefile_star2_O2/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 $0x18, %rsp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
je 0x2dc3d
movzbl (%r14), %eax
subl $0x2d, %eax
jne 0x2dc37
movzbl 0x1(%r14), %eax
negl %eax
testl %eax, %eax
je 0x2dca2
movl 0x8(%rbx), %r12d
pushq $0x8
popq %rcx
movl %r12d, %eax
cltd
idivl %ecx
incl %eax
movslq %eax, %rdi
pushq $0x1
popq %rsi
callq 0x42f0
movq %rax, 0x78(%rbx)
pushq $-0x1
popq %r13
testq %rax, %rax
je 0x2dfd6
movl %r12d, 0x70(%rbx)
testq %r14, %r14
je 0x2dcaa
xorl %edi, %edi
cmpb $0x5e, (%r14)
pushq $0x1
popq %rbp
jne 0x2dd0b
cmpl %r12d, %edi
jge 0x2dd01
movl %edi, %ecx
andb $0x7, %cl
movl %ebp, %eax
shll %cl, %eax
movq 0x78(%rbx), %rcx
movl %edi, %edx
shrl $0x3, %edx
orb %al, (%rcx,%rdx)
incl %edi
movl 0x8(%rbx), %r12d
jmp 0x2dc80
xorl %r13d, %r13d
jmp 0x2dfd6
movq 0x38(%rbx), %r14
callq 0x251e4
testq %rax, %rax
je 0x2dfd6
movq %rax, %r15
andl $0x0, 0x8(%rbx)
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpl (%r14), %r12d
je 0x2deda
movq 0x10(%r14), %rax
movl %r12d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
movl %ebp, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x2dcf9
movq 0x18(%r14), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x45c0
incl %r12d
addl $0x2, %ebp
jmp 0x2dcc8
xorl %edi, %edi
cmpb $0x5e, (%r14)
sete %dil
addq %r14, %rdi
leaq 0x4(%rsp), %rdx
movl %r15d, %esi
callq 0x9a53
pushq $-0x1
popq %r13
testq %rax, %rax
je 0x2dfd6
movq %rax, %r15
xorl %r13d, %r13d
pushq $0x2
popq %r12
movl $0x0, (%rsp)
movslq 0x4(%rsp), %rax
cmpq %rax, %r13
jge 0x2dd9d
movq (%r15,%r13,8), %rdx
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2489c
testl %eax, %eax
js 0x2dd80
cmpl 0x8(%rbx), %eax
jge 0x2dfe8
movl %eax, %ecx
andb $0x7, %cl
movl %ebp, %edx
shll %cl, %edx
shrl $0x3, %eax
cmpb $0x5e, (%r14)
movq 0x78(%rbx), %rcx
movb (%rcx,%rax), %sil
jne 0x2dd91
notb %dl
andb %dl, %sil
jmp 0x2dd94
leal 0x1(%r13), %eax
movl (%rsp), %ecx
testl %ecx, %ecx
cmovel %eax, %ecx
movl %ecx, (%rsp)
jmp 0x2dd98
orb %dl, %sil
movb %sil, (%rcx,%rax)
incq %r13
jmp 0x2dd39
xorl %r14d, %r14d
pushq $-0x1
popq %r13
cltq
cmpq %rax, %r14
jge 0x2ddbd
movq (%r15,%r14,8), %rdi
callq 0x45c0
incq %r14
movl 0x4(%rsp), %eax
jmp 0x2dda4
movq %r15, %rdi
callq 0x45c0
andl $0x0, 0x8(%rbx)
movl 0x70(%rbx), %ebp
xorl %eax, %eax
testl %ebp, %ebp
movl $0x0, %ecx
cmovgl %ebp, %ecx
xorl %edx, %edx
cmpl %edx, %ecx
je 0x2ddfe
movq 0x78(%rbx), %rsi
movl %edx, %edi
shrl $0x3, %edi
movzbl (%rsi,%rdi), %esi
movl %edx, %edi
andl $0x7, %edi
btl %edi, %esi
jae 0x2ddfa
incl %eax
movl %eax, 0x8(%rbx)
incl %edx
jmp 0x2ddda
testl %eax, %eax
je 0x2defa
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x46a0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x2dfd6
callq 0x251e4
testq %rax, %rax
je 0x2dfb6
movq %rax, %r15
xorl %r13d, %r13d
leaq 0x14(%rsp), %r12
xorl %r14d, %r14d
movslq %ebp, %rax
cmpq %rax, %r13
jge 0x2df0d
movq 0x78(%rbx), %rax
movl %r13d, %ecx
shrl $0x3, %ecx
movzbl (%rax,%rcx), %eax
movl %r13d, %ecx
andl $0x7, %ecx
btl %ecx, %eax
jae 0x2ded2
movq 0x40(%rbx), %rax
movq (%rax,%r13,8), %rsi
movslq %r14d, %rax
movq 0x8(%rsp), %rbp
movq %rsi, (%rbp,%rax,8)
movq %r15, %rdi
movq %r12, %rdx
callq 0x2e007
cmpl $0x0, 0x14(%rsp)
js 0x2dfc2
movq 0x20(%r15), %rcx
cltq
imulq $0x38, %rax, %rax
movups 0x57e33(%rip), %xmm0    # 0x85cd0
movups %xmm0, 0x20(%rcx,%rax)
movups 0x57e17(%rip), %xmm0    # 0x85cc0
movups %xmm0, 0x10(%rcx,%rax)
movups 0x57dfb(%rip), %xmm0    # 0x85cb0
movups %xmm0, (%rcx,%rax)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rdx, 0x30(%rcx,%rax)
movq 0x20(%r15), %rcx
movl %r14d, 0x30(%rcx,%rax)
incl %r14d
movl 0x70(%rbx), %ebp
incq %r13
jmp 0x2de3c
movq %r14, %rdi
callq 0x25526
movq %r15, 0x38(%rbx)
movq %rbx, %rdi
callq 0x2276e
movl %eax, %r13d
sarl $0x1f, %r13d
jmp 0x2dfd6
movq 0x78(%rbx), %rdi
callq 0x45c0
andq $0x0, 0x78(%rbx)
jmp 0x2dfb0
movq 0x38(%rbx), %r12
xorl %r13d, %r13d
testl %r14d, %r14d
cmovlel %r13d, %r14d
movq 0x8(%rsp), %rbp
cmpq %r13, %r14
je 0x2df47
movq (%rbp,%r13,8), %rsi
movq %r12, %rdi
callq 0x246ef
cmpl (%r12), %eax
jae 0x2df42
movq %r12, %rdi
movl %eax, %esi
callq 0x2e1ed
incq %r13
jmp 0x2df20
xorl %r14d, %r14d
xorl %r13d, %r13d
movl (%r12), %eax
cmpq %rax, %r13
je 0x2df87
movq 0x10(%r12), %rax
movl %r13d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
movl %r14d, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x2df7e
movq 0x18(%r12), %rax
movq (%rax,%r13,8), %rdi
callq 0x45c0
incq %r13
addl $0x2, %r14d
jmp 0x2df4d
movq %r12, %rdi
callq 0x25526
movq %r15, 0x38(%rbx)
movq 0x40(%rbx), %rdi
callq 0x45c0
movq %rbp, 0x40(%rbx)
movq %rbx, %rdi
callq 0x2276e
testl %eax, %eax
pushq $-0x1
popq %r13
js 0x2dfd6
movl (%rsp), %r13d
jmp 0x2dfd6
movq 0x8(%rsp), %rdi
callq 0x45c0
jmp 0x2dfd6
movq %rbp, %rdi
callq 0x45c0
movq %r15, %rdi
callq 0x25526
pushq $-0x1
popq %r13
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58e51(%rip), %rdi     # 0x86e40
leaq 0x5832d(%rip), %rsi     # 0x86323
leaq 0x58e5d(%rip), %rcx     # 0x86e5a
movl $0x1393, %edx           # imm = 0x1393
callq 0x42e0