// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/sam.c
// Function: bam_plp_push
int bam_plp_push(bam_plp_t iter, const bam1_t *b)
{
    if (iter->error) return -1;
    if (b) {
        if (b->core.tid < 0) { overlap_remove(iter, b); return 0; }
        // Skip only unmapped reads here, any additional filtering must be done in iter->func
        if (b->core.flag & BAM_FUNMAP) { overlap_remove(iter, b); return 0; }
        if (iter->tid == b->core.tid && iter->pos == b->core.pos && iter->mp->cnt > iter->maxcnt)
        {
            overlap_remove(iter, b);
            return 0;
        }
        if (bam_copy1(&iter->tail->b, b) == NULL)
            return -1;
        iter->tail->b.id = iter->id++;
        iter->tail->beg = b->core.pos;
        // Use raw rlen rather than bam_endpos() which adjusts rlen=0 to rlen=1
        iter->tail->end = b->core.pos + bam_cigar2rlen(b->core.n_cigar, bam_get_cigar(b));
        iter->tail->s = g_cstate_null; iter->tail->s.end = iter->tail->end - 1; // initialize cstate_t
        if (b->core.tid < iter->max_tid) {
            hts_log_error("The input is not sorted (chromosomes out of order)");
            iter->error = 1;
            return -1;
        }
        if ((b->core.tid == iter->max_tid) && (iter->tail->beg < iter->max_pos)) {
            hts_log_error("The input is not sorted (reads out of order)");
            iter->error = 1;
            return -1;
        }
        iter->max_tid = b->core.tid; iter->max_pos = iter->tail->beg;
        if (iter->tail->end > iter->pos || iter->tail->b.core.tid > iter->tid) {
            lbnode_t *next = mp_alloc(iter->mp);
            if (!next) {
                iter->error = 1;
                return -1;
            }
            if (iter->plp_construct) {
                if (iter->plp_construct(iter->data, &iter->tail->b,
                                        &iter->tail->cd) < 0) {
                    mp_free(iter->mp, next);
                    iter->error = 1;
                    return -1;
                }
            }
            if (overlap_push(iter, iter->tail) < 0) {
                mp_free(iter->mp, next);
                iter->error = 1;
                return -1;
            }
            iter->tail->next = next;
            iter->tail = iter->tail->next;
        }
    } else iter->is_eof = 1;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x0, 0x38(%rdi)
jne 0x3065a
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
je 0x30651
movl 0x8(%r14), %eax
testl %eax, %eax
js 0x30643
testb $0x4, 0x10(%r14)
jne 0x30643
cmpl %eax, 0x18(%rbx)
jne 0x30661
movq 0x20(%rbx), %rax
cmpq (%r14), %rax
jne 0x30661
movq (%rbx), %rax
movl (%rax), %eax
cmpl 0x3c(%rbx), %eax
jle 0x30661
movq 0x68(%rbx), %rdi
movq %r14, %rsi
callq 0x30406
jmp 0x30658
movl $0x1, 0x30(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq 0x10(%rbx), %rdi
movq %r14, %rsi
callq 0x22b64
testq %rax, %rax
je 0x3065a
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x40(%rbx)
movq %rcx, 0x30(%rax)
movq (%r14), %rdx
movq %rdx, 0x50(%rax)
movslq 0x14(%r14), %rsi
testq %rsi, %rsi
jle 0x306d2
movzwl 0x12(%r14), %edi
addq 0x38(%r14), %rdi
xorl %r9d, %r9d
xorl %r8d, %r8d
movl (%rdi,%r9,4), %r10d
leal (%r10,%r10), %ecx
movl $0x3c1a7, %r11d         # imm = 0x3C1A7
shrl %cl, %r11d
shll $0x1e, %r11d
sarl $0x1f, %r11d
shrl $0x4, %r10d
andl %r11d, %r10d
addq %r10, %r8
incq %r9
cmpq %r9, %rsi
jne 0x306a5
jmp 0x306d5
xorl %r8d, %r8d
addq %rdx, %r8
movq %r8, 0x58(%rax)
movups 0x66e3d(%rip), %xmm0    # 0x97520
movups %xmm0, 0x60(%rax)
movq $0x0, 0x70(%rax)
movq 0x10(%rbx), %rax
movq 0x58(%rax), %rcx
leaq -0x1(%rcx), %rdx
movq %rdx, 0x70(%rax)
movl 0x8(%r14), %edx
cmpl 0x1c(%rbx), %edx
jge 0x30733
leaq 0x6780b(%rip), %rsi     # 0x97f1a
leaq 0x67811(%rip), %rdx     # 0x97f27
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
movl $0x1, 0x38(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x3065a
movq 0x50(%rax), %rsi
jne 0x3074f
cmpq 0x28(%rbx), %rsi
jge 0x3074f
leaq 0x677d4(%rip), %rsi     # 0x97f1a
leaq 0x6780d(%rip), %rdx     # 0x97f5a
jmp 0x30716
movl %edx, 0x1c(%rbx)
movq %rsi, 0x28(%rbx)
cmpq 0x20(%rbx), %rcx
jg 0x3076a
movl 0x8(%rax), %eax
xorl %ebp, %ebp
cmpl 0x18(%rbx), %eax
jle 0x3065a
movq (%rbx), %rdi
callq 0x2fb2d
testq %rax, %rax
je 0x30722
movq %rax, %r14
movq 0x70(%rbx), %rax
testq %rax, %rax
je 0x30798
movq 0x10(%rbx), %rsi
movq 0x60(%rbx), %rdi
leaq 0x80(%rsi), %rdx
callq *%rax
testl %eax, %eax
js 0x307b9
movq 0x10(%rbx), %rsi
movq %rbx, %rdi
callq 0x307c9
testl %eax, %eax
js 0x307b9
movq 0x10(%rbx), %rax
movq %r14, 0x78(%rax)
movq %r14, 0x10(%rbx)
jmp 0x30658
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x2fcbb
jmp 0x30722