// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/synced_bcf_reader.c
// Function: bcf_sr_set_samples
int bcf_sr_set_samples(bcf_srs_t *files, const char *fname, int is_file)
{
    int i, j, nsmpl, free_smpl = 0;
    char **smpl = NULL;

    void *exclude = (fname[0]=='^') ? khash_str2int_init() : NULL;
    if ( exclude || strcmp("-",fname) ) // "-" stands for all samples
    {
        smpl = hts_readlist(fname, is_file, &nsmpl);
        if ( !smpl )
        {
            hts_log_error("Could not read the file: \"%s\"", fname);
            return 0;
        }
        if ( exclude )
        {
            for (i=0; i<nsmpl; i++)
                khash_str2int_inc(exclude, smpl[i]);
        }
        free_smpl = 1;
    }
    if ( !smpl )
    {
        smpl  = files->readers[0].header->samples;   // intersection of all samples
        nsmpl = bcf_hdr_nsamples(files->readers[0].header);
    }

    files->samples = NULL;
    files->n_smpl  = 0;
    for (i=0; i<nsmpl; i++)
    {
        if ( exclude && khash_str2int_has_key(exclude,smpl[i])  ) continue;

        int n_isec = 0;
        for (j=0; j<files->nreaders; j++)
        {
            if ( bcf_hdr_id2int(files->readers[j].header, BCF_DT_SAMPLE, smpl[i])<0 ) break;
            n_isec++;
        }
        if ( n_isec!=files->nreaders )
        {
            hts_log_warning("The sample \"%s\" was not found in %s, skipping",
                smpl[i], files->readers[n_isec].fname);
            continue;
        }

        files->samples = (char**) realloc(files->samples, (files->n_smpl+1)*sizeof(const char*));
        files->samples[files->n_smpl++] = strdup(smpl[i]);
    }

    if ( exclude ) khash_str2int_destroy(exclude);
    if ( free_smpl )
    {
        for (i=0; i<nsmpl; i++) free(smpl[i]);
        free(smpl);
    }

    if ( !files->n_smpl )
    {
        if ( files->nreaders>1 )
            hts_log_warning("No samples in common");
        return 0;
    }
    for (i=0; i<files->nreaders; i++)
    {
        bcf_sr_t *reader = &files->readers[i];
        reader->samples  = (int*) malloc(sizeof(int)*files->n_smpl);
        reader->n_smpl   = files->n_smpl;
        for (j=0; j<files->n_smpl; j++)
            reader->samples[j] = bcf_hdr_id2int(reader->header, BCF_DT_SAMPLE, files->samples[j]);
    }
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, 0x10(%rsp)
movzbl (%rsi), %eax
cmpl $0x5e, %eax
jne 0x2b9ab
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
testq %rax, %rax
je 0x2b9bc
movq %rax, %r13
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
movl %ebp, %esi
callq 0xb53f
testq %rax, %rax
je 0x2b9f9
movq %rax, %r15
cmpl $0x0, 0xc(%rsp)
movq %r13, 0x30(%rsp)
jle 0x2bdbc
xorl %ebx, %ebx
leaq 0x4c(%rsp), %r12
movq 0x10(%rsp), %r14
movq (%r15,%rbx,8), %rsi
movq %r13, %rdi
movq %r12, %rdx
callq 0x2c682
cmpl $0x0, 0x4c(%rsp)
jle 0x2b982
movl 0x4(%r13), %ecx
decl %ecx
movq 0x20(%r13), %rdx
movl %eax, %eax
movl %ecx, (%rdx,%rax,4)
incq %rbx
movslq 0xc(%rsp), %rax
cmpq %rax, %rbx
jl 0x2b95d
movq %r15, 0x18(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
jmp 0x2ba52
subl $0x2d, %eax
jne 0x2b9b6
movzbl 0x1(%r12), %eax
negl %eax
testl %eax, %eax
je 0x2ba1e
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
movl %ebp, %esi
callq 0xb53f
testq %rax, %rax
je 0x2b9f9
movq %rax, 0x18(%rsp)
movb $0x1, %al
movq %rax, 0x40(%rsp)
movl 0xc(%rsp), %eax
movq $0x0, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x10(%rsp), %r14
jmp 0x2ba52
leaq 0x875a3(%rip), %rsi     # 0xb2fa3
leaq 0x875af(%rip), %rdx     # 0xb2fb6
xorl %r15d, %r15d
movl $0x1, %edi
movq %r12, %rcx
xorl %eax, %eax
callq 0x9b31
jmp 0x2bdaa
movq 0x10(%rsp), %r14
movq 0x28(%r14), %rax
movq 0x18(%rax), %rax
movq 0x40(%rax), %rcx
movq %rcx, 0x18(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0xc(%rsp)
movb $0x1, %cl
movq %rcx, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
movb $0x1, %cl
movq %rcx, 0x40(%rsp)
leaq 0x40(%r14), %rcx
movq %rcx, 0x20(%rsp)
movq $0x0, 0x40(%r14)
leaq 0x78(%r14), %rcx
movq %rcx, 0x28(%rsp)
movl $0x0, 0x78(%r14)
testl %eax, %eax
jle 0x2bc43
xorl %r14d, %r14d
cmpb $0x0, 0x40(%rsp)
jne 0x2bb67
movq 0x30(%rsp), %rdx
movl (%rdx), %edi
testl %edi, %edi
je 0x2bac3
movq 0x18(%rsp), %rax
movq (%rax,%r14,8), %rsi
movb (%rsi), %cl
testb %cl, %cl
je 0x2baca
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 0x2baad
jmp 0x2bacf
xorl %ebx, %ebx
jmp 0x2bb5f
movl $0x811c9dc5, %ebp       # imm = 0x811C9DC5
movq %rdi, 0x50(%rsp)
decl %edi
andl %edi, %ebp
movq 0x10(%rdx), %rdx
movl $0x1, %r13d
movl %ebp, %ebx
movq %r14, 0x60(%rsp)
movl %edi, 0x48(%rsp)
movq %rsi, 0x58(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rdx,%rax,4), %r15d
leal (%rbx,%rbx), %r12d
andl $0x1e, %r12d
movl %r15d, %eax
movl %r12d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x2bb4d
testb $0x1, %al
jne 0x2bb3f
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %rdx, %r14
callq 0x46f0
movq %r14, %rdx
movl 0x48(%rsp), %edi
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %r14
testl %eax, %eax
je 0x2bb4d
addl %r13d, %ebx
andl %edi, %ebx
incl %r13d
cmpl %ebp, %ebx
jne 0x2baf2
jmp 0x2bb67
movl %r12d, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
movq 0x50(%rsp), %rdi
cmovnel %edi, %ebx
cmpl %edi, %ebx
jne 0x2bc32
movq 0x10(%rsp), %r12
movl 0x30(%r12), %ecx
testl %ecx, %ecx
jle 0x2bbb9
movl $0x18, %r15d
xorl %ebx, %ebx
movq 0x18(%rsp), %r13
movq 0x28(%r12), %rax
movq (%rax,%r15), %rdi
movq (%r13,%r14,8), %rdx
movl $0x2, %esi
callq 0x32f65
movl 0x30(%r12), %ecx
testl %eax, %eax
js 0x2bbb2
movslq %ecx, %rax
incq %rbx
addq $0x60, %r15
cmpq %rax, %rbx
jl 0x2bb82
movq 0x20(%rsp), %r15
jmp 0x2bbc5
xorl %ebx, %ebx
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %r13
cmpl %ecx, %ebx
jne 0x2bbff
movq (%r15), %rdi
movq 0x28(%rsp), %rbx
movslq (%rbx), %rax
leaq 0x8(,%rax,8), %rsi
callq 0x4870
movq %rax, %r12
movq %rax, (%r15)
movq (%r13,%r14,8), %rdi
callq 0x4950
movslq (%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%rbx)
movq %rax, (%r12,%rcx,8)
jmp 0x2bc32
movq (%r13,%r14,8), %rcx
movq 0x28(%r12), %rax
movl %ebx, %edx
leaq (%rdx,%rdx,2), %rdx
shlq $0x5, %rdx
movq 0x28(%rax,%rdx), %r8
movl $0x3, %edi
leaq 0x8737f(%rip), %rsi     # 0xb2fa3
leaq 0x873a9(%rip), %rdx     # 0xb2fd4
xorl %eax, %eax
callq 0x9b31
incq %r14
movslq 0xc(%rsp), %rax
cmpq %rax, %r14
jl 0x2ba7f
cmpb $0x0, 0x40(%rsp)
je 0x2bc67
cmpb $0x0, 0x38(%rsp)
movq 0x10(%rsp), %rbp
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
movq 0x28(%rsp), %r13
je 0x2bcad
jmp 0x2bcd4
movq 0x10(%rsp), %rbp
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
movq 0x28(%rsp), %r13
movq 0x38(%rsp), %r12
movq 0x30(%rsp), %rbx
movq 0x18(%rbx), %rdi
callq 0x45d0
movq 0x10(%rbx), %rdi
callq 0x45d0
movq 0x20(%rbx), %rdi
callq 0x45d0
movq %rbx, %rdi
callq 0x45d0
testb %r12b, %r12b
jne 0x2bcd4
cmpl $0x0, 0xc(%rsp)
jle 0x2bccc
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rdi
callq 0x45d0
incq %rbx
movslq 0xc(%rsp), %rax
cmpq %rax, %rbx
jl 0x2bcb6
movq %r15, %rdi
callq 0x45d0
movl 0x30(%rbp), %r12d
movl 0x78(%rbp), %ebx
testl %ebx, %ebx
je 0x2bd84
movl $0x1, %r15d
testl %r12d, %r12d
jle 0x2bdaa
movq %r13, 0x28(%rsp)
movq %r14, 0x20(%rsp)
xorl %r14d, %r14d
movq 0x28(%rbp), %r15
leaq (%r14,%r14,2), %r13
shlq $0x5, %r13
movslq %ebx, %rbp
leaq (,%rbp,4), %rdi
callq 0x46b0
movq %rax, 0x50(%r15,%r13)
movl %ebp, 0x58(%r15,%r13)
testl %ebp, %ebp
movq 0x10(%rsp), %rbp
jle 0x2bd71
addq %r13, %r15
xorl %r12d, %r12d
movq 0x20(%rsp), %r13
movq 0x28(%rsp), %rbp
movq 0x18(%r15), %rdi
movq (%r13), %rax
movq (%rax,%r12,8), %rdx
movl $0x2, %esi
callq 0x32f65
movq 0x50(%r15), %rcx
movl %eax, (%rcx,%r12,4)
incq %r12
movslq (%rbp), %rbx
cmpq %rbx, %r12
jl 0x2bd3e
movq 0x10(%rsp), %rbp
movl 0x30(%rbp), %r12d
incq %r14
movslq %r12d, %rax
cmpq %rax, %r14
jl 0x2bcff
movl $0x1, %r15d
jmp 0x2bdaa
xorl %r15d, %r15d
cmpl $0x2, %r12d
jl 0x2bdaa
leaq 0x8720f(%rip), %rsi     # 0xb2fa3
leaq 0x87267(%rip), %rdx     # 0xb3002
xorl %r15d, %r15d
movl $0x3, %edi
xorl %eax, %eax
callq 0x9b31
movl %r15d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rbp
leaq 0x40(%rbp), %r14
movq $0x0, 0x40(%rbp)
leaq 0x78(%rbp), %r13
movl $0x0, 0x78(%rbp)
xorl %r12d, %r12d
jmp 0x2bc80