// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/synced_bcf_reader.c
// Function: next_line
static int next_line(bcf_srs_t *files)
{
    const char *chr = NULL;
    hts_pos_t min_pos = HTS_POS_MAX;

    // Loop until next suitable line is found or all readers have finished
    while ( 1 )
    {
        // Get all readers ready for the next region.
        if ( files->regions && _readers_next_region(files)<0 ) break;

        // Fill buffers and find the minimum chromosome
        int i, min_rid = INT32_MAX;
        for (i=0; i<files->nreaders; i++)
        {
            _reader_fill_buffer(files, &files->readers[i]);
            if ( files->require_index==ALLOW_NO_IDX_ )
            {
                if ( !files->readers[i].nbuffer ) continue;
                if ( min_rid > files->readers[i].buffer[1]->rid ) min_rid = files->readers[i].buffer[1]->rid;
            }
        }

        for (i=0; i<files->nreaders; i++)
        {
            if ( !files->readers[i].nbuffer ) continue;
            if ( files->require_index==ALLOW_NO_IDX_ && min_rid != files->readers[i].buffer[1]->rid ) continue;

            // Update the minimum coordinate
            if ( min_pos > files->readers[i].buffer[1]->pos )
            {
                min_pos = files->readers[i].buffer[1]->pos;
                chr = bcf_seqname(files->readers[i].header, files->readers[i].buffer[1]);
                assert(chr);
                bcf_sr_sort_set_active(&BCF_SR_AUX(files)->sort, i);
            }
            else if ( min_pos==files->readers[i].buffer[1]->pos )
                bcf_sr_sort_add_active(&BCF_SR_AUX(files)->sort, i);
        }
        if ( min_pos==HTS_POS_MAX )
        {
            if ( !files->regions ) break;
            continue;
        }

        // Skip this position if not present in targets
        if ( files->targets )
        {
            int match = 0;
            for (i=0; i<files->nreaders; i++)
            {
                if ( !files->readers[i].nbuffer || files->readers[i].buffer[1]->pos!=min_pos ) continue;
                hts_pos_t beg, end;
                if ( BCF_SR_AUX(files)->targets_overlap==0 )
                    beg = end = min_pos;
                else if ( BCF_SR_AUX(files)->targets_overlap==1 )
                {
                    beg = min_pos;
                    end = min_pos + files->readers[i].buffer[1]->rlen - 1;
                }
                else if ( BCF_SR_AUX(files)->targets_overlap==2 )
                    _set_variant_boundaries(files->readers[i].buffer[1], &beg,&end);
                else
                {
                    hts_log_error("This should never happen, just to keep clang compiler happy: %d",BCF_SR_AUX(files)->targets_overlap);
                    exit(1);
                }
                int overlap = bcf_sr_regions_overlap(files->targets, chr, beg, end)==0 ? 1 : 0;
                if ( (!files->targets_exclude && !overlap) || (files->targets_exclude && overlap) )
                    _reader_shift_buffer(&files->readers[i]);
                else
                    match = 1;
            }
            if ( !match )
            {
                min_pos = HTS_POS_MAX;
                chr = NULL;
                continue;
            }
        }
        break;  // done: chr and min_pos are set
    }
    if ( !chr ) return 0;

    return bcf_sr_sort_next(files, &BCF_SR_AUX(files)->sort, chr, min_pos);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movabsq $0x7fffffff7fffffff, %r12 # imm = 0x7FFFFFFF7FFFFFFF
leaq 0x60(%rdi), %rax
movq %rax, 0x30(%rsp)
movq $0x0, 0x18(%rsp)
movq %r12, 0x8(%rsp)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x2ba0d
movslq 0x30(%rbx), %rax
testq %rax, %rax
jle 0x2b981
movq 0x28(%rbx), %rcx
movq %rax, %rdx
shlq $0x5, %rdx
leaq (%rdx,%rdx,2), %rsi
xorl %r8d, %r8d
xorl %edx, %edx
cmpq $0x0, 0x20(%rcx,%r8)
jne 0x2b976
cmpl $0x1, 0x38(%rcx,%r8)
adcl $0x0, %edx
addq $0x60, %r8
cmpq %r8, %rsi
jne 0x2b965
jmp 0x2b983
xorl %edx, %edx
cmpl %eax, %edx
jne 0x2ba0d
movl 0x9c(%rdi), %ebp
movq 0xa8(%rdi), %r14
callq 0x2cef1
testl %eax, %eax
js 0x2c085
movq 0x48(%rbx), %rax
cmpl 0x9c(%rax), %ebp
movq $-0x1, %rcx
cmovneq %rcx, %r14
movq %r14, 0xc0(%rax)
cmpl $0x0, 0x30(%rbx)
jle 0x2ba0d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x28(%rbx), %rdi
addq %r15, %rdi
movq 0x48(%rbx), %rax
movslq 0x9c(%rax), %rcx
movq 0x90(%rax), %rsi
movq 0xa0(%rax), %rdx
movq (%rsi,%rcx,8), %rsi
movq 0xa8(%rax), %rcx
callq 0x2c5fe
incq %r12
movslq 0x30(%rbx), %rax
addq $0x60, %r15
cmpq %rax, %r12
jl 0x2b9cd
cmpl $0x0, 0x30(%rbx)
jle 0x2be05
movl $0x7fffffff, 0x14(%rsp) # imm = 0x7FFFFFFF
xorl %r15d, %r15d
movq 0x28(%rbx), %rbp
leaq (%r15,%r15,2), %r12
shlq $0x5, %r12
movslq 0x38(%rbp,%r12), %rax
addq %r12, %rbp
testq %rax, %rax
je 0x2ba53
movq 0x30(%rbp), %rcx
movq (%rcx,%rax,8), %rax
movq (%rax), %rax
movq 0x8(%rcx), %rcx
cmpq (%rcx), %rax
jne 0x2bdc6
cmpq $0x0, 0x20(%rbp)
jne 0x2ba64
cmpl $0x0, 0x34(%rbx)
je 0x2bdc6
movl 0x38(%rbp), %ecx
incl %ecx
movslq 0x3c(%rbp), %rax
cmpl %eax, %ecx
jl 0x2bad2
leaq 0x8(%rax), %rcx
movl %ecx, 0x3c(%rbp)
movq 0x30(%rbp), %rdi
leaq 0x40(,%rax,8), %rsi
callq 0x4870
movq %rax, 0x30(%rbp)
movl $0x9, %r13d
movq $-0x8, %r14
callq 0x3604f
movq 0x30(%rbp), %rcx
movslq 0x3c(%rbp), %rdx
addq %r14, %rdx
movq %rax, (%rcx,%rdx,8)
movl 0x14(%rbx), %eax
movq 0x30(%rbp), %rcx
movq (%rcx,%rdx,8), %rcx
movl %eax, 0xb8(%rcx)
movq $-0x1, (%rcx)
decl %r13d
incq %r14
cmpl $0x1, %r13d
ja 0x2ba9a
cmpl $0x0, 0x34(%rbx)
je 0x2bafe
movq (%rbp), %rdi
movl 0x4c(%rdi), %eax
cmpl $0x9, %eax
je 0x2bb63
cmpl $0x8, %eax
jne 0x2c0c5
movl $0x2, %esi
movq 0x30(%rsp), %rdx
callq 0xb781
jmp 0x2bb27
cmpq $0x0, 0x8(%rbp)
movq (%rbp), %rdi
je 0x2bb8e
callq 0xb57d
movq 0x8(%rbp), %rcx
movq 0x20(%rbp), %rsi
movq %rax, %rdi
movq 0x30(%rsp), %rdx
callq 0x10676
cmpl $-0x2, %eax
jg 0x2bb33
movl $0x9, 0x20(%rbx)
testl %eax, %eax
js 0x2bd93
movq 0x18(%rbp), %rsi
movq 0x30(%rbp), %rax
movslq 0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdx
movq 0x30(%rsp), %rdi
callq 0x39b75
testl %eax, %eax
jns 0x2bc05
jmp 0x2bd8c
movq 0x18(%rbp), %rsi
movq 0x30(%rbp), %rax
movslq 0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdx
callq 0x3662a
cmpl $-0x2, %eax
jg 0x2bb85
movl $0x9, 0x20(%rbx)
testl %eax, %eax
jns 0x2bc05
jmp 0x2bd93
testb $0x10, (%rdi)
jne 0x2bbbf
movl $0x1, %edi
leaq 0x8966c(%rip), %rsi     # 0xb520b
leaq 0x89672(%rip), %rdx     # 0xb5218
xorl %eax, %eax
callq 0x9e34
callq 0x4050
movl $0x16, (%rax)
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x2bbdb
movq 0x20(%rbp), %rsi
movq 0x30(%rbp), %rax
movslq 0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdx
movq 0x38(%rdi), %rdi
xorl %ecx, %ecx
callq 0x10676
cmpl $-0x2, %eax
jg 0x2bbe7
movl $0x9, 0x20(%rbx)
testl %eax, %eax
js 0x2bd93
movq 0x18(%rbp), %rdi
movq 0x30(%rbp), %rax
movslq 0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rsi
callq 0x3620a
cmpq $0x0, 0x48(%rbx)
je 0x2bcc2
movq 0x88(%rbx), %rax
movl 0x1d8(%rax), %ecx
cmpl $0x2, %ecx
je 0x2bc71
cmpl $0x1, %ecx
je 0x2bc4b
testl %ecx, %ecx
jne 0x2c0e1
movq 0x30(%rbp), %rax
movslq 0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq %rax, 0x28(%rsp)
jmp 0x2bc8d
movq 0x30(%rbp), %rax
movslq 0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq (%rax), %rcx
movq %rcx, 0x28(%rsp)
movq 0x8(%rax), %rax
addq %rcx, %rax
decq %rax
movq %rax, 0x20(%rsp)
jmp 0x2bc8d
movq 0x30(%rbp), %rax
movslq 0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x2d330
movq 0x28(%rsp), %rax
movq 0x48(%rbx), %rcx
cmpq 0xc0(%rcx), %rax
jle 0x2ba64
movq 0x20(%rsp), %rdx
cmpq 0xa0(%rcx), %rdx
jl 0x2ba64
cmpq 0xa8(%rcx), %rax
jg 0x2ba64
cmpl $0x0, 0x40(%rbp)
movq 0x30(%rbp), %rax
movslq 0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
je 0x2bd2e
movl $0x3, %esi
callq 0x3e6b9
movq 0x30(%rbp), %rax
movslq 0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movl 0x68(%rax), %ecx
testq %rcx, %rcx
je 0x2bd66
testl %ecx, %ecx
jle 0x2ba64
movl 0x40(%rbp), %edx
xorl %esi, %esi
testl %edx, %edx
jle 0x2bd21
movq 0x70(%rax), %rdi
movl (%rdi,%rsi,4), %edi
movq 0x48(%rbp), %r8
xorl %r9d, %r9d
cmpl (%r8,%r9,4), %edi
je 0x2bd38
incq %r9
cmpq %r9, %rdx
jne 0x2bd13
incq %rsi
cmpq %rcx, %rsi
jne 0x2bd01
jmp 0x2ba64
movl $0x1, %esi
callq 0x3e6b9
movslq 0x38(%rbp), %rax
leaq 0x1(%rax), %rcx
movl %ecx, 0x38(%rbp)
movq 0x30(%rbp), %rcx
movq 0x8(%rcx,%rax,8), %rax
movl 0x10(%rax), %edx
movq 0x8(%rcx), %rcx
cmpl 0x10(%rcx), %edx
jne 0x2bda4
movq (%rax), %rax
cmpq (%rcx), %rax
je 0x2ba64
jmp 0x2bda4
movslq 0x40(%rbp), %rax
testq %rax, %rax
jle 0x2ba64
movq 0x48(%rbp), %rcx
xorl %edx, %edx
cmpl $0x0, (%rcx,%rdx,4)
js 0x2bd38
incq %rdx
cmpq %rdx, %rax
jne 0x2bd79
jmp 0x2ba64
movl $0x8, 0x20(%rbx)
movq 0x20(%rbp), %rdi
callq 0xe50f
movq $0x0, 0x20(%rbp)
cmpl $0x2, 0x10(%rbx)
jne 0x2bdc6
movq 0x30(%rbp), %rax
movslq 0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl 0x10(%rcx), %ecx
movq 0x8(%rax), %rax
cmpl 0x10(%rax), %ecx
jl 0x2c10b
cmpl $0x2, 0x10(%rbx)
jne 0x2bdf3
movq 0x28(%rbx), %rax
cmpl $0x0, 0x38(%rax,%r12)
je 0x2bdf3
addq %r12, %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %eax
movl 0x14(%rsp), %ecx
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, 0x14(%rsp)
incq %r15
movslq 0x30(%rbx), %rax
cmpq %rax, %r15
jl 0x2ba22
jmp 0x2be0d
movl $0x7fffffff, 0x14(%rsp) # imm = 0x7FFFFFFF
cmpl $0x0, 0x30(%rbx)
jle 0x2becf
movl $0x38, %ebp
xorl %r15d, %r15d
movq 0x28(%rbx), %rax
cmpl $0x0, (%rax,%rbp)
je 0x2be8e
cmpl $0x2, 0x10(%rbx)
jne 0x2be41
movq -0x8(%rax,%rbp), %rcx
movq 0x8(%rcx), %rcx
movl 0x14(%rsp), %edx
cmpl 0x10(%rcx), %edx
jne 0x2be8e
movq -0x8(%rax,%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx), %r12
cmpq %r12, 0x8(%rsp)
jle 0x2be7d
movq -0x20(%rax,%rbp), %rax
testq %rax, %rax
je 0x2be95
movl 0x10(%rcx), %ecx
movl $0x0, %edx
testl %ecx, %ecx
js 0x2be97
cmpl %ecx, 0x4(%rax)
jle 0x2be95
movq 0x18(%rax), %rax
shlq $0x4, %rcx
movq (%rax,%rcx), %rdx
jmp 0x2be97
jne 0x2be8e
movq 0x88(%rbx), %rdi
movl %r15d, %esi
callq 0x91665
movq 0x8(%rsp), %r12
jmp 0x2beb4
xorl %edx, %edx
movq %rdx, 0x18(%rsp)
testq %rdx, %rdx
je 0x2c12b
movq 0x88(%rbx), %rdi
movl %r15d, %esi
callq 0x915f8
incq %r15
movslq 0x30(%rbx), %rax
addq $0x60, %rbp
movq %r12, 0x8(%rsp)
cmpq %rax, %r15
jl 0x2be1f
jmp 0x2bed4
movq 0x8(%rsp), %r12
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
cmpq %rax, %r12
jne 0x2bef4
cmpq $0x0, 0x48(%rbx)
sete %r15b
movq %rax, %r12
jmp 0x2c075
cmpq $0x0, 0x50(%rbx)
je 0x2c072
xorl %r15d, %r15d
cmpl $0x0, 0x30(%rbx)
jle 0x2c056
leaq -0x1(%r12), %rax
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
movq 0x28(%rbx), %rax
leaq (,%rbp,2), %r13
addq %rbp, %r13
shlq $0x5, %r13
cmpl $0x0, 0x38(%rax,%r13)
je 0x2c035
leaq (%rax,%r13), %rcx
movq 0x30(%rcx), %rcx
movq 0x8(%rcx), %rcx
cmpq %r12, (%rcx)
jne 0x2c035
movq 0x88(%rbx), %rcx
movl 0x1dc(%rcx), %ecx
cmpl $0x2, %ecx
je 0x2bf95
cmpl $0x1, %ecx
je 0x2bf77
testl %ecx, %ecx
jne 0x2c14a
movq %r12, 0x20(%rsp)
movq %r12, 0x28(%rsp)
jmp 0x2bfad
movq %r12, 0x28(%rsp)
movq 0x30(%rax,%r13), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
addq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x2bfad
movq 0x30(%rax,%r13), %rax
movq 0x8(%rax), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x2d330
movq 0x18(%rsp), %rsi
movq 0x50(%rbx), %rdi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
movl $0x1, %r14d
movl $0x1, %r8d
callq 0x2c3c0
testl %eax, %eax
sete %al
cmpl $0x0, 0x5c(%rbx)
sete %cl
cmpb %cl, %al
je 0x2c032
movq 0x28(%rbx), %rax
movl 0x38(%rax,%r13), %ecx
testq %rcx, %rcx
je 0x2c02f
addq %r13, %rax
movq 0x30(%rax), %rdx
movq 0x8(%rdx), %rdx
cmpl $0x2, %ecx
jl 0x2c01d
leaq 0x1(%rcx), %rsi
movl $0x2, %edi
movq 0x30(%rax), %r8
movq (%r8,%rdi,8), %r9
movq %r9, -0x8(%r8,%rdi,8)
incq %rdi
cmpq %rdi, %rsi
jne 0x2c008
cmpl $0x2, %ecx
jl 0x2c02a
movq 0x30(%rax), %rsi
movq %rdx, (%rsi,%rcx,8)
decl %ecx
movl %ecx, 0x38(%rax)
movl %r15d, %r14d
movl %r14d, %r15d
incq %rbp
movslq 0x30(%rbx), %rax
cmpq %rax, %rbp
jl 0x2bf18
testl %r15d, %r15d
setne %r15b
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
testb %r15b, %r15b
movl $0x0, %ecx
movq 0x18(%rsp), %rdx
cmoveq %rcx, %rdx
movq %rdx, 0x18(%rsp)
cmoveq %rax, %r12
jmp 0x2c075
movb $0x1, %r15b
movq %r12, 0x8(%rsp)
testb %r15b, %r15b
je 0x2b93b
jmp 0x2c08a
movq 0x8(%rsp), %r12
movq 0x18(%rsp), %rdx
testq %rdx, %rdx
je 0x2c0b4
movq 0x88(%rbx), %rsi
movq %rbx, %rdi
movq %r12, %rcx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x916d9
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x890ce(%rip), %rsi     # 0xb519a
leaq 0x890db(%rip), %rdx     # 0xb51ae
movl $0x1, %edi
xorl %eax, %eax
callq 0x9e34
jmp 0x2c101
movl 0x1dc(%rax), %ecx
leaq 0x890ac(%rip), %rsi     # 0xb519a
leaq 0x89065(%rip), %rdx     # 0xb515a
movl $0x1, %edi
xorl %eax, %eax
callq 0x9e34
movl $0x1, %edi
callq 0x4600
movq 0x28(%rbp), %rcx
leaq 0x89084(%rip), %rsi     # 0xb519a
leaq 0x890ab(%rip), %rdx     # 0xb51c8
movl $0x1, %edi
xorl %eax, %eax
callq 0x9e34
jmp 0x2c101
leaq 0x88fff(%rip), %rdi     # 0xb5131
leaq 0x88e3a(%rip), %rsi     # 0xb4f73
leaq 0x88ff5(%rip), %rcx     # 0xb5135
movl $0x32b, %edx            # imm = 0x32B
callq 0x42e0
leaq 0x88fff(%rip), %rsi     # 0xb5150
jmp 0x2c0ee