// File: /workspace/github_c_makefile_star2_O3/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 0x12178
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 0x122d3
movl (%r15), %eax
xorl %ebx, %ebx
testl %eax, %eax
js 0x12167
movl 0xc(%r15), %ecx
movl 0x34(%r14), %edx
testw %cx, %dx
jne 0x12167
cmpl %eax, 0x20(%r14)
jne 0x121b8
movl 0x24(%r14), %eax
cmpl 0x4(%r15), %eax
jne 0x121b8
movq (%r14), %rax
movl (%rax), %eax
cmpl 0x40(%r14), %eax
jg 0x12167
movq 0x10(%r14), %rbp
movq 0x30(%rbp), %r12
movl 0x28(%rbp), %r13d
movl 0x24(%r15), %eax
cmpl %eax, %r13d
jge 0x12209
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
movl 0x24(%r15), %eax
leaq 0x3c(%r14), %rcx
movq %rcx, (%rsp)
movq 0x30(%r15), %rsi
movslq %eax, %rdx
movq %r12, %rdi
callq 0x3370
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%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 0x9a3c
movq 0x10(%r14), %rcx
movl %eax, 0x3c(%rcx)
movups 0xa494(%rip), %xmm0     # 0x1c700
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 0x122ff
movl 0x38(%r12), %edx
jne 0x12297
cmpl 0x2c(%r14), %edx
jb 0x1230a
movl %ecx, 0x28(%r14)
movl %edx, 0x2c(%r14)
cmpl 0x24(%r14), %eax
ja 0x122b3
movl (%r12), %eax
cmpl 0x20(%r14), %eax
jle 0x12167
movq (%r14), %rax
incl (%rax)
movslq 0x4(%rax), %rcx
testq %rcx, %rcx
je 0x122e2
movq 0x10(%rax), %rdx
leaq -0x1(%rcx), %rsi
movl %esi, 0x4(%rax)
movq -0x8(%rdx,%rcx,8), %rax
jmp 0x122f1
movl $0x1, 0x30(%r14)
xorl %ebx, %ebx
jmp 0x12167
movl $0x1, %edi
movl $0x58, %esi
callq 0x32e0
movq %rax, 0x50(%r12)
movq %rax, 0x10(%r14)
jmp 0x12167
movq (%rsp), %rdi
callq 0x423d
jmp 0x12313
movq (%rsp), %rdi
callq 0x4215
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x12167