// File: /workspace/github_c_makefile_star2_O3/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 0x46813(%rip), %eax     # 0x51358
cmpl $0x2, %eax
jl 0xab98
movl 0x10(%rbx), %ecx
testl %ecx, %ecx
jle 0xab98
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 0xab7b
movl 0x4678e(%rip), %eax     # 0x5132c
testl %eax, %eax
jle 0xac00
movq 0x8(%rbx), %rsi
xorl %edi, %edi
movq %rsi, %rcx
shrq $0x30, %rcx
je 0xabf7
movl %esi, %edx
shrl $0x18, %edx
addq 0x30(%rbx), %rdx
xorl %r8d, %r8d
movl $0x14105, %r9d          # imm = 0x14105
xorl %edi, %edi
movl (%rdx,%r8,4), %r10d
movl %r10d, %r11d
andl $0xf, %r11d
leal (%r10,%r10), %ebp
shrl $0x4, %r10d
btl %ebp, %r9d
movl $0x0, %ebp
cmovbl %r10d, %ebp
cmpl $0x5, %r11d
cmovel %r10d, %ebp
addl %ebp, %edi
incq %r8
cmpq %r8, %rcx
jne 0xabc5
movb $0x1, %r13b
cmpl %eax, %edi
jge 0xac04
jmp 0xac35
movq 0x8(%rbx), %rsi
movl %esi, %eax
shrl $0x10, %eax
movzbl %al, %eax
movb $0x1, %r13b
cmpl 0x46723(%rip), %eax     # 0x51338
jl 0xac35
movq %rsi, %rax
shrq $0x20, %rax
movzwl %ax, %eax
movl %eax, %ecx
notl %ecx
testl %ecx, 0x46705(%rip)     # 0x51330
jne 0xac35
testl %eax, 0x46701(%rip)     # 0x51334
je 0xac48
movzbl %r13b, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x466f9(%rip), %r15     # 0x51348
testq %r15, %r15
je 0xac89
movslq (%rbx), %rax
testq %rax, %rax
js 0xac89
movq 0x8(%r14), %rcx
movq (%rcx,%rax,8), %r12
movl 0x4(%rbx), %ebp
shrl $0x18, %esi
addq 0x30(%rbx), %rsi
movq %rbx, %rdi
callq 0x2343c
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
movl %eax, %ecx
callq 0x30e93
testl %eax, %eax
je 0xac35
movsd 0x457ff(%rip), %xmm0    # 0x50490
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xacee
movq 0x30(%rbx), %rcx
movsbl (%rcx), %eax
testl %eax, %eax
je 0xacc8
movb 0x1(%rcx), %dl
testb %dl, %dl
je 0xacca
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 0xacb1
jmp 0xacca
xorl %eax, %eax
addl 0x46658(%rip), %eax     # 0x51328
andl $0xffffff, %eax         # imm = 0xFFFFFF
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd 0x35434(%rip), %xmm1    # 0x40118
ucomisd %xmm0, %xmm1
jae 0xac35
movq 0x4666b(%rip), %rax     # 0x51360
orq 0x46654(%rip), %rax     # 0x51350
je 0xad4c
leaq 0x3708c(%rip), %rsi     # 0x41d91
movq %rbx, %rdi
callq 0x22374
testq %rax, %rax
je 0xad4c
movq 0x46637(%rip), %rdi     # 0x51350
testq %rdi, %rdi
je 0xad26
incq %rax
movq %rax, %rsi
jmp 0xad74
movq 0x46633(%rip), %r15     # 0x51360
testq %r15, %r15
je 0xad4c
incq %rax
movq %r15, %rdi
movq %rax, %rsi
callq 0xb1c5
cmpl (%r15), %eax
sete %r13b
jmp 0xac35
cmpq $0x0, 0x465ec(%rip)     # 0x51340
je 0xad84
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2619d
testq %rax, %rax
je 0xac35
movq 0x465cf(%rip), %rsi     # 0x51340
movq %rax, %rdi
callq 0x35a0
testl %eax, %eax
setne %r13b
jmp 0xac35
xorl %r13d, %r13d
jmp 0xac35