// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_tview.c
// Function: bam_tview_main
int bam_tview_main(int argc, char *argv[])
	{
	int view_mode=display_ncurses;
	tview_t* tv=NULL;
    char *samples=NULL, *position=NULL;
    int c;
    while ((c = getopt(argc, argv, "s:p:d:")) >= 0) {
        switch (c) {
            case 's': samples=optarg; break;
            case 'p': position=optarg; break;
            case 'd':
            	{
            	switch(optarg[0])
            		{
            		case 'H': case 'h': view_mode=display_html;break;
            		case 'T': case 't': view_mode=display_text;break;
            		case 'C': case 'c': view_mode=display_ncurses;break;
			default: view_mode=display_ncurses;break;
			}
            	break;
            	}
            default: error(NULL);
        }
    }
	if (argc==optind) error(NULL);
	
	switch(view_mode)
		{
		case display_ncurses:
			{
			tv = curses_tv_init(argv[optind], (optind+1>=argc)? 0 : argv[optind+1], samples);
			break;
			}
		case display_text:
			{
			tv = text_tv_init(argv[optind], (optind+1>=argc)? 0 : argv[optind+1], samples);
			break;
			}
		case display_html:
			{
			tv = html_tv_init(argv[optind], (optind+1>=argc)? 0 : argv[optind+1], samples);
			break;
			}
		}
	if(tv==NULL)
		{
		error("cannot create view");
		return EXIT_FAILURE;
		}
	
	if ( position )
	   	 {
		int _tid = -1, _beg, _end;
		bam_parse_region(tv->header, position, &_tid, &_beg, &_end);
		if (_tid >= 0) { tv->curr_tid = _tid; tv->left_pos = _beg; }
	    	}
	tv->my_drawaln(tv, tv->curr_tid, tv->left_pos);
	tv->my_loop(tv);
	tv->my_destroy(tv);
	
	return EXIT_SUCCESS;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movl %edi, %ebp
leaq 0x37386(%rip), %rdx     # 0x3e222
callq 0x3210
testl %eax, %eax
js 0x6f4b
xorl %r14d, %r14d
movq 0x4812d(%rip), %r13     # 0x4efe0
leaq 0x37368(%rip), %r12     # 0x3e222
movq $0x0, (%rsp)
xorl %ebx, %ebx
cmpl $0x64, %eax
je 0x6ee7
cmpl $0x70, %eax
je 0x6ee1
cmpl $0x73, %eax
jne 0x7045
movq (%r13), %rax
movq %rax, (%rsp)
jmp 0x6f34
movq (%r13), %r14
jmp 0x6f34
movq (%r13), %rax
movzbl (%rax), %eax
addl $-0x43, %eax
cmpl $0x31, %eax
ja 0x6f32
movabsq $0x100000001, %rcx      # imm = 0x100000001
btq %rax, %rcx
jb 0x6f32
movl $0x1, %ebx
movabsq $0x2000000020, %rcx     # imm = 0x2000000020
btq %rax, %rcx
jb 0x6f34
movabsq $0x2000000020000, %rcx  # imm = 0x2000000020000
btq %rax, %rcx
jae 0x6f32
movl $0x2, %ebx
jmp 0x6f34
xorl %ebx, %ebx
movl %ebp, %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x3210
testl %eax, %eax
jns 0x6ec4
jmp 0x6f58
xorl %ebx, %ebx
movq $0x0, (%rsp)
xorl %r14d, %r14d
movq 0x48059(%rip), %rax     # 0x4efb8
cmpl %ebp, (%rax)
je 0x7045
movslq (%rax), %rcx
movq (%r15,%rcx,8), %rdi
leal 0x1(%rcx), %eax
cmpl $0x2, %ebx
je 0x6f8a
cmpl $0x1, %ebx
jne 0x6f96
cmpl %ebp, %eax
movq %r14, %rbx
jge 0x6fa4
cltq
movq (%r15,%rax,8), %rsi
jmp 0x6fa6
cmpl %ebp, %eax
jge 0x6fb1
cltq
movq (%r15,%rax,8), %rsi
jmp 0x6fb3
movq %r14, %rbx
cmpl %ebp, %eax
jge 0x6fc1
movq 0x8(%r15,%rcx,8), %rsi
jmp 0x6fc3
xorl %esi, %esi
movq (%rsp), %rdx
callq 0x1f3f8
jmp 0x6fcc
xorl %esi, %esi
movq %r14, %rbx
movq (%rsp), %rdx
callq 0x1fc0f
jmp 0x6fcc
xorl %esi, %esi
movq (%rsp), %rdx
callq 0x1e900
movq %rax, %r14
testq %rax, %rax
je 0x704e
testq %rbx, %rbx
je 0x7011
leaq 0x14(%rsp), %r15
movl $0xffffffff, (%r15)     # imm = 0xFFFFFFFF
movq 0x18(%r14), %rdi
leaq 0xc(%rsp), %rcx
leaq 0x10(%rsp), %r8
movq %rbx, %rsi
movq %r15, %rdx
callq 0x22482
movl (%r15), %eax
testl %eax, %eax
js 0x7011
movl %eax, 0x28(%r14)
movl 0xc(%rsp), %eax
movl %eax, 0x2c(%r14)
movl 0x28(%r14), %esi
movl 0x2c(%r14), %edx
movq %r14, %rdi
callq *0xb0(%r14)
movq %r14, %rdi
callq *0xb8(%r14)
movq %r14, %rdi
callq *0x78(%r14)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
xorl %eax, %eax
callq 0x7057
leaq 0x371d4(%rip), %rdi     # 0x3e229
jmp 0x7047