// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/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:
subq $0x68, %rsp
movl %edi, 0x64(%rsp)
movl %esi, 0x60(%rsp)
movl %edx, 0x5c(%rsp)
movq %rcx, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movl (%rax), %eax
cmpl 0x5c(%rsp), %eax
jge 0x478142
movl 0x5c(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movl (%rax), %ecx
sarl %ecx
movq 0x40(%rsp), %rax
orl (%rax), %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movl (%rax), %ecx
sarl $0x2, %ecx
movq 0x40(%rsp), %rax
orl (%rax), %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movl (%rax), %ecx
sarl $0x4, %ecx
movq 0x40(%rsp), %rax
orl (%rax), %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movl (%rax), %ecx
sarl $0x8, %ecx
movq 0x40(%rsp), %rax
orl (%rax), %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movl (%rax), %ecx
sarl $0x10, %ecx
movq 0x40(%rsp), %rax
orl (%rax), %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x40(%rsp), %rax
movslq (%rax), %rsi
shlq $0x2, %rsi
callq 0x340d0
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x40(%rsp), %rax
movslq (%rax), %rsi
shlq $0x2, %rsi
callq 0x340d0
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x18(%rax)
movl 0x5c(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x40(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x4781a8
movq 0x38(%rsp), %rax
movl (%rax), %eax
shrl $0x1c, %eax
cmpl $0x0, %eax
jle 0x478196
movq 0x38(%rsp), %rax
movl (%rax), %edx
shrl $0x1c, %edx
addl $-0x1, %edx
movl (%rax), %ecx
andl $0xf, %edx
shll $0x1c, %edx
andl $0xfffffff, %ecx        # imm = 0xFFFFFFF
orl %edx, %ecx
movl %ecx, (%rax)
jmp 0x478198
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x47815c
movl $0x0, 0x2c(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x5c(%rsp), %eax
jge 0x4783af
movq 0x50(%rsp), %rax
movslq 0x34(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movl 0x14(%rax), %eax
shrl %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4782aa
movq 0x40(%rsp), %rax
movq 0x30(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x478286
movq 0x40(%rsp), %rax
movq 0x30(%rax), %rax
movl (%rax), %eax
shrl $0x1c, %eax
cmpl $0x0, %eax
jne 0x478286
movq 0x40(%rsp), %rax
movq 0x30(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x40(%rsp), %rax
movq 0x30(%rax), %rax
movl (%rax), %edx
andl $0xfffffff, %edx        # imm = 0xFFFFFFF
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x34(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x40(%rsp), %rax
movq 0x30(%rax), %rsi
callq 0x477e60
movq 0x18(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x40(%rsp), %rax
movl 0x40(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x40(%rax)
jmp 0x4782a5
movq 0x40(%rsp), %rax
movl 0xc(%rax), %edx
addl $0x1, %edx
movl %edx, 0xc(%rax)
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x34(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x47835a
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x30(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x30(%rsp)
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x34(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x20(%rsp), %rax
movl 0x14(%rax), %eax
shrl $0x2, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x478358
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x34(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x40(%rsp), %rax
movq 0x38(%rax), %rax
movl (%rax), %ecx
andl $0xfffffff, %edx        # imm = 0xFFFFFFF
andl $0xf0000000, %ecx       # imm = 0xF0000000
orl %edx, %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x477fd0
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq 0x38(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x40(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x40(%rsp), %rax
movl 0x40(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x40(%rax)
jmp 0x47835a
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x34(%rsp), %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x2c(%rsp), %eax
jle 0x478386
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x34(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x2c(%rsp)
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x34(%rsp), %rcx
movl (%rax,%rcx,4), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x10(%rax)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x4781c0
movl 0x30(%rsp), %eax
movq 0x40(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x4783bf
jmp 0x4783de
leaq 0x102384(%rip), %rdi    # 0x57a74a
leaq 0x10232a(%rip), %rsi    # 0x57a6f7
movl $0x74, %edx
leaq 0x102380(%rip), %rcx    # 0x57a759
callq 0x2fdc0
movq 0x40(%rsp), %rax
movq 0x48(%rax), %rax
movl 0x64(%rsp), %edi
movl 0x60(%rsp), %esi
movl 0x5c(%rsp), %edx
movq 0x50(%rsp), %rcx
movq 0x40(%rsp), %r8
movq 0x50(%r8), %r8
callq *%rax
movq 0x40(%rsp), %rax
cmpl $0x0, 0x40(%rax)
je 0x47864d
movq 0x40(%rsp), %rax
movl 0x40(%rax), %eax
addl $0x1, %eax
movq 0x40(%rsp), %rcx
cmpl 0x44(%rcx), %eax
jle 0x4784ee
movq 0x40(%rsp), %rax
movl 0x40(%rax), %ecx
addl $0x1, %ecx
movq 0x40(%rsp), %rax
movl %ecx, 0x44(%rax)
movq 0x40(%rsp), %rax
movl 0x44(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x44(%rax)
movq 0x40(%rsp), %rax
movl 0x44(%rax), %ecx
sarl %ecx
movq 0x40(%rsp), %rax
orl 0x44(%rax), %ecx
movl %ecx, 0x44(%rax)
movq 0x40(%rsp), %rax
movl 0x44(%rax), %ecx
sarl $0x2, %ecx
movq 0x40(%rsp), %rax
orl 0x44(%rax), %ecx
movl %ecx, 0x44(%rax)
movq 0x40(%rsp), %rax
movl 0x44(%rax), %ecx
sarl $0x4, %ecx
movq 0x40(%rsp), %rax
orl 0x44(%rax), %ecx
movl %ecx, 0x44(%rax)
movq 0x40(%rsp), %rax
movl 0x44(%rax), %ecx
sarl $0x8, %ecx
movq 0x40(%rsp), %rax
orl 0x44(%rax), %ecx
movl %ecx, 0x44(%rax)
movq 0x40(%rsp), %rax
movl 0x44(%rax), %ecx
sarl $0x10, %ecx
movq 0x40(%rsp), %rax
orl 0x44(%rax), %ecx
movl %ecx, 0x44(%rax)
movq 0x40(%rsp), %rax
movl 0x44(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x44(%rax)
movq 0x40(%rsp), %rax
movq 0x28(%rax), %rdi
movq 0x40(%rsp), %rax
movslq 0x44(%rax), %rsi
shlq $0x3, %rsi
callq 0x340d0
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x40(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x34(%rsp)
movq 0x38(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x478589
movq 0x38(%rsp), %rax
movl (%rax), %eax
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
cmpl 0x2c(%rsp), %eax
jle 0x478557
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x38(%rsp), %rsi
callq 0x477e60
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x478587
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rax
movq 0x28(%rax), %rax
movl 0x34(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x34(%rsp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x47850c
movq 0x40(%rsp), %rax
movq 0x38(%rax), %rdx
movq 0x40(%rsp), %rax
movq 0x28(%rax), %rax
movslq 0x34(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl 0x34(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, 0x40(%rax)
movq 0x40(%rsp), %rax
cmpl $0x0, 0x40(%rax)
je 0x478639
movq 0x40(%rsp), %rax
movslq 0x40(%rax), %rdi
movq 0x40(%rsp), %rax
movq 0x28(%rax), %rsi
callq 0x477150
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
movq 0x40(%rsp), %rcx
cmpl 0x40(%rcx), %eax
jge 0x478622
movq 0x40(%rsp), %rax
movq 0x28(%rax), %rax
movl 0x34(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq 0x40(%rsp), %rax
movq 0x28(%rax), %rax
movslq 0x34(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x4785da
movq 0x40(%rsp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x30(%rax)
jmp 0x47864b
movq 0x40(%rsp), %rax
movq 0x38(%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x30(%rax)
jmp 0x47864d
movl 0x2c(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x40(%rsp), %rax
movl 0x4(%rax), %eax
shll $0x2, %eax
movslq %eax, %rdx
callq 0x33ca0
movl $0x0, 0x30(%rsp)
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x5c(%rsp), %eax
jge 0x4786fd
movq 0x50(%rsp), %rax
movslq 0x34(%rsp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movl 0x14(%rax), %eax
shrl $0x2, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x4786ee
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movslq 0x34(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x30(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x30(%rsp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x4786f0
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x47868e
movl 0x30(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, 0x8(%rax)
xorl %eax, %eax
addq $0x68, %rsp
retq