// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movabsq $0x70400000000, %rax    # imm = 0x70400000000
testq %rax, %rdi
jne 0x4a42
cmpl $0x0, (%rbx)
js 0x4a42
xorl %eax, %eax
cmpw $0x0, 0xe(%rbx)
je 0x4a2d
shrl $0x18, %edi
addq 0x30(%rbx), %rdi
movl 0x4(%rbx), %ebp
xorl %r14d, %r14d
movq %rsi, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movl (%rdi,%r14,4), %r13d
movl %r13d, %ecx
andl $0xf, %ecx
cmpl $0x1, %ecx
je 0x4a1b
movl %r13d, %edx
andl $0xe, %edx
cmpl $0x2, %edx
jne 0x48a5
shrl $0x4, %r13d
addl %r13d, %ebp
movl %r13d, %eax
jmp 0x4a1b
testl %ecx, %ecx
jne 0x4a1b
movw $0x4, %r12w
cmpl $0xffffff, %ebp         # imm = 0xFFFFFF
ja 0x48d7
movw $0x3, %r12w
cmpl $0xffff, %ebp           # imm = 0xFFFF
ja 0x48d7
cmpl $0x100, %ebp            # imm = 0x100
movw $0x1, %r12w
sbbw $-0x1, %r12w
shrl $0x4, %r13d
movq 0x8(%rsi), %rax
movq %rax, (%rsp)
movzwl %r12w, %esi
xorl %edi, %edi
callq 0x51a0
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 0x4903
movq (%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x6776
testq %rax, %rax
je 0x4936
movq 0x8(%rax), %rax
incl (%rax)
jmp 0x4954
movl $0x4, %edi
callq 0x3440
movl $0x1, (%rax)
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x6601
movq %r15, %rdi
callq 0x5261
addl %r13d, %ebp
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, (%rsp)
movw $0x4, %r15w
cmpl $0xffffff, %ebp         # imm = 0xFFFFFF
ja 0x4996
movw $0x3, %r15w
cmpl $0xffff, %ebp           # imm = 0xFFFF
ja 0x4996
cmpl $0x100, %ebp            # imm = 0x100
movw $0x1, %r15w
sbbw $-0x1, %r15w
movzwl %r15w, %esi
xorl %edi, %edi
callq 0x51a0
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 0x49b5
movq (%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x6776
testq %rax, %rax
je 0x49e8
movq 0x8(%rax), %rax
incl (%rax)
jmp 0x4a06
movl $0x4, %edi
callq 0x3440
movl $0x1, (%rax)
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x6601
movq %r12, %rdi
callq 0x5261
movl %r13d, %eax
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdi
incq %r14
movzwl 0xe(%rbx), %ecx
cmpq %rcx, %r14
jb 0x4878
movl %eax, %eax
movq 0x18(%rsi), %rcx
movslq (%rbx), %rdx
incl (%rcx,%rdx,4)
movq 0x20(%rsi), %rcx
movslq (%rbx), %rdx
addq %rax, (%rcx,%rdx,8)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq