// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/bam2bedGraph.c
// Function: fetch_func
int fetch_func(const bam1_t *b, void *data) {
	DataBuf *databuf=(DataBuf *)data;
	uint32_t *cigar = bam1_cigar(b);
	const bam1_core_t *c = &b->core;
	if (c->flag&BAM_DEF_MASK || b->core.tid < 0) return 0;
	int i, l;
	unsigned int temp_start= c->pos;
	for (i = l = 0; i < c->n_cigar; ++i) {
		int op = bam_cigar_op(cigar[i]);
		if (op == BAM_CINS) continue;
		if ( op == BAM_CDEL || op == BAM_CREF_SKIP){
			l = bam_cigar_oplen(cigar[i]);
			temp_start+=l;
		}
		else if (op == BAM_CMATCH ) {
			l = bam_cigar_oplen(cigar[i]);
			insertInt2Hash(databuf->Start,temp_start);
			temp_start+=l;
			insertInt2Hash(databuf->End,temp_start);
		}
	}
	databuf->chrRC[c->tid]++;
	databuf->chrReadLen[c->tid]+=l;
	return 0;
}

// Assembly:
movq 0x8(%rdi), %rcx
movabsq $0x70400000000, %rax    # imm = 0x70400000000
testq %rax, %rcx
jne 0x4d39
movl (%rdi), %edx
testl %edx, %edx
js 0x4d39
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorl %eax, %eax
movq %rcx, %r8
shrq $0x30, %r8
je 0x4d16
movl %ecx, %r13d
shrl $0x18, %r13d
addq 0x30(%rdi), %r13
movl 0x4(%rdi), %ebp
xorl %r14d, %r14d
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movl (%r13,%r14,4), %ebx
movl %ebx, %edx
andl $0xf, %edx
cmpl $0x1, %edx
je 0x4cff
movl %ebx, %r8d
andl $0xe, %r8d
cmpl $0x2, %r8d
jne 0x4b88
shrl $0x4, %ebx
addl %ebx, %ebp
movl %ebx, %eax
jmp 0x4cff
testl %edx, %edx
jne 0x4cff
movw $0x4, %r12w
cmpl $0xffffff, %ebp         # imm = 0xFFFFFF
ja 0x4bba
movw $0x3, %r12w
cmpl $0xffff, %ebp           # imm = 0xFFFF
ja 0x4bba
cmpl $0x100, %ebp            # imm = 0x100
movw $0x1, %r12w
sbbw $-0x1, %r12w
shrl $0x4, %ebx
movq 0x8(%rsi), %rax
movq %rax, (%rsp)
movzwl %r12w, %esi
xorl %edi, %edi
callq 0x548c
movq %rax, %r15
leal -0x1(%r12), %eax
movzwl %ax, %ecx
leaq -0x1(%rcx), %rax
shll $0x3, %ecx
movq %rax, %rdx
movl %ebp, %esi
shrl %cl, %esi
movb %sil, 0x1(%r15,%rax)
decq %rdx
addl $-0x8, %ecx
testw %ax, %ax
movq %rdx, %rax
jns 0x4be5
movq (%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x6a2d
testq %rax, %rax
je 0x4c18
movq 0x8(%rax), %rax
incl (%rax)
jmp 0x4c36
movl $0x4, %edi
callq 0x3440
movl $0x1, (%rax)
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x68b9
movq %r15, %rdi
callq 0x559b
addl %ebx, %ebp
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, (%rsp)
movw $0x4, %r15w
cmpl $0xffffff, %ebp         # imm = 0xFFFFFF
ja 0x4c77
movw $0x3, %r15w
cmpl $0xffff, %ebp           # imm = 0xFFFF
ja 0x4c77
cmpl $0x100, %ebp            # imm = 0x100
movw $0x1, %r15w
sbbw $-0x1, %r15w
movzwl %r15w, %esi
xorl %edi, %edi
callq 0x548c
movq %rax, %r12
leal -0x1(%r15), %eax
movzwl %ax, %ecx
leaq -0x1(%rcx), %rax
shll $0x3, %ecx
movq %rax, %rdx
movl %ebp, %esi
shrl %cl, %esi
movb %sil, 0x1(%r12,%rax)
decq %rdx
addl $-0x8, %ecx
testw %ax, %ax
movq %rdx, %rax
jns 0x4c96
movq (%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x6a2d
testq %rax, %rax
je 0x4cc9
movq 0x8(%rax), %rax
incl (%rax)
jmp 0x4ce7
movl $0x4, %edi
callq 0x3440
movl $0x1, (%rax)
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x68b9
movq %r12, %rdi
callq 0x559b
movq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rcx
movl %ebx, %eax
movq 0x8(%rsp), %rsi
incq %r14
movq %rcx, %rdx
shrq $0x30, %rdx
cmpq %rdx, %r14
jb 0x4b5c
movl (%rdi), %edx
movl %eax, %eax
movq 0x18(%rsi), %rcx
movslq %edx, %rdx
incl (%rcx,%rdx,4)
movq 0x20(%rsi), %rcx
movslq (%rdi), %rdx
addq %rax, (%rcx,%rdx,8)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %eax, %eax
retq