// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movl %r8d, %r13d
movl %ecx, %r12d
movl %edx, 0x8(%rsp)
movl %esi, %ebp
movq %rdi, 0x18(%rsp)
movl $0x1, %edi
movl $0xd0, %esi
callq 0x42f0
movq %rax, %r15
movq %rax, %rbx
testl %ebp, %ebp
je 0x2917b
testq %r15, %r15
je 0x294c2
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0xa0(%rbx)
movl $0xffffffff, 0xb0(%rbx) # imm = 0xFFFFFFFF
movdqu %xmm0, 0xb8(%rbx)
leaq 0x89f6f(%rip), %rsi     # 0xb3017
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0x9c34
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x2949d
movq %rax, %r14
movq %rbp, %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x2dcba
movq %rax, (%rbx)
testq %rax, %rax
je 0x294d0
addq $0x98, %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x2dea3
movq %rax, 0x90(%rbx)
cmpq $0x0, 0x88(%rbx)
jne 0x29119
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
movq %rax, 0x88(%rbx)
cmpl $0x0, (%r15)
jle 0x29163
xorl %r13d, %r13d
movq %rsp, %r14
movq 0x88(%rbx), %r12
testq %r12, %r12
je 0x29158
movq 0x90(%rbx), %rax
movq (%rax,%r13,8), %rsi
movq %r12, %rdi
movq %r14, %rdx
callq 0x2c682
cmpl $0x0, (%rsp)
js 0x29158
movq 0x20(%r12), %rcx
movl %eax, %eax
movl %r13d, (%rcx,%rax,4)
incq %r13
movslq (%r15), %rax
cmpq %rax, %r13
jl 0x29125
movq %rbp, %rdi
callq 0x4950
movq %rax, 0x30(%rbx)
movl $0x1, 0x38(%rbx)
jmp 0x2964f
testq %r15, %r15
je 0x294c9
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0xa0(%rbx)
movl $0xffffffff, 0xb0(%rbx) # imm = 0xFFFFFFFF
movdqu %xmm0, 0xb8(%rbx)
movq %rsp, %rax
movq 0x18(%rsp), %rbp
movq %rbp, (%rax)
movabsq $0x400100000000001, %rdx # imm = 0x400100000000001
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
movb (%rbp), %cl
cmpb $0x7b, %cl
jne 0x291f9
movb $0x7b, %al
movl $0x1, %r12d
testb %al, %al
je 0x29467
movzbl %al, %eax
cmpl $0x7d, %eax
je 0x2927b
leaq (%r12,%rbp), %rax
movq %rax, (%rsp)
movb (%rbp,%r12), %al
incq %r12
jmp 0x291d3
movq %rbp, %rax
incq %rax
xorl %r14d, %r14d
cmpb $0x3a, %cl
ja 0x29210
movzbl %cl, %ecx
btq %rcx, %rdx
jb 0x29221
leaq (%rax,%r14), %rcx
movq %rcx, (%rsp)
movb (%rax,%r14), %cl
incq %r14
jmp 0x29202
cmpq $-0x2, %r14
je 0x292ce
leaq 0x2(%r14), %rax
movq 0x10(%rsp), %r15
cmpq %rax, %r15
jae 0x292e3
movq %rax, %rcx
shrq $0x3e, %rcx
shrq %rax
testq %rcx, %rcx
movl $0x0, %ecx
cmovneq %rcx, %rax
leaq 0x2(%rax,%r14), %r15
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x4870
movq %rax, %r12
movl $0x0, %r13d
testq %rax, %rax
jne 0x292e6
jmp 0x29331
leaq (%r12,%rbp), %rax
movq %rax, (%rsp)
testq %r12, %r12
je 0x292ce
movq 0x10(%rsp), %r14
cmpq %r12, %r14
jae 0x29308
movq %r12, %rax
shrq $0x3e, %rax
movq %r12, %r14
shrq %r14
testq %rax, %rax
movl $0x0, %eax
cmovneq %rax, %r14
addq %r12, %r14
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x4870
movq %rax, %r15
movl $0x0, %r13d
testq %rax, %rax
jne 0x2930b
jmp 0x29331
movq %r13, 0x8(%rsp)
callq 0x4050
movl $0x4b, (%rax)
xorl %r13d, %r13d
jmp 0x29331
movq %r13, %r12
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x43c0
movb $0x0, (%r12,%r14)
movq %r14, %r13
movq %r15, 0x10(%rsp)
movq %r12, 0x8(%rsp)
jmp 0x29331
movq %r13, %r15
incq %rbp
leaq -0x2(%r12), %r13
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x43c0
movb $0x0, -0x2(%r15,%r12)
movq %r14, 0x10(%rsp)
movq %r15, 0x8(%rsp)
movq (%rsp), %rbp
movzbl (%rbp), %eax
testl %eax, %eax
je 0x293af
cmpl $0x2c, %eax
je 0x293af
cmpl $0x3a, %eax
jne 0x296a7
incq %rbp
movq %rbp, %rdi
movq %rsp, %rsi
xorl %edx, %edx
callq 0xf673
movq (%rsp), %r13
cmpq %r13, %rbp
je 0x296a7
movq %rax, %r14
movzbl (%r13), %eax
testl %eax, %eax
je 0x29386
cmpl $0x2d, %eax
je 0x293fe
cmpl $0x2c, %eax
jne 0x296a7
movq %rbx, %rdi
movq 0x8(%rsp), %r13
movq %r13, %rsi
movq %r14, %rdx
movq %r14, %rcx
callq 0x29efc
movq (%rsp), %rbp
movabsq $0x400100000000001, %rdx # imm = 0x400100000000001
jmp 0x291c3
testq %r13, %r13
je 0x293db
movq %rbx, %rdi
movq 0x8(%rsp), %r13
movq %r13, %rsi
movq $-0x1, %rdx
movq $-0x1, %rcx
callq 0x29efc
movq (%rsp), %rbp
movb (%rbp), %al
jmp 0x293e0
movq 0x8(%rsp), %r13
movabsq $0x400100000000001, %rdx # imm = 0x400100000000001
testb %al, %al
je 0x29490
incq %rbp
movq %rbp, (%rsp)
jmp 0x291c3
incq %r13
movq %r13, (%rsp)
movq %r13, %rdi
movq %rsp, %rsi
xorl %edx, %edx
callq 0xf673
movq (%rsp), %rcx
movzbl (%rcx), %edx
cmpl $0x2c, %edx
je 0x29426
testl %edx, %edx
jne 0x296a7
cmpq %rcx, %r13
movabsq $0xffffffffffe, %rcx    # imm = 0xFFFFFFFFFFE
cmoveq %rcx, %rax
movq %rbx, %rdi
movq 0x8(%rsp), %r13
movq %r13, %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0x29efc
movq (%rsp), %rbp
cmpb $0x0, (%rbp)
movabsq $0x400100000000001, %rdx # imm = 0x400100000000001
jne 0x291c3
jmp 0x29490
leaq 0x89e48(%rip), %rdx     # 0xb32b6
leaq 0x89e2c(%rip), %rsi     # 0xb32a1
movl $0x1, %edi
movq 0x18(%rsp), %rcx
xorl %eax, %eax
callq 0x9b31
movq %rbx, %rdi
callq 0x28f39
xorl %ebx, %ebx
movq %r13, %rdi
callq 0x45d0
jmp 0x29647
leaq 0x89b76(%rip), %rsi     # 0xb301a
leaq 0x89b83(%rip), %rdx     # 0xb302e
movl $0x1, %edi
movq %rbp, %rcx
xorl %eax, %eax
callq 0x9b31
movq %rbx, %rdi
callq 0x45d0
xorl %ebx, %ebx
jmp 0x2964f
xorl %ebx, %ebx
jmp 0x29647
movq %rbp, %rdi
callq 0x41c0
movq %rbp, %rcx
movslq %eax, %rbp
leaq (%rcx,%rbp), %rsi
addq $-0x4, %rsi
leaq 0x89b59(%rip), %rdi     # 0xb3046
callq 0x4520
testl %eax, %eax
je 0x29519
addq 0x18(%rsp), %rbp
addq $-0x7, %rbp
leaq 0x89b45(%rip), %rdi     # 0xb304b
movq %rbp, %rsi
callq 0x4520
testl %eax, %eax
setne %al
movl %eax, 0x10(%rsp)
jmp 0x29521
movl $0x0, 0x10(%rsp)
movl 0x4c(%r14), %ebp
addq $0x10, %r15
movq %r14, %rdi
movl $0x2, %esi
movq %r15, %rdx
callq 0xb47e
testl %eax, %eax
jle 0x29629
cmpl $0x8, %ebp
movl $0x1, %eax
cmovel %eax, %r13d
movl $0x1, %r14d
movq 0x20(%rbx), %rdi
movl %r13d, %ebp
negl %ebp
cmovsl %r13d, %ebp
movl 0x8(%rsp), %esi
movl %r12d, %edx
movl %ebp, %ecx
movq %rsp, %r8
leaq 0x30(%rsp), %r9
leaq 0x28(%rsp), %rax
pushq %rax
leaq 0x28(%rsp), %rax
pushq %rax
callq 0x2bde0
addq $0x10, %rsp
testl %eax, %eax
js 0x29593
testl %r13d, %r13d
cmovnsl %r13d, %ebp
jmp 0x295d2
testl %r13d, %r13d
jns 0x29661
movq 0x20(%rbx), %rdi
movl 0x8(%rsp), %esi
movl %r12d, %edx
movl %r12d, %ecx
movq %rsp, %r8
leaq 0x30(%rsp), %r9
leaq 0x28(%rsp), %rax
pushq %rax
leaq 0x28(%rsp), %rax
pushq %rax
callq 0x2bde0
addq $0x10, %rsp
movl %r12d, %ebp
testl %eax, %eax
js 0x29661
testl %eax, %eax
je 0x2960a
movq 0x20(%rsp), %rdx
cmpb $0x0, 0x10(%rsp)
jne 0x295ea
incq %rdx
movq %rdx, 0x20(%rsp)
movq 0x30(%rsp), %r13
movb $0x0, (%r13)
movq (%rsp), %rsi
movq 0x28(%rsp), %rcx
movq %rbx, %rdi
callq 0x29efc
movb $0x9, (%r13)
movq 0x28(%rbx), %rdi
movl $0x2, %esi
movq %r15, %rdx
callq 0xb47e
incq %r14
movl %ebp, %r13d
testl %eax, %eax
jg 0x29553
movq 0x28(%rbx), %rdi
callq 0xae96
movq $0x0, 0x28(%rbx)
cmpl $0x0, 0x98(%rbx)
je 0x294ba
movq %rbx, %rdi
callq 0x2a19e
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%rsp), %r9d
incl %r9d
incl %r12d
incl %r13d
leaq 0x899a4(%rip), %rsi     # 0xb301a
leaq 0x899d6(%rip), %rdx     # 0xb3053
movl $0x1, %edi
movq %r14, %rcx
movq 0x18(%rsp), %r8
xorl %eax, %eax
pushq %r13
pushq %r12
callq 0x9b31
addq $0x10, %rsp
movq 0x28(%rbx), %rdi
callq 0xae96
jmp 0x294ba
leaq 0x89c40(%rip), %rdx     # 0xb32ee
movq 0x8(%rsp), %r13
jmp 0x2946e