// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_view.c
// Function: process_aln
static int process_aln(const bam_header_t *h, bam1_t *b)
{
	if (g_qual_scale > 1) {
		int i;
		uint8_t *qual = bam1_qual(b);
		for (i = 0; i < b->core.l_qseq; ++i) {
			int c = qual[i] * g_qual_scale;
			qual[i] = c < 93? c : 93;
		}
	}
	if (g_min_qlen > 0) {
		int k, qlen = 0;
		uint32_t *cigar = bam1_cigar(b);
		for (k = 0; k < b->core.n_cigar; ++k)
			if ((bam_cigar_type(bam_cigar_op(cigar[k]))&1) || bam_cigar_op(cigar[k]) == BAM_CHARD_CLIP)
				qlen += bam_cigar_oplen(cigar[k]);
		if (qlen < g_min_qlen) return 1;
	}
	if (b->core.qual < g_min_mapQ || ((b->core.flag & g_flag_on) != g_flag_on) || (b->core.flag & g_flag_off))
		return 1;
	if (g_bed && b->core.tid >= 0 && !bed_overlap(g_bed, h->target_name[b->core.tid], b->core.pos, bam_calend(&b->core, bam1_cigar(b))))
		return 1;
	if (g_subsam_frac > 0.) {
		uint32_t k = __ac_X31_hash_string(bam1_qname(b)) + g_subsam_seed;
		if ((double)(k&0xffffff) / 0x1000000 >= g_subsam_frac) return 1;
	}
	if (g_rg || g_rghash) {
		uint8_t *s = bam_aux_get(b, "RG");
		if (s) {
			if (g_rg) return (strcmp(g_rg, (char*)(s + 1)) == 0)? 0 : 1;
			if (g_rghash) {
				khint_t k = kh_get(rg, g_rghash, (char*)(s + 1));
				return (k != kh_end(g_rghash))? 0 : 1;
			}
		}
	}
	if (g_library) {
		const char *p = bam_get_library((bam_header_t*)h, b);
		return (p && strcmp(p, g_library) == 0)? 0 : 1;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl 0x45c2c(%rip), %eax     # 0x50358
cmpl $0x2, %eax
jl 0xa77f
movl 0x10(%rbx), %ecx
testl %ecx, %ecx
jle 0xa77f
movq 0x8(%rbx), %rdx
movq %rdx, %rsi
shrq $0x30, %rsi
shlq $0x2, %rsi
addq 0x30(%rbx), %rsi
shrl $0x18, %edx
incl %ecx
sarl %ecx
movslq %ecx, %rcx
addq %rdx, %rcx
addq %rsi, %rcx
xorl %edx, %edx
movl $0x5d, %esi
movzbl (%rcx,%rdx), %edi
imull %eax, %edi
cmpl $0x5d, %edi
cmovgel %esi, %edi
movb %dil, (%rcx,%rdx)
incq %rdx
movslq 0x10(%rbx), %rdi
cmpq %rdi, %rdx
jl 0xa762
movl 0x45ba7(%rip), %eax     # 0x5032c
testl %eax, %eax
jle 0xa7e4
movq 0x8(%rbx), %rcx
xorl %esi, %esi
movq %rcx, %rdx
shrq $0x30, %rdx
je 0xa7dd
shrl $0x18, %ecx
addq 0x30(%rbx), %rcx
xorl %edi, %edi
movl $0x14105, %r8d          # imm = 0x14105
xorl %esi, %esi
movl (%rcx,%rdi,4), %r9d
movl %r9d, %r10d
andl $0xf, %r10d
leal (%r9,%r9), %r11d
shrl $0x4, %r9d
btl %r11d, %r8d
movl $0x0, %r11d
cmovbl %r9d, %r11d
cmpl $0x5, %r10d
cmovel %r9d, %r11d
addl %r11d, %esi
incq %rdi
cmpq %rdi, %rdx
jne 0xa7a9
movb $0x1, %r13b
cmpl %eax, %esi
jl 0xa819
movq 0x8(%rbx), %rsi
movl %esi, %eax
shrl $0x10, %eax
movzbl %al, %eax
movb $0x1, %r13b
cmpl 0x45b3f(%rip), %eax     # 0x50338
jl 0xa819
movq %rsi, %rax
shrq $0x20, %rax
movzwl %ax, %eax
movl %eax, %ecx
notl %ecx
testl %ecx, 0x45b21(%rip)     # 0x50330
jne 0xa819
testl %eax, 0x45b1d(%rip)     # 0x50334
je 0xa82c
movzbl %r13b, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x45b15(%rip), %r15     # 0x50348
testq %r15, %r15
je 0xa86d
movslq (%rbx), %rax
testq %rax, %rax
js 0xa86d
movq 0x8(%r14), %rcx
movq (%rcx,%rax,8), %r12
movl 0x4(%rbx), %ebp
shrl $0x18, %esi
addq 0x30(%rbx), %rsi
movq %rbx, %rdi
callq 0x22d1c
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
movl %eax, %ecx
callq 0x305ac
testl %eax, %eax
je 0xa819
movsd 0x44c1b(%rip), %xmm0    # 0x4f490
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xa8d2
movq 0x30(%rbx), %rcx
movsbl (%rcx), %eax
testl %eax, %eax
je 0xa8ac
movb 0x1(%rcx), %dl
testb %dl, %dl
je 0xa8ae
addq $0x2, %rcx
movl %eax, %esi
shll $0x5, %esi
subl %eax, %esi
movsbl %dl, %eax
addl %esi, %eax
movb (%rcx), %dl
incq %rcx
testb %dl, %dl
jne 0xa895
jmp 0xa8ae
xorl %eax, %eax
addl 0x45a74(%rip), %eax     # 0x50328
andl $0xffffff, %eax         # imm = 0xFFFFFF
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd 0x34988(%rip), %xmm1    # 0x3f250
ucomisd %xmm0, %xmm1
jae 0xa819
movq 0x45a87(%rip), %rax     # 0x50360
orq 0x45a70(%rip), %rax     # 0x50350
je 0xa94a
leaq 0x36460(%rip), %rsi     # 0x40d49
movq %rbx, %rdi
callq 0x21c82
movb $0x1, %cl
testq %rax, %rax
je 0xa917
movq 0x45a51(%rip), %rdi     # 0x50350
testq %rdi, %rdi
je 0xa91c
incq %rax
movq %rax, %rsi
callq 0x35a0
testl %eax, %eax
setne %r13b
jmp 0xa940
movb $0x1, %r13b
jmp 0xa942
movq 0x45a3d(%rip), %r15     # 0x50360
movb $0x1, %r13b
testq %r15, %r15
je 0xa942
incq %rax
movq %r15, %rdi
movq %rax, %rsi
callq 0xafe4
cmpl (%r15), %eax
sete %r13b
xorl %ecx, %ecx
testb %cl, %cl
je 0xa819
cmpq $0x0, 0x459ee(%rip)     # 0x50340
je 0xa985
movq %r14, %rdi
movq %rbx, %rsi
callq 0x25967
movb $0x1, %r13b
testq %rax, %rax
je 0xa819
movq 0x459ce(%rip), %rsi     # 0x50340
movq %rax, %rdi
callq 0x35a0
testl %eax, %eax
setne %r13b
jmp 0xa819
xorl %r13d, %r13d
jmp 0xa819