// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x4cb9e
movq -0x18(%rbp), %rsi
leaq 0xb91f0(%rip), %rdi     # 0x105d78
callq 0x46b0
cmpl $0x0, %eax
jne 0x4cb9e
movl $0x0, -0x4(%rbp)
jmp 0x4d1ff
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movslq -0x24(%rbp), %rdi
movl $0x1, %esi
callq 0x42e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x78(%rax)
jne 0x4cbe3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d1ff
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x70(%rax)
cmpq $0x0, -0x18(%rbp)
jne 0x4ccc2
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x30(%rbp)
callq 0x3f710
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4cc24
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d1ff
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
je 0x4cc87
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x28(%rbp), %ecx
shrl $0x4, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x28(%rbp), %ecx
andl $0xf, %ecx
shll %ecx
shrl %cl, %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x4cc7a
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x28(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
callq 0x45a0
jmp 0x4cc7c
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x4cc36
movq -0x30(%rbp), %rdi
callq 0x3fd00
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rdi
callq 0x3ae50
cmpl $0x0, %eax
jge 0x4ccb6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d1ff
movl $0x0, -0x4(%rbp)
jmp 0x4d1ff
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
jne 0x4cd2b
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x4cd29
movl -0x20(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %edx, %ecx
movl $0x1, %esi
shll %cl, %esi
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0x80(%rbp)
movl -0x20(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x80(%rbp), %rax
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
orl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4ccd5
jmp 0x4cd2b
movl $0x0, -0x44(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
jne 0x4cd4f
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x4cd5a
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq -0x40(%rbp), %rdx
callq 0xcec0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x4cd84
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d1ff
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x4cea2
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl $0x2, %esi
callq 0x3e820
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x4cdce
cmpl $0x0, -0x44(%rbp)
jne 0x4cdc9
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x4ce94
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x4cddc
jmp 0x4cdfb
leaq 0xbb3d1(%rip), %rdi     # 0x1081b4
leaq 0xba879(%rip), %rsi     # 0x107663
movl $0x1393, %edx           # imm = 0x1393
leaq 0xbb3d8(%rip), %rcx     # 0x1081ce
callq 0x42d0
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
jne 0x4ce4f
movl -0x3c(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %edx, %ecx
movl $0x1, %esi
shll %cl, %esi
xorl $-0x1, %esi
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0x90(%rbp)
movl -0x3c(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x90(%rbp), %rax
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
andl %esi, %edx
movb %dl, (%rax,%rcx)
jmp 0x4ce92
movl -0x3c(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %edx, %ecx
movl $0x1, %esi
shll %cl, %esi
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0x98(%rbp)
movl -0x3c(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x98(%rbp), %rax
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
orl %esi, %edx
movb %dl, (%rax,%rcx)
jmp 0x4ce94
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4cd8b
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x4cecd
movq -0x50(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x45a0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4cea9
movq -0x50(%rbp), %rdi
callq 0x45a0
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x70(%rcx), %eax
jge 0x4cf61
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0xa8(%rbp)
movl -0x20(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x9c(%rbp)
movl -0x20(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl -0x9c(%rbp), %eax
movl %edx, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x4cf54
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x4cf56
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4cee8
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x4cf89
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x45a0
movq -0x10(%rbp), %rax
movq $0x0, 0x78(%rax)
jmp 0x4d1f9
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rdi
shlq $0x3, %rdi
callq 0x4670
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x4cfb1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d1ff
callq 0x3f710
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x4cfd6
movq -0x58(%rbp), %rdi
callq 0x45a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d1ff
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x70(%rcx), %eax
jge 0x4d101
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0xb8(%rbp)
movl -0x20(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xb8(%rbp), %rax
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0xac(%rbp)
movl -0x20(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl -0xac(%rbp), %eax
movl %edx, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x4d0f1
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x58(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x70(%rbp), %rdx
callq 0x4d210
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x70(%rbp)
jge 0x4d0ab
movq -0x58(%rbp), %rdi
callq 0x45a0
movq -0x60(%rbp), %rdi
callq 0x3fd00
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d1ff
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rdi
movslq -0x6c(%rbp), %rax
imulq $0x38, %rax, %rax
addq %rax, %rdi
leaq 0xd85ab(%rip), %rsi     # 0x125670
movl $0x38, %edx
callq 0x43b0
movl -0x3c(%rbp), %ecx
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x6c(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x30(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4d0f3
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4cfe4
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x4d158
movq -0x68(%rbp), %rdi
movq -0x58(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x3e520
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x4d14b
movq -0x68(%rbp), %rdi
movl -0x74(%rbp), %esi
callq 0x4d570
jmp 0x4d14d
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4d114
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpl (%rcx), %eax
je 0x4d1b2
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x6c(%rbp), %ecx
sarl $0x4, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl -0x6c(%rbp), %ecx
andl $0xf, %ecx
shll %ecx
shrl %cl, %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x4d1a5
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x6c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x45a0
jmp 0x4d1a7
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x4d15f
movq -0x68(%rbp), %rdi
callq 0x3fd00
movq -0x60(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x45a0
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rdi
callq 0x3ae50
cmpl $0x0, %eax
jge 0x4d1f7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d1ff
jmp 0x4d1f9
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)