// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_tview.c
// Function: base_draw_aln
int base_draw_aln(tview_t *tv, int tid, int pos)
	{
	assert(tv!=NULL);
	// reset
	tv->my_clear(tv);
	tv->curr_tid = tid; tv->left_pos = pos;
	tv->last_pos = tv->left_pos - 1;
	tv->ccol = 0;
	// print ref and consensus
	if (tv->fai) {
		char *str;
		if (tv->ref) free(tv->ref);
		assert(tv->curr_tid>=0);
		
		str = (char*)calloc(strlen(tv->header->target_name[tv->curr_tid]) + 30, 1);
		assert(str!=NULL);
		sprintf(str, "%s:%d-%d", tv->header->target_name[tv->curr_tid], tv->left_pos + 1, tv->left_pos + tv->mcol);
		tv->ref = fai_fetch(tv->fai, str, &tv->l_ref);
		free(str);
	}
	// draw aln
	bam_lplbuf_reset(tv->lplbuf);
	bam_fetch(tv->fp, tv->idx, tv->curr_tid, tv->left_pos, tv->left_pos + tv->mcol, tv, tv_fetch_func);
	bam_lplbuf_push(0, tv->lplbuf);

	while (tv->ccol < tv->mcol) {
		int pos = tv->last_pos + 1;
		if (pos%10 == 0 && tv->mcol - tv->ccol >= 10) tv->my_mvprintw(tv,0, tv->ccol, "%-d", pos+1);
		tv->my_mvaddch(tv,1, tv->ccol++, (tv->ref && pos < tv->l_ref)? tv->ref[pos - tv->left_pos] : 'N');
		++tv->last_pos;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0x6e25
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
callq *0xa0(%rdi)
movl %r14d, 0x28(%rbx)
movl %ebp, 0x2c(%rbx)
decl %ebp
movl %ebp, 0x44(%rbx)
movl $0x0, 0x40(%rbx)
cmpq $0x0, 0x30(%rbx)
je 0x6d47
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x6cd2
callq 0x3350
movslq 0x28(%rbx), %r15
testq %r15, %r15
js 0x6e44
movq 0x18(%rbx), %rax
movq 0x8(%rax), %r12
movq (%r12,%r15,8), %rdi
callq 0x3360
leaq 0x1e(%rax), %rdi
movl $0x1, %esi
callq 0x3610
testq %rax, %rax
je 0x6e63
movq %rax, %r14
movq (%r12,%r15,8), %rdx
movl 0x2c(%rbx), %r8d
leal 0x1(%r8), %ecx
addl 0x4(%rbx), %r8d
leaq 0x374f8(%rip), %rsi     # 0x3e219
movq %rax, %rdi
xorl %eax, %eax
callq 0x3400
movq 0x30(%rbx), %rdi
leaq 0x58(%rbx), %rdx
movq %r14, %rsi
callq 0x2ef9c
movq %rax, 0x68(%rbx)
movq %r14, %rdi
callq 0x3350
movq 0x10(%rbx), %rdi
callq 0x2c369
movq 0x8(%rbx), %rsi
movq 0x20(%rbx), %rdi
movl 0x28(%rbx), %edx
movl 0x2c(%rbx), %ecx
movl 0x4(%rbx), %r8d
addl %ecx, %r8d
leaq -0x27b(%rip), %rax      # 0x6af1
movq %rax, (%rsp)
movq %rbx, %r9
callq 0x2a4e1
movq 0x10(%rbx), %rsi
xorl %edi, %edi
callq 0x2ca9d
movl 0x4(%rbx), %eax
movl 0x40(%rbx), %edx
cmpl %eax, %edx
jge 0x6e16
movl $0x19999998, %ebp       # imm = 0x19999998
leaq 0x37421(%rip), %r14     # 0x3e1be
movslq 0x44(%rbx), %r8
leaq 0x1(%r8), %r15
imull $0xcccccccd, %r15d, %ecx # imm = 0xCCCCCCCD
addl %ebp, %ecx
rorl %ecx
cmpl %ebp, %ecx
ja 0x6dcf
subl %edx, %eax
cmpl $0xa, %eax
jl 0x6dcf
addl $0x2, %r8d
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rcx
xorl %eax, %eax
callq *0x80(%rbx)
movq 0x88(%rbx), %rax
movl 0x40(%rbx), %edx
leal 0x1(%rdx), %ecx
movl %ecx, 0x40(%rbx)
movq 0x68(%rbx), %rsi
movl $0x4e, %ecx
testq %rsi, %rsi
je 0x6dff
cmpl 0x58(%rbx), %r15d
jge 0x6dff
movslq 0x2c(%rbx), %rcx
subq %rcx, %r15
movsbl (%rsi,%r15), %ecx
movq %rbx, %rdi
movl $0x1, %esi
callq *%rax
incl 0x44(%rbx)
movl 0x4(%rbx), %eax
movl 0x40(%rbx), %edx
cmpl %eax, %edx
jl 0x6d9d
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x372b4(%rip), %rdi     # 0x3e0e0
leaq 0x372b6(%rip), %rsi     # 0x3e0e9
leaq 0x3739e(%rip), %rcx     # 0x3e1d8
movl $0xf5, %edx
callq 0x31b0
leaq 0x373b4(%rip), %rdi     # 0x3e1ff
leaq 0x37297(%rip), %rsi     # 0x3e0e9
leaq 0x3737f(%rip), %rcx     # 0x3e1d8
movl $0xff, %edx
callq 0x31b0
leaq 0x373a5(%rip), %rdi     # 0x3e20f
leaq 0x37278(%rip), %rsi     # 0x3e0e9
leaq 0x37360(%rip), %rcx     # 0x3e1d8
movl $0x102, %edx            # imm = 0x102
callq 0x31b0