// File: /workspace/github_c_makefile_star2_O1/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 0x31426
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
je 0x3141d
movl 0x8(%r14), %eax
testl %eax, %eax
js 0x31410
testb $0x4, 0x10(%r14)
jne 0x31410
cmpl %eax, 0x18(%rbx)
jne 0x3142d
movq 0x20(%rbx), %rax
cmpq (%r14), %rax
jne 0x3142d
movq (%rbx), %rax
movl (%rax), %eax
cmpl 0x3c(%rbx), %eax
jle 0x3142d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x311dc
jmp 0x31424
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 0x2357d
testq %rax, %rax
je 0x31426
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 0x3149e
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 0x31471
jmp 0x314a1
xorl %r8d, %r8d
addq %rdx, %r8
movq %r8, 0x58(%rax)
movups 0x69061(%rip), %xmm0    # 0x9a510
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 0x314ff
leaq 0x69a2c(%rip), %rsi     # 0x9af07
leaq 0x69a32(%rip), %rdx     # 0x9af14
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movl $0x1, 0x38(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x31426
jne 0x3151b
movq 0x50(%rax), %rsi
cmpq 0x28(%rbx), %rsi
jge 0x3151b
leaq 0x699f5(%rip), %rsi     # 0x9af07
leaq 0x69a2e(%rip), %rdx     # 0x9af47
jmp 0x314e2
movl %edx, 0x1c(%rbx)
movq 0x50(%rax), %rdx
movq %rdx, 0x28(%rbx)
cmpq 0x20(%rbx), %rcx
jg 0x3153a
movl 0x8(%rax), %eax
xorl %ebp, %ebp
cmpl 0x18(%rbx), %eax
jle 0x31426
movq (%rbx), %rdi
callq 0x30898
testq %rax, %rax
je 0x314ee
movq %rax, %r14
movq 0x70(%rbx), %rax
testq %rax, %rax
je 0x31568
movq 0x10(%rbx), %rsi
movq 0x60(%rbx), %rdi
leaq 0x80(%rsi), %rdx
callq *%rax
testl %eax, %eax
js 0x31589
movq 0x10(%rbx), %rsi
movq %rbx, %rdi
callq 0x31599
testl %eax, %eax
js 0x31589
movq 0x10(%rbx), %rax
movq %r14, 0x78(%rax)
movq %r14, 0x10(%rbx)
jmp 0x31424
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x30a1d
jmp 0x314ee