// File: /workspace/github_c_makefile_star2_O2/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
leaq 0x60(%rdi), %r14
movq 0x48(%rbx), %rdi
movq $0x0, 0x18(%rsp)
testq %rdi, %rdi
je 0x22590
movl 0x30(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
imulq $0x60, %rdx, %rdx
xorl %esi, %esi
cmpq %rcx, %rdx
je 0x22512
movq 0x28(%rbx), %r8
cmpq $0x0, 0x20(%r8,%rcx)
jne 0x2250c
cmpl $0x1, 0x38(%r8,%rcx)
adcl $0x0, %esi
addq $0x60, %rcx
jmp 0x224f2
cmpl %eax, %esi
jne 0x22590
movl 0x9c(%rdi), %ebp
movq 0xa8(%rdi), %r15
callq 0x23554
testl %eax, %eax
js 0x22b2d
movq 0x48(%rbx), %rax
cmpl 0x9c(%rax), %ebp
pushq $-0x1
popq %rcx
cmovneq %rcx, %r15
movq %r15, 0xc0(%rax)
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq 0x30(%rbx), %rax
cmpq %rax, %r12
jge 0x22590
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 0x22e44
incq %r12
addq $0x60, %r15
jmp 0x2254e
movl $0x7fffffff, 0x8(%rsp)  # imm = 0x7FFFFFFF
xorl %r15d, %r15d
movslq 0x30(%rbx), %rax
cmpq %rax, %r15
jge 0x2295a
movq 0x28(%rbx), %r13
imulq $0x60, %r15, %rbp
movslq 0x38(%r13,%rbp), %rax
addq %rbp, %r13
testq %rax, %rax
je 0x225d5
movq 0x30(%r13), %rcx
movq (%rcx,%rax,8), %rdx
movq (%rdx), %rdx
movq 0x8(%rcx), %rcx
cmpq (%rcx), %rdx
jne 0x22926
cmpq $0x0, 0x20(%r13)
jne 0x225e6
cmpl $0x0, 0x34(%rbx)
je 0x22926
incl %eax
movslq 0x3c(%r13), %rcx
cmpl %ecx, %eax
jge 0x2261c
cmpl $0x0, 0x34(%rbx)
je 0x22670
movq (%r13), %rdi
movl 0x4c(%rdi), %eax
cmpl $0x9, %eax
je 0x226c6
cmpl $0x8, %eax
jne 0x22b72
pushq $0x2
popq %rsi
movq %r14, %rdx
callq 0x9f6c
jmp 0x22693
leaq 0x8(%rcx), %rax
movl %eax, 0x3c(%r13)
movq 0x30(%r13), %rdi
leaq 0x40(,%rcx,8), %rsi
callq 0x4870
movq %rax, 0x30(%r13)
pushq $-0x8
popq %r12
testl %r12d, %r12d
je 0x225f0
callq 0x2aaba
movq 0x30(%r13), %rcx
movslq 0x3c(%r13), %rdx
addq %r12, %rdx
movq %rax, (%rcx,%rdx,8)
movl 0x14(%rbx), %eax
movq 0x30(%r13), %rcx
movq (%rcx,%rdx,8), %rcx
movl %eax, 0xb8(%rcx)
orq $-0x1, (%rcx)
incq %r12
jmp 0x2263d
cmpq $0x0, 0x8(%r13)
movq (%r13), %rdi
je 0x226ee
callq 0x9d88
movq 0x8(%r13), %rcx
movq 0x20(%r13), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0xdddd
cmpl $-0x1, %eax
jl 0x228f0
testl %eax, %eax
js 0x228f6
movq 0x18(%r13), %rsi
movq 0x30(%r13), %rax
movslq 0x38(%r13), %rcx
movq 0x8(%rax,%rcx,8), %rdx
movq %r14, %rdi
callq 0x2d082
testl %eax, %eax
jns 0x2273a
jmp 0x228c9
movq 0x18(%r13), %rsi
movq 0x30(%r13), %rax
movslq 0x38(%r13), %rcx
movq 0x8(%rax,%rcx,8), %rdx
callq 0x2aeca
cmpl $-0x1, %eax
jl 0x228f0
testl %eax, %eax
jns 0x2273a
jmp 0x228f6
testb $0x10, (%rdi)
je 0x228cd
movq 0x20(%r13), %rsi
movq 0x30(%r13), %rax
movslq 0x38(%r13), %rcx
movq 0x8(%rax,%rcx,8), %rdx
movq 0x38(%rdi), %rdi
xorl %ecx, %ecx
callq 0xdddd
cmpl $-0x1, %eax
jl 0x228f0
testl %eax, %eax
js 0x228f6
movq 0x18(%r13), %rdi
movq 0x30(%r13), %rax
movslq 0x38(%r13), %rcx
movq 0x8(%rax,%rcx,8), %rsi
callq 0x2ac64
movq 0x48(%rbx), %rax
testq %rax, %rax
je 0x227ec
movq 0x88(%rbx), %rcx
movl 0x1d8(%rcx), %edx
cmpl $0x2, %edx
je 0x2279e
cmpl $0x1, %edx
je 0x2277d
testl %edx, %edx
jne 0x22b8e
movq 0x30(%r13), %rcx
movslq 0x38(%r13), %rdx
movq 0x8(%rcx,%rdx,8), %rcx
movq (%rcx), %rcx
movq %rcx, 0x10(%rsp)
jmp 0x227c3
movq 0x30(%r13), %rcx
movslq 0x38(%r13), %rdx
movq 0x8(%rcx,%rdx,8), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
addq %rcx, %rdx
decq %rdx
movq %rdx, 0x10(%rsp)
jmp 0x227c3
movq 0x30(%r13), %rax
movslq 0x38(%r13), %rcx
movq 0x8(%rax,%rcx,8), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x2391e
movq 0x20(%rsp), %rcx
movq 0x48(%rbx), %rax
cmpq 0xc0(%rax), %rcx
jle 0x227e3
movq 0x10(%rsp), %rdx
cmpq 0xa0(%rax), %rdx
jl 0x227e3
cmpq 0xa8(%rax), %rcx
jle 0x227ec
movl 0x38(%r13), %eax
jmp 0x225e6
cmpl $0x0, 0x40(%r13)
movq 0x30(%r13), %rax
movslq 0x38(%r13), %rcx
movq 0x8(%rax,%rcx,8), %rdi
je 0x22868
pushq $0x3
popq %rsi
callq 0x2fc94
movq 0x30(%r13), %rcx
movslq 0x38(%r13), %rax
movq 0x8(%rcx,%rax,8), %rdx
movl 0x68(%rdx), %esi
testl %esi, %esi
je 0x2287a
movl $0x0, %edi
cmovlel %edi, %esi
xorl %edi, %edi
cmpq %rsi, %rdi
je 0x225e6
movl 0x40(%r13), %r8d
testl %r8d, %r8d
movl $0x0, %r9d
cmovlel %r9d, %r8d
xorl %r9d, %r9d
cmpq %r9, %r8
je 0x22863
movq 0x70(%rdx), %r10
movl (%r10,%rdi,4), %r10d
movq 0x48(%r13), %r11
leaq 0x1(%r9), %r12
cmpl (%r11,%r9,4), %r10d
movq %r12, %r9
jne 0x22843
jmp 0x228a1
incq %rdi
jmp 0x22826
pushq $0x1
popq %rsi
callq 0x2fc94
movl 0x38(%r13), %eax
movq 0x30(%r13), %rcx
jmp 0x228a1
movl 0x40(%r13), %edx
testl %edx, %edx
movl $0x0, %esi
cmovlel %esi, %edx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x225e6
movq 0x48(%r13), %rdi
cmpl $0x0, (%rdi,%rsi,4)
leaq 0x1(%rsi), %rsi
jns 0x2288a
movslq %eax, %rdx
incl %eax
movl %eax, 0x38(%r13)
movq 0x8(%rcx,%rdx,8), %rdx
movl 0x10(%rdx), %esi
movq 0x8(%rcx), %rcx
cmpl 0x10(%rcx), %esi
jne 0x22904
movq (%rdx), %rdx
cmpq (%rcx), %rdx
je 0x225e6
jmp 0x22904
pushq $0x8
jmp 0x228f2
pushq $0x1
popq %rdi
leaq 0x688c4(%rip), %rsi     # 0x8b19b
leaq 0x688ca(%rip), %rdx     # 0x8b1a8
xorl %eax, %eax
callq 0x86fa
callq 0x4050
movl $0x16, (%rax)
pushq $0x9
popq %rax
movl %eax, 0x20(%rbx)
movq 0x20(%r13), %rdi
callq 0xc3d9
andq $0x0, 0x20(%r13)
cmpl $0x2, 0x10(%rbx)
jne 0x22952
movq 0x30(%r13), %rax
movslq 0x38(%r13), %rcx
movq (%rax,%rcx,8), %rcx
movl 0x10(%rcx), %ecx
movq 0x8(%rax), %rax
cmpl 0x10(%rax), %ecx
jl 0x22bb0
cmpl $0x2, 0x10(%rbx)
jne 0x22952
movq 0x28(%rbx), %rax
cmpl $0x0, 0x38(%rax,%rbp)
je 0x22952
addq %rbp, %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movl 0x10(%rax), %eax
movl 0x8(%rsp), %ecx
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, 0x8(%rsp)
incq %r15
jmp 0x2259b
pushq $0x38
popq %r13
xorl %r15d, %r15d
movabsq $0x7fffffff7fffffff, %r12 # imm = 0x7FFFFFFF7FFFFFFF
movslq %eax, %rcx
cmpq %rcx, %r15
jge 0x229f0
movq 0x28(%rbx), %rax
cmpl $0x0, (%rax,%r13)
je 0x229db
cmpl $0x2, 0x10(%rbx)
movq -0x8(%rax,%r13), %rcx
movq 0x8(%rcx), %rcx
jne 0x22996
movl 0x8(%rsp), %edx
cmpl 0x10(%rcx), %edx
jne 0x229db
movq (%rcx), %rbp
cmpq %rbp, %r12
jle 0x229ca
movq -0x20(%rax,%r13), %rdi
movl 0x10(%rcx), %esi
callq 0x21f24
testq %rax, %rax
je 0x22bd5
movq %rax, 0x18(%rsp)
movq 0x88(%rbx), %rdi
movl %r15d, %esi
callq 0x6e320
jmp 0x229de
jne 0x229db
movq 0x88(%rbx), %rdi
movl %r15d, %esi
callq 0x6e387
movq %r12, %rbp
incq %r15
movl 0x30(%rbx), %eax
addq $0x60, %r13
movq %rbp, %r12
jmp 0x2296b
movabsq $0x7fffffff7fffffff, %rcx # imm = 0x7FFFFFFF7FFFFFFF
cmpq %rcx, %r12
jne 0x22a11
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
jne 0x224d4
jmp 0x22b2d
cmpq $0x0, 0x50(%rbx)
je 0x22b37
leaq -0x1(%r12), %rcx
movq %rcx, 0x8(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
movslq %eax, %rcx
cmpq %rcx, %r13
jge 0x22b23
movq 0x28(%rbx), %rcx
imulq $0x60, %r13, %r15
cmpl $0x0, 0x38(%rcx,%r15)
je 0x22b1b
addq %r15, %rcx
movq 0x30(%rcx), %rcx
movq 0x8(%rcx), %rdi
cmpq %r12, (%rdi)
jne 0x22b1b
movq 0x88(%rbx), %rax
movl 0x1dc(%rax), %ecx
movq %r12, %rax
movq %r12, %rdx
testl %ecx, %ecx
je 0x22aab
cmpl $0x2, %ecx
je 0x22a92
cmpl $0x1, %ecx
jne 0x22bf4
movq 0x8(%rdi), %rax
addq 0x8(%rsp), %rax
movq %r12, %rdx
jmp 0x22aab
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x2391e
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rax
movq 0x50(%rbx), %rdi
movq 0x18(%rsp), %rsi
movq %rax, %rcx
callq 0x23833
testl %eax, %eax
sete %al
cmpl $0x0, 0x5c(%rbx)
sete %dl
pushq $0x1
popq %rcx
cmpb %dl, %al
je 0x22b16
movq 0x28(%rbx), %rax
movslq 0x38(%rax,%r15), %rcx
testq %rcx, %rcx
je 0x22b14
addq %r15, %rax
movq 0x30(%rax), %rdx
movq 0x8(%rdx), %rdx
pushq $0x2
popq %rsi
cmpq %rcx, %rsi
jg 0x22b02
movq 0x30(%rax), %rdi
movq (%rdi,%rsi,8), %r8
movq %r8, -0x8(%rdi,%rsi,8)
incq %rsi
jmp 0x22aeb
cmpl $0x2, %ecx
jl 0x22b0f
movq 0x30(%rax), %rsi
movq %rdx, (%rsi,%rcx,8)
decl %ecx
movl %ecx, 0x38(%rax)
movl %ebp, %ecx
movl 0x30(%rbx), %eax
movl %ecx, %ebp
incq %r13
jmp 0x22a2b
testl %ebp, %ebp
je 0x224c7
jmp 0x22b37
movabsq $0x7fffffff7fffffff, %r12 # imm = 0x7FFFFFFF7FFFFFFF
movq 0x18(%rsp), %rdx
testq %rdx, %rdx
je 0x22b61
movq 0x88(%rbx), %rsi
movq %rbx, %rdi
movq %r12, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6e3f5
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x685b1(%rip), %rsi     # 0x8b12a
leaq 0x685be(%rip), %rdx     # 0x8b13e
pushq $0x1
popq %rbx
movl %ebx, %edi
xorl %eax, %eax
callq 0x86fa
jmp 0x22bce
movl 0x1dc(%rcx), %ecx
leaq 0x6858f(%rip), %rsi     # 0x8b12a
leaq 0x68548(%rip), %rdx     # 0x8b0ea
pushq $0x1
popq %rbx
movl %ebx, %edi
xorl %eax, %eax
callq 0x86fa
jmp 0x22bce
movq 0x28(%r13), %rcx
leaq 0x6856f(%rip), %rsi     # 0x8b12a
leaq 0x68596(%rip), %rdx     # 0x8b158
pushq $0x1
popq %rbx
movl %ebx, %edi
xorl %eax, %eax
callq 0x86fa
movl %ebx, %edi
callq 0x4600
leaq 0x684e5(%rip), %rdi     # 0x8b0c1
leaq 0x68320(%rip), %rsi     # 0x8af03
leaq 0x684db(%rip), %rcx     # 0x8b0c5
movl $0x32b, %edx            # imm = 0x32B
callq 0x42e0
leaq 0x684e5(%rip), %rsi     # 0x8b0e0
jmp 0x22b9b