// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/synced_bcf_reader.c
// Function: bcf_sr_regions_next
int bcf_sr_regions_next(bcf_sr_regions_t *reg)
{
    if ( reg->iseq<0 ) return -1;
    reg->start = reg->end = -1;
    reg->nals = 0;

    // using in-memory regions
    if ( reg->regs )
    {
        while ( reg->iseq < reg->nseqs )
        {
            if ( advance_creg(&reg->regs[reg->iseq])==0 ) break;    // a valid record was found
            reg->iseq++;
        }
        if ( reg->iseq >= reg->nseqs ) { reg->iseq = -1; return -1; } // no more regions left
        region1_t *creg = &reg->regs[reg->iseq].regs[reg->regs[reg->iseq].creg];
        reg->start = creg->start;
        reg->end   = creg->end;
        return 0;
    }

    // reading from tabix
    char *chr, *chr_end;
    int ichr = 0, ifrom = 1, ito = 2, is_bed = 0;
    hts_pos_t from, to;
    if ( reg->tbx )
    {
        ichr   = reg->tbx->conf.sc-1;
        ifrom  = reg->tbx->conf.bc-1;
        ito    = reg->tbx->conf.ec-1;
        if ( ito<0 ) ito = ifrom;
        is_bed = reg->tbx->conf.preset==TBX_UCSC ? 1 : 0;
    }

    int ret = 0;
    while ( !ret )
    {
        if ( reg->itr )
        {
            // tabix index present, reading a chromosome block
            ret = tbx_itr_next(reg->file, reg->tbx, reg->itr, &reg->line);
            if ( ret<0 ) { reg->iseq = -1; return -1; }
        }
        else
        {
            if ( reg->is_bin )
            {
                // Waited for seek which never came. Reopen in text mode and stream
                // through the regions, otherwise hts_getline would fail
                hts_close(reg->file);
                reg->file = hts_open(reg->fname, "r");
                if ( !reg->file )
                {
                    hts_log_error("Could not open file: %s", reg->fname);
                    reg->file = NULL;
                    bcf_sr_regions_destroy(reg);
                    return -1;
                }
                reg->is_bin = 0;
            }

            // tabix index absent, reading the whole file
            ret = reg->file ? hts_getline(reg->file, KS_SEP_LINE, &reg->line) : -1;
            if ( ret<0 ) { reg->iseq = -1; return -1; }
        }
        ret = _regions_parse_line(reg->line.s, ichr,ifrom,ito, &chr,&chr_end,&from,&to);
        if ( ret<0 )
        {
            hts_log_error("Could not parse the file %s, using the columns %d,%d,%d",
                reg->fname,ichr+1,ifrom+1,ito+1);
            return -1;
        }
    }
    if ( is_bed ) from++;

    *chr_end = 0;
    if ( khash_str2int_get(reg->seq_hash, chr, &reg->iseq)<0 )
    {
        hts_log_error("Broken tabix index? The sequence \"%s\" not in dictionary [%s]",
            chr, reg->line.s);
        exit(1);
    }
    *chr_end = '\t';

    reg->start = from - 1;
    reg->end   = to - 1;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x9c(%rax)
jge 0x3b7a5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3bbed
movq -0x10(%rbp), %rax
movq $-0x1, 0xa8(%rax)
movq -0x10(%rbp), %rax
movq $-0x1, 0xa0(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0x3b8e3
jmp 0x3b7e2
movq -0x10(%rbp), %rax
movl 0x9c(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x98(%rcx), %eax
jge 0x3b836
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x9c(%rax), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x3bc00
cmpl $0x0, %eax
jne 0x3b821
jmp 0x3b836
movq -0x10(%rbp), %rax
movl 0x9c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x9c(%rax)
jmp 0x3b7e2
movq -0x10(%rbp), %rax
movl 0x9c(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x98(%rcx), %eax
jl 0x3b866
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x9c(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3bbed
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x9c(%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x80(%rcx), %rcx
movq -0x10(%rbp), %rdx
movslq 0x9c(%rdx), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movslq 0x10(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa0(%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa8(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x3bbed
movl $0x0, -0x2c(%rbp)
movl $0x1, -0x30(%rbp)
movl $0x2, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x3b961
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0xc(%rax), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x3b945
movl -0x30(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x10000, %edx          # imm = 0x10000
cmovel %ecx, %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x3b97a
jmp 0x3bb4c
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x3b9d9
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0xd310
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rdx
addq $0x10, %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rcx
callq 0x13ab0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x3b9d4
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x9c(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3bbed
jmp 0x3bac8
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0x3ba6c
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0xc9d0
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
leaq 0xd5c1d(%rip), %rsi     # 0x111620
callq 0xa8b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x3ba61
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rcx
movl $0x1, %edi
leaq 0xd6826(%rip), %rsi     # 0x112258
leaq 0xd67b5(%rip), %rdx     # 0x1121ee
movb $0x0, %al
callq 0xa790
movq -0x10(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x10(%rbp), %rdi
callq 0x380b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3bbed
movq -0x10(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x3ba96
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rdx
addq $0x10, %rdx
movl $0x2, %esi
callq 0xd730
movl %eax, -0x50(%rbp)
jmp 0x3baa0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x50(%rbp)
jmp 0x3baa0
movl -0x50(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x3bac6
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x9c(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3bbed
jmp 0x3bac8
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
movl -0x34(%rbp), %ecx
leaq -0x20(%rbp), %r8
leaq -0x28(%rbp), %r9
leaq -0x40(%rbp), %r10
leaq -0x48(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x3b200
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x3bb47
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rcx
movl -0x2c(%rbp), %r8d
addl $0x1, %r8d
movl -0x30(%rbp), %r9d
addl $0x1, %r9d
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl $0x1, %edi
leaq 0xd672e(%rip), %rsi     # 0x112258
leaq 0xd673b(%rip), %rdx     # 0x11226c
movl %eax, (%rsp)
movb $0x0, %al
callq 0xa790
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3bbed
jmp 0x3b968
cmpl $0x0, -0x38(%rbp)
je 0x3bb5e
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0x9c, %rdx
callq 0x3a580
cmpl $0x0, %eax
jge 0x3bbb9
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %r8
movl $0x1, %edi
leaq 0xd66b7(%rip), %rsi     # 0x112258
leaq 0xd66fc(%rip), %rdx     # 0x1122a4
movb $0x0, %al
callq 0xa790
movl $0x1, %edi
callq 0x45d0
movq -0x28(%rbp), %rax
movb $0x9, (%rax)
movq -0x40(%rbp), %rcx
subq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa0(%rax)
movq -0x48(%rbp), %rcx
subq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa8(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)