// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0x43869
movq -0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq $0x0, -0x8(%rbp)
jmp 0x43c11
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x30(%rax)
je 0x4389c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x4389c
movq $0x0, -0x8(%rbp)
jmp 0x43c11
jmp 0x4389e
movq -0x10(%rbp), %rcx
movb $0x1, %al
cmpl $0x0, 0x30(%rcx)
movb %al, -0x41(%rbp)
jne 0x438f3
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x10(%rbp), %rdx
movb $0x1, %al
cmpl 0x18(%rdx), %ecx
movb %al, -0x41(%rbp)
jg 0x438f3
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x18(%rdx), %ecx
movb %al, -0x42(%rbp)
jne 0x438ed
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
setg %al
movb %al, -0x42(%rbp)
movb -0x42(%rbp), %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x438ff
jmp 0x43c09
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
je 0x43acf
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jl 0x43964
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jne 0x439c1
movq -0x40(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jg 0x439c1
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x43c20
movq -0x10(%rbp), %rax
cmpq $0x0, 0x78(%rax)
je 0x4399d
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x60(%rcx), %rdi
movq -0x40(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq $0x80, %rdx
callq *%rax
movq -0x40(%rbp), %rax
movq 0x78(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x436c0
jmp 0x43aca
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jne 0x43abb
movq -0x40(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jg 0x43abb
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jne 0x43a47
movq -0x10(%rbp), %rax
cmpl $0x0, 0x34(%rax)
je 0x43a0f
movq -0x10(%rbp), %rax
movl 0x34(%rax), %eax
shll %eax
movl %eax, -0x48(%rbp)
jmp 0x43a19
movl $0x100, %eax            # imm = 0x100
movl %eax, -0x48(%rbp)
jmp 0x43a19
movl -0x48(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x34(%rax), %rax
imulq $0x28, %rax, %rsi
callq 0x4820
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq -0x40(%rbp), %rcx
movq 0x80(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x40(%rbp), %rdx
addq $0x60, %rdx
callq 0x43cf0
cmpl $0x0, %eax
je 0x43ab9
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x43abb
movq -0x38(%rbp), %rax
movq (%rax), %rax
addq $0x78, %rax
movq %rax, -0x38(%rbp)
jmp 0x43912
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
je 0x43b58
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jle 0x43b56
movl $0x1, %edi
leaq 0xae8d8(%rip), %rsi     # 0xf23fe
leaq 0xae8e0(%rip), %rdx     # 0xf240d
movb $0x0, %al
callq 0x1b030
movq -0x10(%rbp), %rax
movl $0x1, 0x38(%rax)
movq -0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq $0x0, -0x8(%rbp)
jmp 0x43c11
jmp 0x43b58
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jge 0x43b94
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x43bd2
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpq 0x50(%rcx), %rax
jge 0x43bc0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x43bd0
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
jmp 0x43bd2
cmpl $0x0, -0x2c(%rbp)
je 0x43be6
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0x43c11
movq -0x10(%rbp), %rax
cmpl $0x0, 0x30(%rax)
je 0x43c04
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x43c04
jmp 0x43c09
jmp 0x4389e
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)