// File: /workspace/github_c_makefile_star2_O3/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 0x37f7e(%rip), %rdx     # 0x3f242
callq 0x3210
testl %eax, %eax
js 0x7373
xorl %r14d, %r14d
movq 0x48d05(%rip), %r13     # 0x4ffe0
leaq 0x37f60(%rip), %r12     # 0x3f242
movq $0x0, (%rsp)
xorl %ebx, %ebx
cmpl $0x64, %eax
je 0x730f
cmpl $0x70, %eax
je 0x7309
cmpl $0x73, %eax
jne 0x746d
movq (%r13), %rax
movq %rax, (%rsp)
jmp 0x735c
movq (%r13), %r14
jmp 0x735c
movq (%r13), %rax
movzbl (%rax), %eax
addl $-0x43, %eax
cmpl $0x31, %eax
ja 0x735a
movabsq $0x100000001, %rcx      # imm = 0x100000001
btq %rax, %rcx
jb 0x735a
movl $0x1, %ebx
movabsq $0x2000000020, %rcx     # imm = 0x2000000020
btq %rax, %rcx
jb 0x735c
movabsq $0x2000000020000, %rcx  # imm = 0x2000000020000
btq %rax, %rcx
jae 0x735a
movl $0x2, %ebx
jmp 0x735c
xorl %ebx, %ebx
movl %ebp, %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x3210
testl %eax, %eax
jns 0x72ec
jmp 0x7380
xorl %ebx, %ebx
movq $0x0, (%rsp)
xorl %r14d, %r14d
movq 0x48c31(%rip), %rax     # 0x4ffb8
movslq (%rax), %rax
cmpl %ebp, %eax
je 0x746d
movq (%r15,%rax,8), %rdi
incl %eax
cmpl $0x2, %ebx
je 0x73b1
cmpl $0x1, %ebx
jne 0x73bd
cmpl %ebp, %eax
movq %r14, %rbx
jge 0x73cc
cltq
movq (%r15,%rax,8), %rsi
jmp 0x73ce
cmpl %ebp, %eax
jge 0x73d9
cltq
movq (%r15,%rax,8), %rsi
jmp 0x73db
movq %r14, %rbx
cmpl %ebp, %eax
jge 0x73e9
cltq
movq (%r15,%rax,8), %rsi
jmp 0x73eb
xorl %esi, %esi
movq (%rsp), %rdx
callq 0x1f960
jmp 0x73f4
xorl %esi, %esi
movq %r14, %rbx
movq (%rsp), %rdx
callq 0x20168
jmp 0x73f4
xorl %esi, %esi
movq (%rsp), %rdx
callq 0x1ee7c
movq %rax, %r14
testq %rax, %rax
je 0x7476
testq %rbx, %rbx
je 0x7439
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 0x22e08
movl (%r15), %eax
testl %eax, %eax
js 0x7439
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 0x747f
leaq 0x37dcc(%rip), %rdi     # 0x3f249
jmp 0x746f