// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_tview.c
// Function: base_tv_init
int base_tv_init(tview_t* tv,const char *fn, const char *fn_fa, const char *samples)
	{
	assert(tv!=NULL);
	assert(fn!=NULL);
	tv->mrow = 24; tv->mcol = 80;
	tv->color_for = TV_COLOR_MAPQ;
	tv->is_dot = 1;
	
	tv->fp = bam_open(fn, "r");
	if(tv->fp==0)
		{
		fprintf(stderr,"bam_open %s. %s\n", fn,fn_fa);
            	exit(EXIT_FAILURE);
		}
	bgzf_set_cache_size(tv->fp, 8 * 1024 *1024);
	assert(tv->fp);
	
	tv->header = bam_header_read(tv->fp);
	if(tv->header==0)
		{
		fprintf(stderr,"Cannot read '%s'.\n", fn);
            	exit(EXIT_FAILURE);
		}
	tv->idx = bam_index_load(fn);
	if (tv->idx == 0)
		{
		fprintf(stderr,"Cannot read index for '%s'.\n", fn);
		exit(EXIT_FAILURE);
		}
	tv->lplbuf = bam_lplbuf_init(tv_pl_func, tv);
	if (fn_fa) tv->fai = fai_load(fn_fa);
	tv->bca = bcf_call_init(0.83, 13);
	tv->ins = 1;

    if ( samples ) 
    {
        if ( !tv->header->dict ) tv->header->dict = sam_header_parse2(tv->header->text);
        void *iter = tv->header->dict;
        const char *key, *val;
        int n = 0;
        tv->rg_hash = kh_init(kh_rg);
        while ( (iter = sam_header2key_val(iter, "RG","ID","SM", &key, &val)) )
        {
            if ( !strcmp(samples,key) || (val && !strcmp(samples,val)) )
            {
                khiter_t k = kh_get(kh_rg, tv->rg_hash, key);
                if ( k != kh_end(tv->rg_hash) ) continue;
                int ret;
                k = kh_put(kh_rg, tv->rg_hash, key, &ret);
                kh_value(tv->rg_hash, k) = val;
                n++;
            }
        }
        if ( !n )
        {
            fprintf(stderr,"The sample or read group \"%s\" not present.\n", samples);
            exit(EXIT_FAILURE);
        }
    }

	return 0;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, 0x20(%rsp)
testq %rdi, %rdi
je 0x6503
movq %rsi, %r12
testq %rsi, %rsi
je 0x6522
movq %rdx, %r15
movq %rdi, %rbx
movabsq $0x5000000018, %rax     # imm = 0x5000000018
movq %rax, (%rdi)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x50(%rdi)
leaq 0x3feb3(%rip), %rsi     # 0x45d4f
movq %r12, %rdi
callq 0x20308
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x6541
movq %rax, %rdi
movl $0x800000, %esi         # imm = 0x800000
callq 0x2153b
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x654c
callq 0x235fb
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x656b
movq %r12, %rdi
callq 0x2a134
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x6573
leaq 0x68c(%rip), %rdi       # 0x6585
movq %rbx, %rsi
callq 0x2ce17
movq %rax, 0x10(%rbx)
testq %r15, %r15
je 0x5f16
movq %r15, %rdi
callq 0x2faa6
movq %rax, 0x30(%rbx)
movsd 0x390ea(%rip), %xmm0    # 0x3f008
movl $0xd, %edi
callq 0x10d1c
movq %rax, 0x38(%rbx)
movl $0x1, 0x5c(%rbx)
cmpq $0x0, 0x20(%rsp)
je 0x64f2
movq 0x18(%rbx), %rcx
movq 0x18(%rcx), %rax
testq %rax, %rax
jne 0x5f5d
movq 0x38(%rcx), %rdi
callq 0x36cb0
movq 0x18(%rbx), %rcx
movq %rax, 0x18(%rcx)
movq %rax, 0x40(%rsp)
movl $0x1, %edi
movl $0x28, %esi
callq 0x3610
movq %rax, 0x70(%rbx)
movl $0x0, 0xc(%rsp)
movq %rbx, 0x30(%rsp)
movq 0x40(%rsp), %rdi
leaq 0x3be03(%rip), %rsi     # 0x41d91
leaq 0x39217(%rip), %rdx     # 0x3f1ac
leaq 0x39213(%rip), %rcx     # 0x3f1af
leaq 0x50(%rsp), %r8
leaq 0x48(%rsp), %r9
callq 0x377cd
testq %rax, %rax
je 0x64e7
movq %rax, 0x40(%rsp)
movq 0x50(%rsp), %r14
movq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x35a0
testl %eax, %eax
movq 0x30(%rsp), %rbx
je 0x5fec
movq 0x48(%rsp), %rsi
testq %rsi, %rsi
je 0x5f82
movq 0x20(%rsp), %rdi
callq 0x35a0
testl %eax, %eax
jne 0x5f82
movq 0x70(%rbx), %rdi
movl (%rdi), %r8d
testl %r8d, %r8d
movq %rdi, 0x10(%rsp)
movq %r14, 0x28(%rsp)
je 0x602d
movsbl (%r14), %ecx
testl %ecx, %ecx
je 0x6034
movb 0x1(%r14), %al
testb %al, %al
je 0x6036
leaq 0x2(%r14), %rdx
movl %ecx, %esi
shll $0x5, %esi
subl %ecx, %esi
movsbl %al, %ecx
addl %esi, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0x6016
jmp 0x6036
xorl %ebp, %ebp
jmp 0x60dc
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r8d
movl %edx, %r14d
leal -0x1(%r8), %esi
movl %ecx, %eax
xorl %edx, %edx
divl %esi
incl %edx
movq 0x10(%rdi), %r13
movl %r14d, %ebp
movl %edx, 0x18(%rsp)
movl %ebp, %eax
shrl $0x4, %eax
movl (%r13,%rax,4), %r15d
leal (,%rbp,2), %ebx
andl $0x1e, %ebx
movl %r15d, %eax
movl %ebx, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x60cf
testb $0x1, %al
jne 0x60a1
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x28(%rsp), %rsi
movq %r8, %r12
callq 0x35a0
movl 0x18(%rsp), %edx
movq %r12, %r8
testl %eax, %eax
je 0x60cf
addl %edx, %ebp
cmpl %r8d, %ebp
movl %r8d, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %ebp
cmpl %r14d, %ebp
jne 0x6057
movq 0x10(%rsp), %rbp
movl 0x8(%rbp), %eax
cmpl 0xc(%rbp), %eax
jae 0x60e7
movq 0x28(%rsp), %r15
jmp 0x6333
movl %ebx, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
cmovnel %r8d, %ebp
cmpl %r8d, %ebp
jne 0x5f82
jmp 0x60b8
movl 0x4(%rbp), %eax
leal (%rax,%rax), %ecx
cmpl %r8d, %ecx
movl $0x0, %ecx
sbbl %ecx, %ecx
orl $0x1, %ecx
addl %r8d, %ecx
movl $0x21, %edx
leaq 0x38f77(%rip), %rdi     # 0x3f080
movq 0x28(%rsp), %r15
leal -0x2(%rdx), %esi
decl %edx
cmpl %ecx, (%rdi,%rsi,4)
ja 0x610e
movl %edx, %ecx
movl (%rdi,%rcx,4), %r13d
xorps %xmm0, %xmm0
cvtsi2sd %r13, %xmm0
mulsd 0x38ee2(%rip), %xmm0    # 0x3f010
addsd 0x38ee2(%rip), %xmm0    # 0x3f018
cvttsd2si %xmm0, %rcx
cmpl %ecx, %eax
jae 0x6333
movq %rcx, 0x18(%rsp)
movl %r13d, %eax
shrl $0x4, %eax
leaq 0x4(,%rax,4), %rbx
movq %rbx, %rdi
callq 0x3240
movq %rax, %r12
movq %rax, %rdi
movl $0xaa, %esi
movq %rbx, %rdx
callq 0x3080
movl (%rbp), %edx
cmpl %r13d, %edx
jae 0x61a4
movq 0x18(%rbp), %rdi
leaq (,%r13,8), %rbx
movq %rbx, %rsi
callq 0x3720
movq %rax, 0x18(%rbp)
movq 0x20(%rbp), %rdi
movq %rbx, %rsi
callq 0x3720
movq %rax, 0x20(%rbp)
movl (%rbp), %edx
testl %edx, %edx
je 0x6311
leal -0x1(%r13), %edi
xorl %r8d, %r8d
movq 0x10(%rbp), %r9
movl %r8d, %eax
shrl $0x4, %eax
movl (%r9,%rax,4), %esi
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
movl %esi, %r10d
shrl %cl, %r10d
testb $0x3, %r10b
jne 0x62d8
movl %r8d, %edx
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rbx
movq (%r10,%rdx,8), %r11
movq (%rbx,%rdx,8), %r10
btsl %ecx, %esi
movl %esi, (%r9,%rax,4)
movsbl (%r11), %ecx
testl %ecx, %ecx
je 0x621d
movb 0x1(%r11), %al
testb %al, %al
je 0x621f
leaq 0x2(%r11), %rdx
movl %ecx, %esi
shll $0x5, %esi
subl %ecx, %esi
movsbl %al, %ecx
addl %esi, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0x6206
jmp 0x621f
xorl %ecx, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r13d
movl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %esi, %eax
movl %esi, %ecx
addl %esi, %ecx
andl $0x1e, %ecx
movl $0x2, %ebp
shll %cl, %ebp
shrl $0x4, %eax
movl (%r12,%rax,4), %ebx
testl %ebx, %ebp
jne 0x6273
incl %edx
addl %edx, %esi
xorl %eax, %eax
cmpl %r13d, %esi
jb 0x6257
movl %r13d, %eax
subl %eax, %esi
movl %esi, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %ebx
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl $0x2, %ebp
shll %cl, %ebp
testl %ebx, %ebp
je 0x624b
notl %ebp
andl %ebx, %ebp
movl %ebp, (%r12,%rax,4)
movq 0x10(%rsp), %rbp
movl (%rbp), %edx
movl %esi, %ebx
cmpl %edx, %esi
jae 0x62c8
movl (%r9,%rax,4), %r9d
shrl %cl, %r9d
movq 0x18(%rbp), %rsi
testb $0x3, %r9b
jne 0x62cc
movq (%rsi,%rbx,8), %rdx
movq %r11, (%rsi,%rbx,8)
movq 0x20(%rbp), %rsi
movq (%rsi,%rbx,8), %r14
movq %r10, (%rsi,%rbx,8)
movl $0x1, %esi
shll %cl, %esi
movq 0x10(%rbp), %r9
orl %esi, (%r9,%rax,4)
movq %rdx, %r11
movq %r14, %r10
jmp 0x61f2
movq 0x18(%rbp), %rsi
movq %r11, (%rsi,%rbx,8)
movq 0x20(%rbp), %rax
movq %r10, (%rax,%rbx,8)
incl %r8d
cmpl %edx, %r8d
jne 0x61b3
cmpl %r13d, %edx
jbe 0x6311
movq 0x18(%rbp), %rdi
leaq (,%r13,8), %rbx
movq %rbx, %rsi
callq 0x3720
movq %rax, 0x18(%rbp)
movq 0x20(%rbp), %rdi
movq %rbx, %rsi
callq 0x3720
movq %rax, 0x20(%rbp)
movq 0x10(%rbp), %rdi
callq 0x3350
movq %r12, 0x10(%rbp)
movl %r13d, (%rbp)
movl 0x4(%rbp), %eax
movl %eax, 0x8(%rbp)
movq 0x18(%rsp), %rax
movl %eax, 0xc(%rbp)
movl %r13d, %r8d
movsbl (%r15), %esi
testl %esi, %esi
je 0x635e
movb 0x1(%r15), %al
testb %al, %al
je 0x6360
leaq 0x2(%r15), %rcx
movl %esi, %edx
shll $0x5, %edx
subl %esi, %edx
movsbl %al, %esi
addl %edx, %esi
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x6347
jmp 0x6360
xorl %esi, %esi
movl %esi, %eax
xorl %edx, %edx
divl %r8d
movl %edx, %r13d
movq 0x10(%rbp), %rdi
movl %edx, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %eax
leal (,%r13,2), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x638c
movl %r13d, %r12d
jmp 0x644f
leal -0x1(%r8), %ecx
movl %esi, %eax
xorl %edx, %edx
divl %ecx
incl %edx
movl %r13d, %ebp
movl %r8d, %r12d
movq %rdi, 0x18(%rsp)
movl %edx, 0x3c(%rsp)
movl %ebp, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r14d
leal (,%rbp,2), %ebx
andl $0x1e, %ebx
movl %r14d, %eax
movl %ebx, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x6428
testb $0x1, %al
jne 0x63f8
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebp, %ecx
movq (%rax,%rcx,8), %rdi
movq %r15, %rsi
movq %r8, %r15
callq 0x35a0
movl 0x3c(%rsp), %edx
movq 0x18(%rsp), %rdi
movq %r15, %r8
movq 0x28(%rsp), %r15
testl %eax, %eax
je 0x6428
btl %ebx, %r14d
cmovbl %ebp, %r12d
addl %edx, %ebp
cmpl %r8d, %ebp
movl %r8d, %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
subl %eax, %ebp
cmpl %r13d, %ebp
jne 0x63a7
movb $0x1, %al
movl %r8d, %ecx
cmpl %r8d, %r12d
movq 0x10(%rsp), %rbp
je 0x643f
jmp 0x644f
movl %ebx, %ecx
shrl %cl, %r14d
testb $0x2, %r14b
sete %al
movl %r12d, %ecx
movl %ebp, %r13d
movq 0x10(%rsp), %rbp
cmpl %r8d, %ecx
cmovel %r13d, %ecx
testb %al, %al
cmovnel %r13d, %ecx
movl %ecx, %r12d
movl %r12d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %edx
leal (%r12,%r12), %ecx
andl $0x1e, %ecx
shrl %cl, %edx
testb $0x2, %dl
jne 0x6475
testb $0x1, %dl
movq 0x30(%rsp), %rbx
jne 0x64a9
movl %r12d, %edx
jmp 0x64c7
movq 0x18(%rbp), %rsi
movl %r12d, %edx
movq %r15, (%rsi,%rdx,8)
movl $0x3, %esi
shll %cl, %esi
notl %esi
movq 0x10(%rbp), %rcx
andl %esi, (%rcx,%rax,4)
movq 0x4(%rbp), %xmm0
psubd 0x38ba3(%rip), %xmm0    # 0x3f040
movq %xmm0, 0x4(%rbp)
movq 0x30(%rsp), %rbx
jmp 0x64c7
movq 0x18(%rbp), %rsi
movl %r12d, %edx
movq %r15, (%rsi,%rdx,8)
movl $0x3, %esi
shll %cl, %esi
notl %esi
movq 0x10(%rbp), %rcx
andl %esi, (%rcx,%rax,4)
incl 0x4(%rbp)
movl 0xc(%rsp), %esi
movq 0x48(%rsp), %rax
movq 0x70(%rbx), %rcx
movq 0x20(%rcx), %rcx
movq %rax, (%rcx,%rdx,8)
incl %esi
movl %esi, 0xc(%rsp)
jmp 0x5f82
cmpl $0x0, 0xc(%rsp)
je 0x657b
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x38bf6(%rip), %rdi     # 0x3f100
leaq 0x38bf8(%rip), %rsi     # 0x3f109
leaq 0x38bfd(%rip), %rcx     # 0x3f115
movl $0x6, %edx
callq 0x31b0
leaq 0x38c32(%rip), %rdi     # 0x3f15b
leaq 0x38bd9(%rip), %rsi     # 0x3f109
leaq 0x38bde(%rip), %rcx     # 0x3f115
movl $0x7, %edx
callq 0x31b0
movq %r12, %rdi
movq %r15, %rsi
callq 0x38ac
leaq 0x38c22(%rip), %rdi     # 0x3f175
leaq 0x38baf(%rip), %rsi     # 0x3f109
leaq 0x38bb4(%rip), %rcx     # 0x3f115
movl $0x13, %edx
callq 0x31b0
movq %r12, %rdi
callq 0x3888
movq %r12, %rdi
callq 0x3864
movq 0x20(%rsp), %rdi
callq 0x3840