// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
jne 0x3a9c9
callq 0x3ad60
movq %rax, -0x58(%rbp)
jmp 0x3a9d1
xorl %eax, %eax
movq %rax, -0x58(%rbp)
jmp 0x3a9d1
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x3a9f9
movq -0x18(%rbp), %rsi
leaq 0xd653d(%rip), %rdi     # 0x110f28
callq 0x46b0
cmpl $0x0, %eax
je 0x3aa7d
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq -0x28(%rbp), %rdx
callq 0xd8c0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x3aa3e
movq -0x18(%rbp), %rcx
movl $0x1, %edi
leaq 0xd773f(%rip), %rsi     # 0x112163
leaq 0xd774b(%rip), %rdx     # 0x112176
movb $0x0, %al
callq 0xa790
movl $0x0, -0x4(%rbp)
jmp 0x3ad54
cmpq $0x0, -0x40(%rbp)
je 0x3aa76
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x3aa74
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x3ad70
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3aa4c
jmp 0x3aa76
movl $0x1, -0x2c(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x3aaaa
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
movq 0x40(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x78(%rax)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x3ac10
cmpq $0x0, -0x40(%rbp)
je 0x3aafa
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x3ae10
cmpl $0x0, %eax
je 0x3aafa
jmp 0x3ac02
movl $0x0, -0x44(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x3ab5c
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl $0x2, %esi
callq 0x46d10
cmpl $0x0, %eax
jge 0x3ab48
jmp 0x3ab5c
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3ab08
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x30(%rcx), %eax
je 0x3aba7
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x44(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movq 0x28(%rax), %r8
movl $0x3, %edi
leaq 0xd75cc(%rip), %rsi     # 0x112163
leaq 0xd75f6(%rip), %rdx     # 0x112194
movb $0x0, %al
callq 0xa790
jmp 0x3ac02
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x78(%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x4840
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x4930
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rsi
movl 0x78(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0x78(%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3aac8
cmpq $0x0, -0x40(%rbp)
je 0x3ac20
movq -0x40(%rbp), %rdi
callq 0x3ae60
cmpl $0x0, -0x2c(%rbp)
je 0x3ac5a
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x3ac51
movq -0x38(%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 0x3ac2d
movq -0x38(%rbp), %rdi
callq 0x45a0
movq -0x10(%rbp), %rax
cmpl $0x0, 0x78(%rax)
jne 0x3ac94
movq -0x10(%rbp), %rax
cmpl $0x1, 0x30(%rax)
jle 0x3ac88
movl $0x3, %edi
leaq 0xd74e9(%rip), %rsi     # 0x112163
leaq 0xd7541(%rip), %rdx     # 0x1121c2
movb $0x0, %al
callq 0xa790
movl $0x0, -0x4(%rbp)
jmp 0x3ad54
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x3ad4d
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movslq 0x78(%rax), %rdi
shlq $0x2, %rdi
callq 0x4670
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movl 0x78(%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x58(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x78(%rcx), %eax
jge 0x3ad3d
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl $0x2, %esi
callq 0x46d10
movl %eax, %edx
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3acf3
jmp 0x3ad3f
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3ac9b
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)