// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_pileup.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) return 0;
		if (b->core.flag & iter->flag_mask) return 0;
		if (iter->tid == b->core.tid && iter->pos == b->core.pos && iter->mp->cnt > iter->maxcnt) return 0;
		bam_copy1(&iter->tail->b, b);
		iter->tail->beg = b->core.pos; iter->tail->end = bam_calend(&b->core, bam1_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) {
			fprintf(stderr, "[bam_pileup_core] the input is not sorted (chromosomes out of order)\n");
			iter->error = 1;
			return -1;
		}
		if ((b->core.tid == iter->max_tid) && (iter->tail->beg < iter->max_pos)) {
			fprintf(stderr, "[bam_pileup_core] the input is not sorted (reads out of order)\n");
			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) {
			iter->tail->next = mp_alloc(iter->mp);
			iter->tail = iter->tail->next;
		}
	} else iter->is_eof = 1;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x0, 0x3c(%rdi)
je 0x11acf
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r15
movq %rdi, %r14
testq %rsi, %rsi
je 0x11c34
movl (%r15), %eax
xorl %ebx, %ebx
testl %eax, %eax
js 0x11abe
movl 0xc(%r15), %ecx
movl 0x34(%r14), %edx
testw %cx, %dx
jne 0x11abe
cmpl %eax, 0x20(%r14)
jne 0x11b0f
movl 0x24(%r14), %eax
cmpl 0x4(%r15), %eax
jne 0x11b0f
movq (%r14), %rax
movl (%rax), %eax
cmpl 0x40(%r14), %eax
jg 0x11abe
movq 0x10(%r14), %rbp
movq 0x30(%rbp), %r12
movl 0x28(%rbp), %r13d
movl 0x24(%r15), %eax
cmpl %eax, %r13d
jge 0x11b5c
decl %eax
movl %eax, %ecx
sarl %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x8, %eax
orl %ecx, %eax
movl %eax, %r13d
sarl $0x10, %r13d
orl %eax, %r13d
incl %r13d
movslq %r13d, %rsi
movq %r12, %rdi
callq 0x3430
movq %rax, %r12
leaq 0x3c(%r14), %rax
movq %rax, (%rsp)
movq 0x30(%r15), %rsi
movslq 0x24(%r15), %rdx
movq %r12, %rdi
callq 0x3370
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rbp)
movq 0x30(%r15), %rax
movq %rax, 0x30(%rbp)
movups %xmm0, (%rbp)
movups %xmm1, 0x10(%rbp)
movl %r13d, 0x28(%rbp)
movq %r12, 0x30(%rbp)
movl 0x4(%r15), %eax
movq 0x10(%r14), %rcx
movl %eax, 0x38(%rcx)
movzbl 0xb(%r15), %esi
addq 0x30(%r15), %rsi
movq %r15, %rdi
callq 0x9628
movq 0x10(%r14), %rcx
movl %eax, 0x3c(%rcx)
movups 0x9b60(%rip), %xmm0     # 0x1b728
movups %xmm0, 0x40(%rcx)
movq 0x10(%r14), %r12
movl 0x3c(%r12), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x4c(%r12)
movl (%r15), %ecx
cmpl 0x28(%r14), %ecx
jl 0x11c60
jne 0x11bf3
movl 0x38(%r12), %edx
cmpl 0x2c(%r14), %edx
jb 0x11c6b
movl %ecx, 0x28(%r14)
movl 0x38(%r12), %ecx
movl %ecx, 0x2c(%r14)
cmpl 0x24(%r14), %eax
ja 0x11c14
movl (%r12), %eax
cmpl 0x20(%r14), %eax
jle 0x11abe
movq (%r14), %rax
incl (%rax)
movslq 0x4(%rax), %rcx
testq %rcx, %rcx
je 0x11c43
movq 0x10(%rax), %rdx
leaq -0x1(%rcx), %rsi
movl %esi, 0x4(%rax)
movq -0x8(%rdx,%rcx,8), %rax
jmp 0x11c52
movl $0x1, 0x30(%r14)
xorl %ebx, %ebx
jmp 0x11abe
movl $0x1, %edi
movl $0x58, %esi
callq 0x32e0
movq %rax, 0x50(%r12)
movq %rax, 0x10(%r14)
jmp 0x11abe
movq (%rsp), %rdi
callq 0x3f62
jmp 0x11c74
movq (%rsp), %rdi
callq 0x3f3a
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x11abe