// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/bam_lpileup.c
// Function: tview_func
static int tview_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl, void *data)
{
	bam_lplbuf_t *tv = (bam_lplbuf_t*)data;
	freenode_t *p;
	int i, l, max_level;
	// allocate memory if necessary
	if (tv->max < n) { // enlarge
		tv->max = n;
		kroundup32(tv->max);
		tv->cur_level = (int*)realloc(tv->cur_level, sizeof(int) * tv->max);
		tv->pre_level = (int*)realloc(tv->pre_level, sizeof(int) * tv->max);
	}
	tv->n_cur = n;
	// update cnt
	for (p = tv->head; p->next; p = p->next)
		if (p->cnt > 0) --p->cnt;
	// calculate cur_level[]
	max_level = 0;
	for (i = l = 0; i < n; ++i) {
		const bam_pileup1_t *p = pl + i;
		if (p->is_head) {
			if (tv->head->next && tv->head->cnt == 0) { // then take a free slot
				freenode_t *p = tv->head->next;
				tv->cur_level[i] = tv->head->level;
				mp_free(tv->mp, tv->head);
				tv->head = p;
				--tv->n_nodes;
			} else tv->cur_level[i] = ++tv->max_level;
		} else {
			tv->cur_level[i] = tv->pre_level[l++];
			if (p->is_tail) { // then return a free slot
				tv->tail->level = tv->cur_level[i];
				tv->tail->next = mp_alloc(tv->mp);
				tv->tail = tv->tail->next;
				++tv->n_nodes;
			}
		}
		if (tv->cur_level[i] > max_level) max_level = tv->cur_level[i];
		((bam_pileup1_t*)p)->level = tv->cur_level[i];
	}
	assert(l == tv->n_pre);
	tv->func(tid, pos, n, pl, tv->user_data);
	// sort the linked list
	if (tv->n_nodes) {
		freenode_t *q;
		if (tv->n_nodes + 1 > tv->m_aux) { // enlarge
			tv->m_aux = tv->n_nodes + 1;
			kroundup32(tv->m_aux);
			tv->aux = (freenode_t**)realloc(tv->aux, sizeof(void*) * tv->m_aux);
		}
		for (p = tv->head, i = l = 0; p->next;) {
			if (p->level > max_level) { // then discard this entry
				q = p->next;
				mp_free(tv->mp, p);
				p = q;
			} else {
				tv->aux[i++] = p;
				p = p->next;
			}
		}
		tv->aux[i] = tv->tail; // add a proper tail for the loop below
		tv->n_nodes = i;
		if (tv->n_nodes) {
			ks_introsort(node, tv->n_nodes, tv->aux);
			for (i = 0; i < tv->n_nodes; ++i) tv->aux[i]->next = tv->aux[i+1];
			tv->head = tv->aux[0];
		} else tv->head = tv->tail;
	}
	// clean up
	tv->max_level = max_level;
	memcpy(tv->pre_level, tv->cur_level, tv->n_cur * 4);
	// squeeze out terminated levels
	for (i = l = 0; i < n; ++i) {
		const bam_pileup1_t *p = pl + i;
		if (!p->is_tail)
			tv->pre_level[l++] = tv->pre_level[i];
	}
	tv->n_pre = l;
/*
	fprintf(stderr, "%d\t", pos+1);
	for (i = 0; i < n; ++i) {
		const bam_pileup1_t *p = pl + i;
		if (p->is_head) fprintf(stderr, "^");
		if (p->is_tail) fprintf(stderr, "$");
		fprintf(stderr, "%d,", p->level);
	}
	fprintf(stderr, "\n");
*/
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %rbx
movq %rcx, %r14
movl %edx, %r15d
movl %esi, 0x20(%rsp)
movl %edi, 0x1c(%rsp)
cmpl %edx, (%r8)
jge 0x183d0
leal -0x1(%r15), %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, %ecx
sarl $0x10, %ecx
orl %eax, %ecx
leal 0x1(%rcx), %eax
movl %eax, (%rbx)
movq 0x10(%rbx), %rdi
movslq %ecx, %rax
leaq 0x4(,%rax,4), %rsi
callq 0x3610
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rdi
movslq (%rbx), %rsi
shlq $0x2, %rsi
callq 0x3610
movq %rax, 0x18(%rbx)
movl %r15d, 0x4(%rbx)
movq 0x30(%rbx), %rax
cmpq $0x0, 0x8(%rax)
je 0x18403
leaq 0x8(%rax), %rcx
movl (%rax), %edx
cmpl $0x10000000, %edx       # imm = 0x10000000
jb 0x183f5
addl $0xf0000000, %edx       # imm = 0xF0000000
movl %edx, (%rax)
movq (%rcx), %rax
leaq 0x8(%rax), %rcx
cmpq $0x0, 0x8(%rax)
jne 0x183e3
movl %r15d, %edi
movq %r15, 0x8(%rsp)
testl %r15d, %r15d
movq %rbx, 0x28(%rsp)
movq %rdi, 0x10(%rsp)
movq %r14, 0x30(%rsp)
jle 0x18598
leaq 0x14(%r14), %r12
xorl %r15d, %r15d
xorl %r8d, %r8d
xorl %ebp, %ebp
testb $0x2, (%r12)
jne 0x18494
movq 0x10(%rbx), %rcx
movq 0x18(%rbx), %rax
movslq %r8d, %rdx
incl %r8d
movl (%rax,%rdx,4), %eax
movl %eax, (%rcx,%r15,4)
testb $0x4, (%r12)
je 0x18574
movq 0x38(%rbx), %rcx
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
movl (%rcx), %edx
movl $0xf0000000, %esi       # imm = 0xF0000000
andl %esi, %edx
orl %eax, %edx
movl %edx, (%rcx)
movq 0x20(%rbx), %rax
incl (%rax)
movslq 0x4(%rax), %rcx
testq %rcx, %rcx
je 0x1854b
movq 0x10(%rax), %rdx
leaq -0x1(%rcx), %rsi
movl %esi, 0x4(%rax)
movq -0x8(%rdx,%rcx,8), %rax
jmp 0x18565
movq 0x30(%rbx), %r13
movq 0x8(%r13), %r14
testq %r14, %r14
je 0x18539
movl (%r13), %eax
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x18539
movq 0x10(%rbx), %rcx
movl %eax, (%rcx,%r15,4)
movq 0x20(%rbx), %rbx
decl (%rbx)
movq $0x0, 0x8(%r13)
movl (%r13), %eax
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
andl %ecx, %eax
orl $0x20000000, %eax       # imm = 0x20000000
movl %eax, (%r13)
movl 0x8(%rbx), %eax
cmpl %eax, 0x4(%rbx)
jne 0x18519
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x100, %eax            # imm = 0x100
cmovel %eax, %ecx
movl %ecx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
movslq %ecx, %rsi
shlq $0x3, %rsi
movl %r8d, 0x24(%rsp)
callq 0x3610
movl 0x24(%rsp), %r8d
movq 0x10(%rsp), %rdi
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rax
movslq 0x4(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x4(%rbx)
movq %r13, (%rax,%rcx,8)
movq 0x28(%rsp), %rbx
movq %r14, 0x30(%rbx)
decl 0x40(%rbx)
jmp 0x18574
movl 0xc(%rbx), %eax
incl %eax
movl %eax, 0xc(%rbx)
movq 0x10(%rbx), %rcx
movl %eax, (%rcx,%r15,4)
jmp 0x18574
movl $0x1, %edi
movl $0x10, %esi
movl %r8d, %r14d
callq 0x3530
movl %r14d, %r8d
movq 0x10(%rsp), %rdi
movq 0x38(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq %rax, 0x38(%rbx)
incl 0x40(%rbx)
movq 0x10(%rbx), %rax
movl (%rax,%r15,4), %eax
cmpl %ebp, %eax
cmovgl %eax, %ebp
movl %eax, -0x4(%r12)
incq %r15
addq $0x18, %r12
cmpq %r15, %rdi
jne 0x1842f
jmp 0x1859d
xorl %ebp, %ebp
xorl %r8d, %r8d
cmpl 0x8(%rbx), %r8d
jne 0x18794
movq 0x50(%rbx), %r8
movl 0x1c(%rsp), %edi
movl 0x20(%rsp), %esi
movq 0x8(%rsp), %r15
movl %r15d, %edx
movq 0x30(%rsp), %r14
movq %r14, %rcx
callq *0x48(%rbx)
movl 0x40(%rbx), %eax
testl %eax, %eax
je 0x18731
cmpl 0x44(%rbx), %eax
jl 0x18616
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, %ecx
sarl $0x10, %ecx
orl %eax, %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x44(%rbx)
movq 0x28(%rbx), %rdi
movslq %ecx, %rax
leaq 0x8(,%rax,8), %rsi
callq 0x3610
movq %rax, 0x28(%rbx)
movq 0x30(%rbx), %r13
movq 0x8(%r13), %r12
testq %r12, %r12
je 0x186cc
leaq 0x8(%r13), %rax
xorl %r15d, %r15d
movl $0xfffffff, %esi        # imm = 0xFFFFFFF
movl (%r13), %ecx
andl %esi, %ecx
cmpl %ebp, %ecx
jle 0x186a3
movq 0x20(%rbx), %rbx
decl (%rbx)
movq $0x0, (%rax)
movl (%r13), %eax
andl %esi, %eax
orl $0x20000000, %eax       # imm = 0x20000000
movl %eax, (%r13)
movl 0x8(%rbx), %eax
cmpl %eax, 0x4(%rbx)
jne 0x1868a
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x100, %eax            # imm = 0x100
cmovel %eax, %ecx
movl %ecx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
movslq %ecx, %rsi
shlq $0x3, %rsi
callq 0x3610
movl $0xfffffff, %esi        # imm = 0xFFFFFFF
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rax
movslq 0x4(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x4(%rbx)
movq %r13, (%rax,%rcx,8)
movq 0x28(%rsp), %rbx
jmp 0x186b4
movq 0x28(%rbx), %rcx
movslq %r15d, %rdx
incl %r15d
movq %r13, (%rcx,%rdx,8)
movq (%rax), %r12
movq %r12, %r13
leaq 0x8(%r12), %rax
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x18633
jmp 0x186cf
xorl %r15d, %r15d
movq 0x28(%rbx), %rax
movq 0x38(%rbx), %rcx
movslq %r15d, %rdi
movq %rcx, (%rax,%rdi,8)
movl %edi, 0x40(%rbx)
testl %edi, %edi
je 0x18721
movq 0x28(%rbx), %rsi
callq 0x17d16
movslq 0x40(%rbx), %rax
testq %rax, %rax
movq 0x8(%rsp), %r15
jle 0x1871b
movq 0x28(%rbx), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movq 0x8(%rcx,%rdx,8), %rdi
leaq 0x1(%rdx), %r8
movq %rdi, 0x8(%rsi)
movq %r8, %rdx
cmpq %r8, %rax
jne 0x18702
movq 0x28(%rbx), %rax
jmp 0x1872a
leaq 0x38(%rbx), %rax
movq 0x8(%rsp), %r15
movq (%rax), %rax
movq %rax, 0x30(%rbx)
movl %ebp, 0xc(%rbx)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdi
movslq 0x4(%rbx), %rdx
shlq $0x2, %rdx
callq 0x3680
testl %r15d, %r15d
jle 0x1877e
addq $0x14, %r14
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x10(%rsp), %r8
testb $0x4, (%r14)
jne 0x18770
movq 0x18(%rbx), %rdx
movl (%rdx,%rcx,4), %esi
movslq %eax, %rdi
incl %eax
movl %esi, (%rdx,%rdi,4)
incq %rcx
addq $0x18, %r14
cmpq %rcx, %r8
jne 0x1875b
jmp 0x18780
xorl %eax, %eax
movl %eax, 0x8(%rbx)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe609(%rip), %rdi      # 0x26da4
leaq 0xe5cc(%rip), %rsi      # 0x26d6e
leaq 0xe60a(%rip), %rcx      # 0x26db3
movl $0x74, %edx
callq 0x3140