// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: bam_plp64_next
const bam_pileup1_t *bam_plp64_next(bam_plp_t iter, int *_tid, hts_pos_t *_pos, int *_n_plp)
{
    if (iter->error) { *_n_plp = -1; return NULL; }
    *_n_plp = 0;
    if (iter->is_eof && iter->head == iter->tail) return NULL;
    while (iter->is_eof || iter->max_tid > iter->tid || (iter->max_tid == iter->tid && iter->max_pos > iter->pos)) {
        int n_plp = 0;
        // write iter->plp at iter->pos
        lbnode_t **pptr = &iter->head;
        while (*pptr != iter->tail) {
            lbnode_t *p = *pptr;
            if (p->b.core.tid < iter->tid || (p->b.core.tid == iter->tid && p->end <= iter->pos)) { // then remove
                overlap_remove(iter, &p->b);
                if (iter->plp_destruct)
                    iter->plp_destruct(iter->data, &p->b, &p->cd);
                *pptr = p->next; mp_free(iter->mp, p);
            }
            else {
                if (p->b.core.tid == iter->tid && p->beg <= iter->pos) { // here: p->end > pos; then add to pileup
                    if (n_plp == iter->max_plp) { // then double the capacity
                        iter->max_plp = iter->max_plp? iter->max_plp<<1 : 256;
                        iter->plp = (bam_pileup1_t*)realloc(iter->plp, sizeof(bam_pileup1_t) * iter->max_plp);
                    }
                    iter->plp[n_plp].b = &p->b;
                    iter->plp[n_plp].cd = p->cd;
                    if (resolve_cigar2(iter->plp + n_plp, iter->pos, &p->s)) ++n_plp; // actually always true...
                }
                pptr = &(*pptr)->next;
            }
        }
        *_n_plp = n_plp; *_tid = iter->tid; *_pos = iter->pos;
        // update iter->tid and iter->pos
        if (iter->head != iter->tail) {
            if (iter->tid > iter->head->b.core.tid) {
                hts_log_error("Unsorted input. Pileup aborts");
                iter->error = 1;
                *_n_plp = -1;
                return NULL;
            }
        }
        if (iter->tid < iter->head->b.core.tid) { // come to a new reference sequence
            iter->tid = iter->head->b.core.tid; iter->pos = iter->head->beg; // jump to the next reference
        } else if (iter->pos < iter->head->beg) { // here: tid == head->b.core.tid
            iter->pos = iter->head->beg; // jump to the next position
        } else ++iter->pos; // scan contiguously
        // return
        if (n_plp) return iter->plp;
        if (iter->is_eof && iter->head == iter->tail) break;
    }
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
cmpl $0x0, 0x38(%rdi)
je 0x27255
orl $-0x1, (%r14)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r13
movq %rdi, %r15
andl $0x0, (%r14)
movl 0x30(%rdi), %eax
testl %eax, %eax
je 0x27270
movq 0x8(%r15), %rcx
cmpq 0x10(%r15), %rcx
je 0x27244
leaq 0x8(%r15), %rcx
movq %rcx, 0x30(%rsp)
movq %r14, 0x18(%rsp)
movq %r13, 0x10(%rsp)
movq %rsi, 0x28(%rsp)
testl %eax, %eax
jne 0x272a2
movl 0x18(%r15), %eax
cmpl %eax, 0x1c(%r15)
jg 0x272a2
jne 0x27244
movq 0x28(%r15), %rax
cmpq 0x20(%r15), %rax
jle 0x27244
xorl %ebx, %ebx
movq 0x30(%rsp), %r12
movq (%r12), %rbp
cmpq 0x10(%r15), %rbp
je 0x2776d
movl 0x18(%r15), %eax
cmpl %eax, 0x8(%rbp)
jl 0x272d0
jne 0x27761
movq 0x20(%r15), %rax
cmpq %rax, 0x58(%rbp)
jg 0x27309
movq %r15, %rdi
movq %rbp, %rsi
callq 0x27878
movq 0x78(%r15), %rax
testq %rax, %rax
je 0x272f4
movq 0x60(%r15), %rdi
leaq 0x80(%rbp), %rdx
movq %rbp, %rsi
callq *%rax
movq 0x78(%rbp), %rax
movq %rax, (%r12)
movq (%r15), %rdi
movq %rbp, %rsi
callq 0x271c4
jmp 0x272a9
cmpq %rax, 0x50(%rbp)
jg 0x27761
movq 0x48(%r15), %rax
cmpl 0x34(%r15), %ebx
jne 0x27341
leal (%rbx,%rbx), %ecx
testl %ebx, %ebx
movl $0x100, %edx            # imm = 0x100
cmovel %edx, %ecx
movl %ecx, 0x34(%r15)
movslq %ecx, %rcx
imulq $0x28, %rcx, %rsi
movq %rax, %rdi
callq 0x4840
movq %rax, 0x48(%r15)
movslq %ebx, %rcx
imulq $0x28, %rcx, %rcx
movq %rbp, (%rax,%rcx)
movq 0x80(%rbp), %rdx
movq %rdx, 0x18(%rax,%rcx)
movq 0x20(%r15), %r13
movq 0x48(%r15), %rdx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movq 0x38(%rdx), %rsi
movzwl 0x12(%rdx), %ecx
movq %rcx, 0x8(%rsp)
leaq (%rsi,%rcx), %r8
movslq 0x60(%rbp), %rdi
cmpq $-0x1, %rdi
je 0x27478
movl (%r8,%rdi,4), %r11d
movl %r11d, %r9d
shrl $0x4, %r9d
movq 0x68(%rbp), %r10
movq %r13, %rcx
subq %r10, %rcx
cmpq %r9, %rcx
jl 0x27552
movq %rdx, (%rsp)
movl 0x14(%rdx), %ecx
cmpl %ecx, %edi
jae 0x27859
movq %r13, %rdx
movl 0x4(%r8,%rdi,4), %r14d
movl %r14d, %r13d
andl $0xf, %r13d
andl $0xf, %r11d
cmpl $0x8, %r13d
je 0x27521
movl %r14d, %r13d
andl $0xd, %r13d
je 0x27521
andl $0xb, %r14d
cmpl $0x3, %r14d
je 0x27521
cmpl $0x8, %r11d
ja 0x27402
movl $0x181, %r14d           # imm = 0x181
btl %r11d, %r14d
jae 0x27402
addl %r9d, 0x64(%rbp)
addq %r9, %r10
movq %r10, 0x68(%rbp)
movq 0x8(%rsp), %r9
leaq (%r9,%rdi,4), %r9
addq %rsi, %r9
addq $0x4, %r9
incl %edi
movq %rdx, %r13
movq (%rsp), %rdx
cmpl %edi, %ecx
jbe 0x27837
movl (%r9), %r10d
movl %r10d, %r11d
andl $0xf, %r11d
cmpl $0x8, %r11d
je 0x27547
movl %r10d, %r14d
andl $0xd, %r14d
je 0x27547
movl %r10d, %r14d
andl $0xb, %r14d
cmpl $0x3, %r14d
je 0x27547
cmpl $0x4, %r11d
je 0x27468
cmpl $0x1, %r11d
jne 0x27470
shrl $0x4, %r10d
addl %r10d, 0x64(%rbp)
addq $0x4, %r9
incl %edi
jmp 0x27422
andl $0x0, 0x8(%rax)
movl 0x14(%rdx), %ecx
cmpq $0x1, %rcx
jne 0x274c0
movl (%r8), %ecx
andl $0xf, %ecx
pushq $-0x1
popq %rdi
cmpl $0x8, %ecx
ja 0x27552
movl $0x181, %edi            # imm = 0x181
btl %ecx, %edi
pushq $-0x1
popq %rcx
movl %ecx, %edi
jae 0x27552
andl $0x0, 0x60(%rbp)
movq (%rdx), %rcx
movq %rcx, 0x68(%rbp)
andl $0x0, 0x64(%rbp)
xorl %edi, %edi
jmp 0x27552
movq (%rdx), %rdi
movq %rdi, 0x68(%rbp)
andl $0x0, 0x64(%rbp)
xorl %r9d, %r9d
xorl %edi, %edi
cmpq %rdi, %rcx
je 0x27818
movl (%r8,%rdi,4), %r10d
movl %r10d, %r11d
andl $0xf, %r11d
cmpl $0x8, %r11d
je 0x2751c
movl %r10d, %r14d
andl $0xd, %r14d
je 0x2751c
movl %r10d, %r14d
andl $0xb, %r14d
cmpl $0x3, %r14d
je 0x2751c
cmpl $0x4, %r11d
je 0x2750c
cmpl $0x1, %r11d
jne 0x27517
shrl $0x4, %r10d
addl %r10d, %r9d
movl %r9d, 0x64(%rbp)
incq %rdi
jmp 0x274d0
movl %edi, 0x60(%rbp)
jmp 0x27552
cmpl $0x8, %r11d
ja 0x27537
movl $0x181, %r14d           # imm = 0x181
btl %r11d, %r14d
jae 0x27537
addl %r9d, 0x64(%rbp)
addq %r9, %r10
movq %r10, 0x68(%rbp)
incl %edi
movq %rdx, %r13
movq (%rsp), %rdx
movl %edi, 0x60(%rbp)
cmpl %ecx, %edi
jae 0x2783a
movslq %edi, %rcx
movl (%r8,%rcx,4), %r11d
movl %r11d, %r10d
andl $0xf, %r10d
movl %r11d, %ecx
shrl $0x4, %ecx
movl 0x14(%rax), %r9d
andl $0x0, 0xc(%rax)
andl $-0xa, %r9d
movl %r9d, 0x14(%rax)
movq 0x68(%rbp), %rdi
movq %rdi, 0x20(%rsp)
addq %rdi, %rcx
decq %rcx
movq %r13, (%rsp)
cmpq %r13, %rcx
jne 0x276c5
movslq 0x60(%rbp), %r13
leal 0x1(%r13), %edi
movl 0x14(%rdx), %ecx
cmpl %ecx, %edi
jae 0x276c5
movl 0x4(%r8,%r13,4), %r8d
movl %r8d, %r14d
andl $0xf, %r14d
shrl $0x4, %r8d
cmpl $0x2, %r10d
je 0x2760a
cmpl $0x2, %r14d
jne 0x2760a
negl %r8d
movl %r8d, 0xc(%rax)
addl $0x2, %r13d
movslq %r13d, %rdi
movq 0x8(%rsp), %r14
leaq (%r14,%rdi,4), %rdi
addq %rdi, %rsi
cmpl %r13d, %ecx
jbe 0x276c5
movl (%rsi), %r14d
movl %r14d, %edi
andl $0xf, %edi
cmpl $0x2, %edi
jne 0x276c5
shrl $0x4, %r14d
subl %r14d, %r8d
movl %r8d, 0xc(%rax)
addq $0x4, %rsi
incl %r13d
jmp 0x275db
cmpl $0x6, %r14d
je 0x27662
cmpl $0x1, %r14d
jne 0x276c5
movl %r8d, 0xc(%rax)
addl $0x2, %r13d
movslq %r13d, %rdi
movq 0x8(%rsp), %r14
leaq (%r14,%rdi,4), %rdi
addq %rdi, %rsi
cmpl %r13d, %ecx
jbe 0x276c5
movl (%rsi), %edi
movl %edi, %r14d
andl $0xf, %r14d
cmpl $0x6, %r14d
je 0x27659
cmpl $0x1, %r14d
jne 0x276c5
shrl $0x4, %edi
addl %edi, %r8d
movl %r8d, 0xc(%rax)
addq $0x4, %rsi
incl %r13d
jmp 0x27631
addq $0x2, %r13
cmpl %ecx, %r13d
jae 0x276c5
movq 0x8(%rsp), %rdi
leaq (%rdi,%r13,4), %rdi
addq %rdi, %rsi
xorl %edi, %edi
cmpl %r13d, %ecx
jbe 0x276be
movl (%rsi), %r8d
movl %r8d, %r14d
andl $0xf, %r14d
cmpl $0x1, %r14d
jne 0x27697
shrl $0x4, %r8d
addl %r8d, %edi
jmp 0x276b5
cmpl $0x8, %r14d
je 0x276be
movl %edi, %r14d
movl %r8d, %edi
andl $0xd, %edi
movl %r14d, %edi
je 0x276be
andl $0xb, %r8d
cmpl $0x3, %r8d
je 0x276be
addq $0x4, %rsi
incl %r13d
jmp 0x27679
testl %edi, %edi
jle 0x276c5
movl %edi, 0xc(%rax)
cmpl $0x7, %r10d
setne %cl
testb $0x7, %r11b
setne %sil
testb %cl, %sil
jne 0x276f5
movq (%rsp), %rsi
movl %esi, %ecx
subl 0x20(%rsp), %ecx
addl 0x64(%rbp), %ecx
movl %ecx, 0x8(%rax)
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %r13
jmp 0x27730
andl $0xe, %r11d
cmpl $0x2, %r11d
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %r13
jne 0x2772c
xorl %ecx, %ecx
cmpl $0x3, %r10d
sete %cl
movl %r9d, %esi
orl $0x1, %esi
movl %esi, 0x14(%rax)
movl 0x64(%rbp), %esi
movl %esi, 0x8(%rax)
leal (%r9,%rcx,8), %r9d
incl %r9d
movl %r9d, 0x14(%rax)
movq (%rsp), %rsi
xorl %ecx, %ecx
cmpq %rsi, (%rdx)
sete %cl
andl $-0x3, %r9d
leal (%r9,%rcx,2), %ecx
movl %ecx, 0x14(%rax)
xorl %edx, %edx
cmpq %rsi, 0x70(%rbp)
sete %dl
andl $-0x5, %ecx
leal (%rcx,%rdx,4), %ecx
movl %ecx, 0x14(%rax)
movl 0x60(%rbp), %ecx
movl %ecx, 0x20(%rax)
incl %ebx
movq (%r12), %rbp
addq $0x78, %rbp
movq %rbp, %r12
jmp 0x272a9
movl %ebx, (%r14)
movl 0x18(%r15), %edx
movq 0x28(%rsp), %rsi
movl %edx, (%rsi)
movq 0x20(%r15), %rcx
movq %rcx, (%r13)
movq 0x8(%r15), %rax
cmpq %rbp, %rax
setne %dil
movl 0x8(%rax), %r9d
cmpl %r9d, %edx
setg %r8b
andb %dil, %r8b
cmpb $0x1, %r8b
je 0x277e4
cmpl %r9d, %edx
jge 0x277b1
movl %r9d, 0x18(%r15)
movq 0x50(%rax), %rdx
jmp 0x277c0
movq 0x50(%rax), %rdi
leaq 0x1(%rcx), %rdx
cmpq %rdi, %rcx
cmovlq %rdi, %rdx
movq %rdx, 0x20(%r15)
testl %ebx, %ebx
jne 0x2780f
cmpq %rbp, %rax
setne %cl
movl 0x30(%r15), %eax
testl %eax, %eax
sete %dl
orb %cl, %dl
jne 0x27288
jmp 0x27244
leaq 0x52650(%rip), %rsi     # 0x79e3b
leaq 0x52658(%rip), %rdx     # 0x79e4a
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x110c6
xorl %eax, %eax
movl $0x1, 0x38(%r15)
orl $-0x1, (%r14)
jmp 0x27246
movq 0x48(%r15), %rax
jmp 0x27246
leaq 0x53001(%rip), %rdi     # 0x7a820
leaq 0x5245b(%rip), %rsi     # 0x79c81
leaq 0x52fb5(%rip), %rcx     # 0x7a7e2
movl $0x1588, %edx           # imm = 0x1588
callq 0x42f0
movl %ecx, 0x60(%rbp)
leaq 0x52fdc(%rip), %rdi     # 0x7a81d
leaq 0x52439(%rip), %rsi     # 0x79c81
leaq 0x52f93(%rip), %rcx     # 0x7a7e2
movl $0x159e, %edx           # imm = 0x159E
callq 0x42f0
leaq 0x52fbd(%rip), %rdi     # 0x7a81d
leaq 0x5241a(%rip), %rsi     # 0x79c81
leaq 0x52f74(%rip), %rcx     # 0x7a7e2
movl $0x158e, %edx           # imm = 0x158E
callq 0x42f0