// File: /workspace/github_cpp_makefile_star2_O3/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/bam_tview.c
// Function: tv_init
tview_t *tv_init(const char *fn, const char *fn_fa)
{
	tview_t *tv = (tview_t*)calloc(1, sizeof(tview_t));
	tv->is_dot = 1;
	tv->idx = bam_index_load(fn);
	if (tv->idx == 0) exit(1);
	tv->fp = bam_open(fn, "r");
	bgzf_set_cache_size(tv->fp, 8 * 1024 *1024);
	assert(tv->fp);
	tv->header = bam_header_read(tv->fp);
	tv->lplbuf = bam_lplbuf_init(tv_pl_func, tv);
	if (fn_fa) tv->fai = fai_load(fn_fa);
	tv->bmc = bam_maqcns_init();
	tv->ins = 1;
	bam_maqcns_prepare(tv->bmc);

	initscr();
	keypad(stdscr, TRUE);
	clear();
	noecho();
	cbreak();
	tv->mrow = 24; tv->mcol = 80;
	getmaxyx(stdscr, tv->mrow, tv->mcol);
	tv->wgoto = newwin(3, TV_MAX_GOTO + 10, 10, 5);
	tv->whelp = newwin(29, 40, 5, 5);
	tv->color_for = TV_COLOR_MAPQ;
	start_color();
	init_pair(1, COLOR_BLUE, COLOR_BLACK);
	init_pair(2, COLOR_GREEN, COLOR_BLACK);
	init_pair(3, COLOR_YELLOW, COLOR_BLACK);
	init_pair(4, COLOR_WHITE, COLOR_BLACK);
	init_pair(5, COLOR_GREEN, COLOR_BLACK);
	init_pair(6, COLOR_CYAN, COLOR_BLACK);
	init_pair(7, COLOR_YELLOW, COLOR_BLACK);
	init_pair(8, COLOR_RED, COLOR_BLACK);
	init_pair(9, COLOR_BLUE, COLOR_BLACK);
	return tv;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
movl $0x1, %edi
movl $0x80, %esi
callq 0x3530
movq %rax, %rbx
movl $0x1, 0x64(%rax)
movq %r15, %rdi
callq 0x16892
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x5c16
leaq 0x2165c(%rip), %rsi     # 0x270c7
movq %r15, %rdi
callq 0x10048
movq %rax, %r15
movq %rax, 0x30(%rbx)
movq %rax, %rdi
movl $0x800000, %esi         # imm = 0x800000
callq 0x10e5d
testq %r15, %r15
je 0x5c20
movq %r15, %rdi
callq 0x12383
movq %rax, 0x28(%rbx)
leaq -0x857(%rip), %rdi      # 0x524c
movq %rbx, %rsi
callq 0x18a36
movq %rax, 0x20(%rbx)
testq %r14, %r14
je 0x5ac0
movq %r14, %rdi
callq 0x1b819
movq %rax, 0x40(%rbx)
xorl %eax, %eax
callq 0x6cc5
movq %rax, 0x48(%rbx)
movl $0x1, 0x6c(%rbx)
movq %rax, %rdi
callq 0x6d11
callq 0x35a0
movq 0x284f2(%rip), %r14     # 0x2dfd8
movq (%r14), %rdi
movl $0x1, %esi
callq 0x3190
movq (%r14), %rdi
callq 0x3070
callq 0x3080
callq 0x3570
movq (%r14), %rax
testq %rax, %rax
je 0x5b26
movd 0x4(%rax), %xmm0
pshuflw $0x60, %xmm0, %xmm0     # xmm0 = xmm0[0,0,2,1,4,5,6,7]
psrad $0x10, %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
jmp 0x5b2a
pcmpeqd %xmm0, %xmm0
movq %xmm0, (%rbx)
movl $0x3, %edi
movl $0x32, %esi
movl $0xa, %edx
movl $0x5, %ecx
callq 0x34c0
movq %rax, 0x8(%rbx)
movl $0x1d, %edi
movl $0x28, %esi
movl $0x5, %edx
movl $0x5, %ecx
callq 0x34c0
movq %rax, 0x10(%rbx)
movl $0x0, 0x60(%rbx)
callq 0x35b0
movl $0x1, %edi
movl $0x4, %esi
xorl %edx, %edx
callq 0x3220
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x3220
movl $0x3, %edi
movl $0x3, %esi
xorl %edx, %edx
callq 0x3220
movl $0x4, %edi
movl $0x7, %esi
xorl %edx, %edx
callq 0x3220
movl $0x5, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x3220
movl $0x6, %edi
movl $0x6, %esi
xorl %edx, %edx
callq 0x3220
movl $0x7, %edi
movl $0x3, %esi
xorl %edx, %edx
callq 0x3220
movl $0x8, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x3220
movl $0x9, %edi
movl $0x4, %esi
xorl %edx, %edx
callq 0x3220
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movl $0x1, %edi
callq 0x3130
leaq 0x1d4ae(%rip), %rdi     # 0x230d5
leaq 0x1d4ae(%rip), %rsi     # 0x230dc
leaq 0x1d4b3(%rip), %rcx     # 0x230e8
movl $0xbe, %edx
callq 0x3140