// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq %rdi, %rbx
movabsq $0x7fffffff7fffffff, %r13 # imm = 0x7FFFFFFF7FFFFFFF
leaq 0x60(%rdi), %rax
movq %rax, 0x10(%rsp)
movl 0x30(%rdi), %eax
movq 0x48(%rbx), %rdi
movq $0x0, 0x18(%rsp)
testq %rdi, %rdi
je 0x2aa61
testl %eax, %eax
jle 0x2a9d0
movq 0x28(%rbx), %rcx
movl %eax, %edx
shlq $0x5, %rdx
leaq (%rdx,%rdx,2), %rsi
xorl %r8d, %r8d
xorl %edx, %edx
cmpq $0x0, 0x20(%rcx,%r8)
jne 0x2a9c5
cmpl $0x1, 0x38(%rcx,%r8)
adcl $0x0, %edx
addq $0x60, %r8
cmpq %r8, %rsi
jne 0x2a9b4
jmp 0x2a9d2
xorl %edx, %edx
cmpl %eax, %edx
jne 0x2aa61
movl 0x9c(%rdi), %ebp
movq 0xa8(%rdi), %r14
callq 0x2c1ae
testl %eax, %eax
js 0x2b06a
movq 0x48(%rbx), %rax
cmpl 0x9c(%rax), %ebp
movq $-0x1, %rcx
cmovneq %rcx, %r14
movq %r14, 0xc0(%rax)
movl 0x30(%rbx), %eax
testl %eax, %eax
jle 0x2af0e
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 0x2b7c6
incq %r12
movslq 0x30(%rbx), %rax
addq $0x60, %r15
cmpq %rax, %r12
jl 0x2aa21
testl %eax, %eax
jle 0x2af0e
movl $0x7fffffff, (%rsp)     # imm = 0x7FFFFFFF
xorl %r12d, %r12d
movq 0x28(%rbx), %r15
leaq (%r12,%r12,2), %r13
shlq $0x5, %r13
movslq 0x38(%r15,%r13), %rax
addq %r13, %r15
testq %rax, %rax
je 0x2aaa4
movq 0x30(%r15), %rcx
movq (%rcx,%rax,8), %rdx
movq (%rdx), %rdx
movq 0x8(%rcx), %rcx
cmpq (%rcx), %rdx
jne 0x2adff
cmpq $0x0, 0x20(%r15)
jne 0x2aab5
cmpl $0x0, 0x34(%rbx)
je 0x2adff
incl %eax
movslq 0x3c(%r15), %rcx
cmpl %ecx, %eax
jl 0x2ab1e
leaq 0x8(%rcx), %rax
movl %eax, 0x3c(%r15)
movq 0x30(%r15), %rdi
leaq 0x40(,%rcx,8), %rsi
callq 0x4870
movq %rax, 0x30(%r15)
movl $0x9, %ebp
movq $-0x8, %r14
callq 0x3522a
movq 0x30(%r15), %rcx
movslq 0x3c(%r15), %rdx
addq %r14, %rdx
movq %rax, (%rcx,%rdx,8)
movl 0x14(%rbx), %eax
movq 0x30(%r15), %rcx
movq (%rcx,%rdx,8), %rcx
movl %eax, 0xb8(%rcx)
movq $-0x1, (%rcx)
decl %ebp
incq %r14
cmpl $0x1, %ebp
ja 0x2aae8
cmpl $0x0, 0x34(%rbx)
je 0x2ab49
movq (%r15), %rdi
movl 0x4c(%rdi), %eax
cmpl $0x9, %eax
je 0x2aba2
cmpl $0x8, %eax
jne 0x2b0a8
movl $0x2, %esi
movq 0x10(%rsp), %rdx
callq 0xb47e
jmp 0x2ab6d
cmpq $0x0, 0x8(%r15)
movq (%r15), %rdi
je 0x2abca
callq 0xb277
movq 0x8(%r15), %rcx
movq 0x20(%r15), %rsi
movq %rax, %rdi
movq 0x10(%rsp), %rdx
callq 0x1037e
cmpl $-0x1, %eax
jl 0x2adc4
testl %eax, %eax
js 0x2adcc
movq 0x18(%r15), %rsi
movq 0x30(%r15), %rax
movslq 0x38(%r15), %rcx
movq 0x8(%rax,%rcx,8), %rdx
movq 0x10(%rsp), %rdi
callq 0x39160
testl %eax, %eax
jns 0x2ac16
jmp 0x2ad98
movq 0x18(%r15), %rsi
movq 0x30(%r15), %rax
movslq 0x38(%r15), %rcx
movq 0x8(%rax,%rcx,8), %rdx
callq 0x35805
cmpl $-0x1, %eax
jl 0x2adc4
testl %eax, %eax
jns 0x2ac16
jmp 0x2adcc
testb $0x10, (%rdi)
je 0x2ad9f
movq 0x20(%r15), %rsi
movq 0x30(%r15), %rax
movslq 0x38(%r15), %rcx
movq 0x8(%rax,%rcx,8), %rdx
movq 0x38(%rdi), %rdi
xorl %ecx, %ecx
callq 0x1037e
cmpl $-0x1, %eax
jl 0x2adc4
testl %eax, %eax
js 0x2adcc
movq 0x18(%r15), %rdi
movq 0x30(%r15), %rax
movslq 0x38(%r15), %rcx
movq 0x8(%rax,%rcx,8), %rsi
callq 0x353ed
movq 0x48(%rbx), %rax
testq %rax, %rax
je 0x2acc8
movq 0x88(%rbx), %rcx
movl 0x1d8(%rcx), %edx
cmpl $0x2, %edx
je 0x2ac7a
cmpl $0x1, %edx
je 0x2ac59
testl %edx, %edx
jne 0x2b0c4
movq 0x30(%r15), %rcx
movslq 0x38(%r15), %rdx
movq 0x8(%rcx,%rdx,8), %rcx
movq (%rcx), %rcx
movq %rcx, 0x8(%rsp)
jmp 0x2ac9f
movq 0x30(%r15), %rcx
movslq 0x38(%r15), %rdx
movq 0x8(%rcx,%rdx,8), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
addq %rcx, %rdx
decq %rdx
movq %rdx, 0x8(%rsp)
jmp 0x2ac9f
movq 0x30(%r15), %rax
movslq 0x38(%r15), %rcx
movq 0x8(%rax,%rcx,8), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x2c5d7
movq 0x20(%rsp), %rcx
movq 0x48(%rbx), %rax
cmpq 0xc0(%rax), %rcx
jle 0x2acbf
movq 0x8(%rsp), %rdx
cmpq 0xa0(%rax), %rdx
jl 0x2acbf
cmpq 0xa8(%rax), %rcx
jle 0x2acc8
movl 0x38(%r15), %eax
jmp 0x2aab5
cmpl $0x0, 0x40(%r15)
movq 0x30(%r15), %rax
movslq 0x38(%r15), %rcx
movq 0x8(%rax,%rcx,8), %rdi
je 0x2ad38
movl $0x3, %esi
callq 0x3dd0f
movq 0x30(%r15), %rcx
movslq 0x38(%r15), %rax
movq 0x8(%rcx,%rax,8), %rdx
movl 0x68(%rdx), %esi
testq %rsi, %rsi
je 0x2ad72
testl %esi, %esi
jle 0x2aab5
movl 0x40(%r15), %edi
xorl %r8d, %r8d
testl %edi, %edi
jle 0x2ad2b
movq 0x70(%rdx), %r9
movl (%r9,%r8,4), %r9d
movq 0x48(%r15), %r10
xorl %r11d, %r11d
cmpl (%r10,%r11,4), %r9d
je 0x2ad4a
incq %r11
cmpq %r11, %rdi
jne 0x2ad1d
incq %r8
cmpq %rsi, %r8
jne 0x2ad0a
jmp 0x2aab5
movl $0x1, %esi
callq 0x3dd0f
movl 0x38(%r15), %eax
movq 0x30(%r15), %rcx
movslq %eax, %rdx
incl %eax
movl %eax, 0x38(%r15)
movq 0x8(%rcx,%rdx,8), %rdx
movl 0x10(%rdx), %esi
movq 0x8(%rcx), %rcx
cmpl 0x10(%rcx), %esi
jne 0x2addd
movq (%rdx), %rdx
cmpq (%rcx), %rdx
je 0x2aab5
jmp 0x2addd
movslq 0x40(%r15), %rdx
testq %rdx, %rdx
jle 0x2aab5
movq 0x48(%r15), %rsi
xorl %edi, %edi
cmpl $0x0, (%rsi,%rdi,4)
js 0x2ad4a
incq %rdi
cmpq %rdi, %rdx
jne 0x2ad85
jmp 0x2aab5
movl $0x8, %eax
jmp 0x2adc9
movl $0x1, %edi
leaq 0x88450(%rip), %rsi     # 0xb31fb
leaq 0x88456(%rip), %rdx     # 0xb3208
xorl %eax, %eax
callq 0x9b31
callq 0x4050
movl $0x16, (%rax)
movl $0x9, %eax
movl %eax, 0x20(%rbx)
movq 0x20(%r15), %rdi
callq 0xe271
movq $0x0, 0x20(%r15)
cmpl $0x2, 0x10(%rbx)
jne 0x2ae2a
movq 0x30(%r15), %rax
movslq 0x38(%r15), %rcx
movq (%rax,%rcx,8), %rcx
movl 0x10(%rcx), %ecx
movq 0x8(%rax), %rax
cmpl 0x10(%rax), %ecx
jl 0x2b105
cmpl $0x2, 0x10(%rbx)
jne 0x2ae2a
movq 0x28(%rbx), %rax
cmpl $0x0, 0x38(%rax,%r13)
je 0x2ae2a
addq %r13, %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %eax
movl (%rsp), %ecx
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, (%rsp)
incq %r12
movslq 0x30(%rbx), %rax
cmpq %rax, %r12
jl 0x2aa73
testl %eax, %eax
jle 0x2af04
movl $0x38, %r15d
xorl %r13d, %r13d
movabsq $0x7fffffff7fffffff, %rbp # imm = 0x7FFFFFFF7FFFFFFF
movq 0x28(%rbx), %rax
cmpl $0x0, (%rax,%r15)
je 0x2aee4
cmpl $0x2, 0x10(%rbx)
movq -0x8(%rax,%r15), %rcx
movq 0x8(%rcx), %rcx
jne 0x2ae7b
movl (%rsp), %edx
cmpl 0x10(%rcx), %edx
jne 0x2aee4
movq (%rcx), %r12
cmpq %r12, %rbp
jle 0x2aed3
movq -0x20(%rax,%r15), %rax
testq %rax, %rax
je 0x2b0e6
movl 0x10(%rcx), %ecx
testl %ecx, %ecx
js 0x2b0e6
cmpl %ecx, 0x4(%rax)
jle 0x2b0e6
movq 0x18(%rax), %rax
shlq $0x4, %rcx
movq (%rax,%rcx), %rcx
movq %rcx, 0x18(%rsp)
testq %rcx, %rcx
je 0x2b0e6
movq 0x88(%rbx), %rdi
movl %r13d, %esi
callq 0x8fa34
movq %r12, %rbp
jmp 0x2aee4
jne 0x2aee4
movq 0x88(%rbx), %rdi
movl %r13d, %esi
callq 0x8faa1
incq %r13
movslq 0x30(%rbx), %rax
addq $0x60, %r15
cmpq %rax, %r13
jl 0x2ae55
movabsq $0x7fffffff7fffffff, %r13 # imm = 0x7FFFFFFF7FFFFFFF
jmp 0x2af11
movabsq $0x7fffffff7fffffff, %r13 # imm = 0x7FFFFFFF7FFFFFFF
movq %r13, %rbp
cmpq %r13, %rbp
jne 0x2af28
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
jne 0x2a994
jmp 0x2b06a
cmpq $0x0, 0x50(%rbx)
je 0x2b06d
testl %eax, %eax
jle 0x2a987
leaq -0x1(%rbp), %rcx
movq %rcx, (%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x28(%rbx), %rcx
leaq (,%r13,2), %r15
addq %r13, %r15
shlq $0x5, %r15
cmpl $0x0, 0x38(%rcx,%r15)
je 0x2b046
addq %r15, %rcx
movq 0x30(%rcx), %rcx
movq 0x8(%rcx), %rdi
cmpq %rbp, (%rdi)
jne 0x2b046
movq 0x88(%rbx), %rax
movl 0x1dc(%rax), %ecx
movq %rbp, %rax
movq %rbp, %rdx
testl %ecx, %ecx
je 0x2afc7
cmpl $0x2, %ecx
je 0x2afae
cmpl $0x1, %ecx
jne 0x2b12d
movq 0x8(%rdi), %rax
addq (%rsp), %rax
movq %rbp, %rdx
jmp 0x2afc7
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x2c5d7
movq 0x20(%rsp), %rdx
movq 0x8(%rsp), %rax
movq 0x50(%rbx), %rdi
movl $0x1, %r14d
movq 0x18(%rsp), %rsi
movq %rax, %rcx
movl $0x1, %r8d
callq 0x2b585
testl %eax, %eax
sete %al
cmpl $0x0, 0x5c(%rbx)
sete %cl
cmpb %cl, %al
je 0x2b040
movq 0x28(%rbx), %rax
movl 0x38(%rax,%r15), %ecx
testq %rcx, %rcx
je 0x2b03d
addq %r15, %rax
cmpl $0x2, %ecx
jl 0x2b038
movq 0x30(%rax), %rdx
movq 0x8(%rdx), %rdx
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 0x2b01b
movq 0x30(%rax), %rsi
movq %rdx, (%rsi,%rcx,8)
decl %ecx
movl %ecx, 0x38(%rax)
movl %r12d, %r14d
movl 0x30(%rbx), %eax
movl %r14d, %r12d
incq %r13
movslq %eax, %rcx
cmpq %rcx, %r13
jl 0x2af49
testl %r12d, %r12d
movabsq $0x7fffffff7fffffff, %r13 # imm = 0x7FFFFFFF7FFFFFFF
je 0x2a987
jmp 0x2b06d
movq %r13, %rbp
movq 0x18(%rsp), %rdx
testq %rdx, %rdx
je 0x2b097
movq 0x88(%rbx), %rsi
movq %rbx, %rdi
movq %rbp, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8fb15
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x880db(%rip), %rsi     # 0xb318a
leaq 0x880e8(%rip), %rdx     # 0xb319e
movl $0x1, %edi
xorl %eax, %eax
callq 0x9b31
jmp 0x2b123
movl 0x1dc(%rcx), %ecx
leaq 0x880b9(%rip), %rsi     # 0xb318a
leaq 0x88072(%rip), %rdx     # 0xb314a
movl $0x1, %edi
xorl %eax, %eax
callq 0x9b31
jmp 0x2b123
leaq 0x88034(%rip), %rdi     # 0xb3121
leaq 0x87e6f(%rip), %rsi     # 0xb2f63
leaq 0x8802a(%rip), %rcx     # 0xb3125
movl $0x32b, %edx            # imm = 0x32B
callq 0x42e0
movq 0x28(%r15), %rcx
leaq 0x8807a(%rip), %rsi     # 0xb318a
leaq 0x880a1(%rip), %rdx     # 0xb31b8
movl $0x1, %edi
xorl %eax, %eax
callq 0x9b31
movl $0x1, %edi
callq 0x4600
leaq 0x8800c(%rip), %rsi     # 0xb3140
jmp 0x2b0d1