// File: /workspace/github_c_makefile_star2_O3/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 %rbx
pushq %rax
testq %rdi, %rdi
je 0x724d
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %rbx
callq *0xa0(%rdi)
movl %ebp, 0x28(%rbx)
movl %r14d, 0x2c(%rbx)
decl %r14d
movl %r14d, 0x44(%rbx)
movl $0x0, 0x40(%rbx)
cmpq $0x0, 0x30(%rbx)
je 0x7167
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0x70f3
callq 0x3350
movl 0x28(%rbx), %ebp
testl %ebp, %ebp
js 0x726c
movq 0x18(%rbx), %rax
movq 0x8(%rax), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %r15
movq %r15, %rdi
callq 0x3360
leaq 0x1e(%rax), %rdi
movl $0x1, %esi
callq 0x3610
testq %rax, %rax
je 0x728b
movq %rax, %r14
movl 0x2c(%rbx), %r8d
leal 0x1(%r8), %ecx
addl 0x4(%rbx), %r8d
leaq 0x380fb(%rip), %rsi     # 0x3f239
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3400
movq 0x30(%rbx), %rdi
leaq 0x58(%rbx), %rdx
movq %r14, %rsi
callq 0x2fb9f
movq %rax, 0x68(%rbx)
movq %r14, %rdi
callq 0x3350
movq 0x10(%rbx), %rdi
callq 0x2cd51
movq 0x8(%rbx), %rsi
movq 0x20(%rbx), %rdi
movl 0x28(%rbx), %edx
movl 0x2c(%rbx), %ecx
movl 0x4(%rbx), %r8d
addl %ecx, %r8d
leaq -0x27e(%rip), %rax      # 0x6f0e
movq %rax, (%rsp)
movq %rbx, %r9
callq 0x2ae7a
movq 0x10(%rbx), %rsi
xorl %edi, %edi
callq 0x2d478
movl 0x4(%rbx), %eax
movl 0x40(%rbx), %edx
cmpl %eax, %edx
jge 0x7240
movl 0x44(%rbx), %r8d
movl $0x19999998, %ebp       # imm = 0x19999998
leaq 0x3801d(%rip), %r14     # 0x3f1de
movslq %r8d, %r15
incq %r15
imull $0xcccccccd, %r15d, %ecx # imm = 0xCCCCCCCD
addl %ebp, %ecx
rorl %ecx
cmpl %ebp, %ecx
ja 0x71f4
subl %edx, %eax
cmpl $0xa, %eax
jl 0x71f4
addl $0x2, %r8d
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rcx
xorl %eax, %eax
callq *0x80(%rbx)
movl 0x40(%rbx), %edx
movq 0x68(%rbx), %rsi
movq 0x88(%rbx), %rax
leal 0x1(%rdx), %ecx
movl %ecx, 0x40(%rbx)
movl $0x4e, %ecx
testq %rsi, %rsi
je 0x7221
cmpl 0x58(%rbx), %r15d
jge 0x7221
movslq 0x2c(%rbx), %rcx
subq %rcx, %r15
movsbl (%rsi,%r15), %ecx
movq %rbx, %rdi
movl $0x1, %esi
callq *%rax
movl 0x44(%rbx), %r8d
incl %r8d
movl %r8d, 0x44(%rbx)
movl 0x4(%rbx), %eax
movl 0x40(%rbx), %edx
cmpl %eax, %edx
jl 0x71c1
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x37eac(%rip), %rdi     # 0x3f100
leaq 0x37eae(%rip), %rsi     # 0x3f109
leaq 0x37f96(%rip), %rcx     # 0x3f1f8
movl $0xf5, %edx
callq 0x31b0
leaq 0x37fac(%rip), %rdi     # 0x3f21f
leaq 0x37e8f(%rip), %rsi     # 0x3f109
leaq 0x37f77(%rip), %rcx     # 0x3f1f8
movl $0xff, %edx
callq 0x31b0
leaq 0x37f9d(%rip), %rdi     # 0x3f22f
leaq 0x37e70(%rip), %rsi     # 0x3f109
leaq 0x37f58(%rip), %rcx     # 0x3f1f8
movl $0x102, %edx            # imm = 0x102
callq 0x31b0