// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/synced_bcf_reader.c
// Function: bcf_sr_regions_init
bcf_sr_regions_t *bcf_sr_regions_init(const char *regions, int is_file, int ichr, int ifrom, int ito)
{
    bcf_sr_regions_t *reg;
    if ( !is_file )
    {
        reg = _regions_init_string(regions);
        _regions_sort_and_merge(reg);
        return reg;
    }

    reg = bcf_sr_regions_alloc();
    if ( !reg ) return NULL;

    reg->file = hts_open(regions, "rb");
    if ( !reg->file )
    {
        hts_log_error("Could not open file: %s", regions);
        free(reg);
        return NULL;
    }

    reg->tbx = tbx_index_load3(regions, NULL, HTS_IDX_SAVE_REMOTE|HTS_IDX_SILENT_FAIL);
    if ( !reg->tbx )
    {
        size_t iline = 0;
        int len = strlen(regions);
        int is_bed  = strcasecmp(".bed",regions+len-4) ? 0 : 1;
        if ( !is_bed && !strcasecmp(".bed.gz",regions+len-7) ) is_bed = 1;

        if ( reg->file->format.format==vcf ) ito = 1;

        // read the whole file, tabix index is not present
        while ( hts_getline(reg->file, KS_SEP_LINE, &reg->line) > 0 )
        {
            iline++;
            char *chr, *chr_end;
            hts_pos_t from, to;
            int ret;
            ret = _regions_parse_line(reg->line.s, ichr,ifrom,abs(ito), &chr,&chr_end,&from,&to);
            if ( ret < 0 )
            {
                if ( ito<0 )
                    ret = _regions_parse_line(reg->line.s, ichr,ifrom,ifrom, &chr,&chr_end,&from,&to);
                if ( ret<0 )
                {
                    hts_log_error("Could not parse %zu-th line of file %s, using the columns %d,%d[,%d]",
                        iline, regions,ichr+1,ifrom+1,ito+1);
                    hts_close(reg->file); reg->file = NULL; free(reg);
                    return NULL;
                }
                ito = ifrom;
            }
            else if ( ito<0 )
                ito = abs(ito);
            if ( !ret ) continue;
            if ( is_bed ) from++;
            *chr_end = 0;
            _regions_add(reg, chr, from, to);
            *chr_end = '\t';
        }
        hts_close(reg->file); reg->file = NULL;
        if ( !reg->nseqs ) { free(reg); return NULL; }
        _regions_sort_and_merge(reg);
        return reg;
    }

    reg->seq_names = (char**) tbx_seqnames(reg->tbx, &reg->nseqs);
    if ( !reg->seq_hash )
        reg->seq_hash = khash_str2int_init();
    int i;
    for (i=0; i<reg->nseqs; i++)
    {
        khash_str2int_set(reg->seq_hash,reg->seq_names[i],i);
    }
    reg->fname  = strdup(regions);
    reg->is_bin = 1;
    return reg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %r13d
movl %ecx, %r15d
movq %rdx, 0x10(%rsp)
movl %esi, %ebp
movq %rdi, %r14
movl $0x1, %edi
movl $0xd0, %esi
callq 0x42f0
movq %rax, %rbx
testl %ebp, %ebp
je 0x29fc4
testq %rbx, %rbx
je 0x29ff0
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0xa0(%rbx)
movl $0xffffffff, 0xb0(%rbx) # imm = 0xFFFFFFFF
movdqu %xmm0, 0xb8(%rbx)
jmp 0x29ff2
testq %rbx, %rbx
je 0x2a0ff
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0xa0(%rbx)
movl $0xffffffff, 0xb0(%rbx) # imm = 0xFFFFFFFF
movdqu %xmm0, 0xb8(%rbx)
jmp 0x2a101
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x2a0f8
leaq 0x8b025(%rip), %rsi     # 0xb5027
movq %r14, %rdi
callq 0x9f37
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x2a0d3
movq %r14, %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x2e97a
movq %rax, (%rbx)
testq %rax, %rax
je 0x2a44c
movq %r14, %rbp
leaq 0x98(%rbx), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x2eb95
movq %rax, 0x90(%rbx)
cmpq $0x0, 0x88(%rbx)
jne 0x2a06e
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
movq %rax, 0x88(%rbx)
cmpl $0x0, (%r14)
jle 0x2a0bb
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
movq 0x88(%rbx), %r12
testq %r12, %r12
je 0x2a0b0
movq 0x90(%rbx), %rax
movq (%rax,%r13,8), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x2d3e5
cmpl $0x0, 0x8(%rsp)
js 0x2a0b0
movq 0x20(%r12), %rcx
movl %eax, %eax
movl %r13d, (%rcx,%rax,4)
incq %r13
movslq (%r14), %rax
cmpq %rax, %r13
jl 0x2a07c
movq %rbp, %rdi
callq 0x4950
movq %rax, 0x30(%rbx)
movl $0x1, 0x38(%rbx)
jmp 0x2a655
leaq 0x8af50(%rip), %rsi     # 0xb502a
leaq 0x8af5d(%rip), %rdx     # 0xb503e
movl $0x1, %edi
movq %r14, %rcx
xorl %eax, %eax
callq 0x9e34
movq %rbx, %rdi
callq 0x45d0
xorl %ebx, %ebx
jmp 0x2a655
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x2a445
leaq 0x8(%rsp), %rax
movq %r14, (%rax)
movabsq $0x400100000000001, %rcx # imm = 0x400100000000001
movq $0x0, 0x28(%rsp)
movq $0x0, 0x10(%rsp)
movq %r14, %rbp
movq %r14, 0x18(%rsp)
movq 0x8(%rsp), %r15
cmpb $0x7b, (%r15)
jne 0x2a16b
xorl %r13d, %r13d
movzbl (%r15,%r13), %ecx
testl %ecx, %ecx
je 0x2a40c
leaq (%r15,%r13), %rax
incq %rax
cmpl $0x7d, %ecx
je 0x2a1fb
movq %rax, 0x8(%rsp)
incq %r13
jmp 0x2a144
xorl %r13d, %r13d
movzbl (%r15,%r13), %eax
cmpq $0x3a, %rax
ja 0x2a17f
btq %rax, %rcx
jb 0x2a190
leaq (%r15,%r13), %rax
incq %rax
movq %rax, 0x8(%rsp)
incq %r13
jmp 0x2a16e
subq %rbp, %r15
leaq (%r15,%r13), %rdx
movq %rdx, %rax
addq $0x2, %rax
je 0x2a258
movq 0x28(%rsp), %rcx
cmpq %rax, %rcx
jae 0x2a268
movq %rax, %rcx
shrq $0x3e, %rcx
shrq %rax
testq %rcx, %rcx
movl $0x0, %ecx
cmovneq %rcx, %rax
addq %r15, %rax
leaq (%rax,%r13), %rsi
addq $0x2, %rsi
movq 0x10(%rsp), %rdi
movq %rsi, 0x20(%rsp)
movq %rdx, %r14
callq 0x4870
movq %r14, %rdx
movq %rax, %r12
movl $0x0, %r14d
testq %rax, %rax
jne 0x2a272
jmp 0x2a2c5
movq %rax, 0x8(%rsp)
cmpq %rbp, %rax
je 0x2a258
subq %rbp, %r15
leaq (%r15,%r13), %rax
incq %rax
movq 0x28(%rsp), %rcx
cmpq %rax, %rcx
jae 0x2a28b
movq %rax, %rcx
shrq $0x3e, %rcx
shrq %rax
testq %rcx, %rcx
movl $0x0, %ecx
cmovneq %rcx, %rax
addq %r15, %rax
leaq (%rax,%r13), %rsi
incq %rsi
movq 0x10(%rsp), %rdi
movq %rsi, 0x20(%rsp)
callq 0x4870
movq %rax, %r12
movl $0x0, %r14d
testq %rax, %rax
jne 0x2a295
jmp 0x2a2c5
callq 0x4050
movl $0x4b, (%rax)
xorl %r14d, %r14d
jmp 0x2a2c5
movq %rcx, 0x20(%rsp)
movq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
movq %rdx, %r14
callq 0x43c0
addq %r12, %r15
movb $0x0, (%r13,%r15)
jmp 0x2a2b6
movq %rcx, 0x20(%rsp)
movq 0x10(%rsp), %r12
incq %rbp
leaq (%r15,%r13), %r14
decq %r14
addq %r12, %r15
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x43c0
movb $0x0, -0x1(%r13,%r15)
movq 0x20(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %r12, 0x10(%rsp)
movq 0x8(%rsp), %r15
movzbl (%r15), %eax
testl %eax, %eax
je 0x2a351
cmpl $0x2c, %eax
je 0x2a351
cmpl $0x3a, %eax
leaq 0x8b01d(%rip), %r12     # 0xb52fe
jne 0x2a667
incq %r15
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0xf942
movq 0x8(%rsp), %r13
cmpq %r13, %r15
je 0x2a667
movq %rax, %r14
movzbl (%r13), %eax
testl %eax, %eax
je 0x2a325
cmpl $0x2d, %eax
je 0x2a39c
cmpl $0x2c, %eax
jne 0x2a667
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
movq %r14, %rcx
callq 0x2ae76
movq 0x8(%rsp), %rbp
movq 0x18(%rsp), %r14
movabsq $0x400100000000001, %rcx # imm = 0x400100000000001
jmp 0x2a136
testq %r14, %r14
je 0x2a371
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
movq $-0x1, %rdx
movq $-0x1, %rcx
callq 0x2ae76
movq 0x8(%rsp), %rbp
cmpb $0x0, (%rbp)
movq 0x18(%rsp), %r14
je 0x2a436
incq %rbp
movq %rbp, 0x8(%rsp)
movabsq $0x400100000000001, %rcx # imm = 0x400100000000001
jmp 0x2a136
incq %r13
movq %r13, 0x8(%rsp)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0xf942
movq 0x8(%rsp), %rcx
movzbl (%rcx), %edx
cmpl $0x2c, %edx
je 0x2a3c8
testl %edx, %edx
jne 0x2a667
cmpq %rcx, %r13
movabsq $0xffffffffffe, %rcx    # imm = 0xFFFFFFFFFFE
cmoveq %rcx, %rax
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0x2ae76
movq 0x8(%rsp), %rbp
cmpb $0x0, (%rbp)
movq 0x18(%rsp), %r14
movabsq $0x400100000000001, %rcx # imm = 0x400100000000001
jne 0x2a136
jmp 0x2a436
leaq 0x8aeb3(%rip), %r12     # 0xb52c6
leaq 0x8ae97(%rip), %rsi     # 0xb52b1
movl $0x1, %edi
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x9e34
movq %rbx, %rdi
callq 0x29e6c
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
callq 0x45d0
jmp 0x2a64d
xorl %ebx, %ebx
jmp 0x2a64d
movq %r14, %rdi
callq 0x41c0
movq %r14, %r12
movslq %eax, %r14
leaq (%r12,%r14), %rsi
addq $-0x4, %rsi
leaq 0x8abed(%rip), %rdi     # 0xb5056
callq 0x4520
testl %eax, %eax
movq %r12, 0x18(%rsp)
je 0x2a498
addq %r12, %r14
addq $-0x7, %r14
leaq 0x8abd6(%rip), %rdi     # 0xb505b
movq %r14, %rsi
callq 0x4520
testl %eax, %eax
setne %al
movl %eax, 0x20(%rsp)
jmp 0x2a4a0
movl $0x0, 0x20(%rsp)
movq 0x28(%rbx), %rdi
movl 0x4c(%rdi), %ebp
leaq 0x10(%rbx), %rdx
movl $0x2, %esi
movq %rdx, 0x28(%rsp)
callq 0xb781
testl %eax, %eax
jle 0x2a62f
cmpl $0x8, %ebp
movl $0x1, %eax
cmovel %eax, %r13d
movq 0x10(%rsp), %rax
incl %eax
movl %eax, 0x3c(%rsp)
leal 0x1(%r15), %eax
movq %rax, 0x50(%rsp)
movl $0x1, %r14d
movq 0x20(%rbx), %rdi
movl %r13d, %ebp
negl %ebp
cmovsl %r13d, %ebp
movq 0x10(%rsp), %rsi
movl %r15d, %edx
movl %ebp, %ecx
leaq 0x8(%rsp), %r8
leaq 0x48(%rsp), %r9
leaq 0x40(%rsp), %rax
pushq %rax
leaq 0x38(%rsp), %rax
pushq %rax
callq 0x2cb1d
addq $0x10, %rsp
testl %eax, %eax
js 0x2a52b
testl %r13d, %r13d
cmovnsl %r13d, %ebp
jmp 0x2a56a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %r13d, %r13d
jns 0x2a563
movq 0x20(%rbx), %rdi
movq 0x10(%rsp), %rsi
movl %r15d, %edx
movl %r15d, %ecx
leaq 0x8(%rsp), %r8
leaq 0x48(%rsp), %r9
leaq 0x40(%rsp), %rax
pushq %rax
leaq 0x38(%rsp), %rax
pushq %rax
callq 0x2cb1d
addq $0x10, %rsp
movl %r15d, %ebp
testl %eax, %eax
js 0x2a5ad
testl %eax, %eax
je 0x2a5a5
cmpb $0x0, 0x20(%rsp)
jne 0x2a57a
incq 0x30(%rsp)
movq 0x48(%rsp), %r12
movb $0x0, (%r12)
movq 0x8(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq %rbx, %rdi
callq 0x2ae76
movb $0x9, (%r12)
xorl %r12d, %r12d
jmp 0x2a604
movl $0x2, %r12d
jmp 0x2a604
leal 0x1(%r13), %r10d
movl $0x1, %r12d
movl $0x1, %edi
leaq 0x8aa67(%rip), %rsi     # 0xb502a
leaq 0x8aa99(%rip), %rdx     # 0xb5063
movq %r14, %rcx
movq 0x18(%rsp), %r8
movl 0x3c(%rsp), %r9d
xorl %eax, %eax
pushq %r10
pushq 0x58(%rsp)
callq 0x9e34
addq $0x10, %rsp
movq 0x28(%rbx), %rdi
callq 0xb1a1
movq $0x0, 0x28(%rbx)
movq %rbx, %rdi
callq 0x45d0
movl %r13d, %ebp
testb $0x1, %r12b
jne 0x2a0f8
movq 0x28(%rbx), %rdi
movl $0x2, %esi
movq 0x28(%rsp), %rdx
callq 0xb781
incq %r14
movl %ebp, %r13d
testl %eax, %eax
jg 0x2a4e8
movq 0x28(%rbx), %rdi
callq 0xb1a1
movq $0x0, 0x28(%rbx)
cmpl $0x0, 0x98(%rbx)
je 0x2a0f0
movq %rbx, %rdi
callq 0x2b13a
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %r14
jmp 0x2a413