// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/inter.cpp
// Function: overlap_statistics(overlap_region_alloc*, ma_ug_t*, long*, unsigned char)
uint32_t overlap_statistics(overlap_region_alloc* olist, ma_ug_t *ug, int64_t *tt, uint8_t mm)
{
	uint32_t k, sp = (uint32_t)-1, ep = (uint32_t)-1, l = 0;
	for (k = 0; k < olist->length; k++) {
		/**
		if(b->olist.list[k].y_id != 38) continue;
		**/		
		/**
		
		for (z = 0, te = ta = tua = 0; z < b->olist.list[k].w_list_length; z++) {
			if(b->olist.list[k].w_list[z].y_end != -1) {
				te += b->olist.list[k].w_list[z].error;
				ta += b->olist.list[k].w_list[z].x_end + 1 - b->olist.list[k].w_list[z].x_start;
				fprintf(stderr, "x->[%lu, %lu), y->[%d, %d), e->%d\n", b->olist.list[k].w_list[z].x_start, b->olist.list[k].w_list[z].x_end+1, 
					b->olist.list[k].w_list[z].y_start, b->olist.list[k].w_list[z].y_end+1, b->olist.list[k].w_list[z].error);
			}
			else {
				tua += b->olist.list[k].w_list[z].x_end + 1 - b->olist.list[k].w_list[z].x_start;
			}
		}
		fprintf(stderr, "[M::utg%.6d%c::is_match:%u] x->[%u, %u); y->[%u, %u), ualigned->%u, e_rate->%f\n", b->olist.list[k].y_id+1, "lc"[s->ug->u.a[b->olist.list[k].y_id].circ], 
		b->olist.list[k].is_match == 1, b->olist.list[k].x_pos_s, b->olist.list[k].x_pos_e+1, b->olist.list[k].y_pos_s, b->olist.list[k].y_pos_e+1, tua, (float)te/(float)ta);
		**/
		if(tt){
			uint32_t z;
			for (z = 0; z < olist->list[k].w_list.n; z++) {
				if(olist->list[k].w_list.a[z].y_end != -1) {
					if(tt) *tt += olist->list[k].w_list.a[z].x_end+1-olist->list[k].w_list.a[z].x_start;
				}
			}
		}
		if(olist->list[k].is_match == mm) {
			if(sp == (uint32_t)-1 || ep < olist->list[k].x_pos_s) {
				if(sp != (uint32_t)-1) l += ep + 1 - sp;
				sp = olist->list[k].x_pos_s;
				ep = olist->list[k].x_pos_e;
			} else {
				ep = MAX(ep, olist->list[k].x_pos_e);
			}
			if(ug) {
				fprintf(stderr, "[M::utg%.6d%c::is_match->%u] rev->%u, x->[%u, %u), y->[%u, %u)\n", (int)olist->list[k].y_id+1, "lc"[ug->u.a[olist->list[k].y_id].circ], olist->list[k].is_match, 
				olist->list[k].y_pos_strand, olist->list[k].x_pos_s, olist->list[k].x_pos_e+1, olist->list[k].y_pos_s, olist->list[k].y_pos_e+1);
			}
		}
	}
	if(sp != (uint32_t)-1) l += ep + 1 - sp;
	return l;
}

// Assembly:
cmpq $0x0, 0x10(%rdi)
je 0x19f223
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebx
movq %rdx, %r14
movq %rsi, %r9
movq %rdi, %r12
addq $0x10, %rsi
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r13d, %r13d
movl $0x1, %eax
xorl %r10d, %r10d
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x19f187
movq (%r12), %rcx
imulq $0xa8, %r13, %rdx
cmpq $0x0, 0x48(%rcx,%rdx)
je 0x19f187
addq %rdx, %rcx
addq $0x48, %rcx
movq 0x10(%rcx), %rdx
movl $0x1, %r11d
xorl %edi, %edi
shlq $0x5, %rdi
cmpl $-0x1, 0xc(%rdx,%rdi)
je 0x19f17c
addq %rdx, %rdi
movl 0x4(%rdi), %r8d
subl (%rdi), %r8d
incl %r8d
movslq %r8d, %rdi
addq %rdi, (%r14)
movl %r11d, %edi
incl %r11d
cmpq %rdi, (%rcx)
ja 0x19f15e
movq (%r12), %rdi
imulq $0xa8, %r13, %rdx
movb 0x2c(%rdi,%rdx), %cl
cmpb %bl, %cl
jne 0x19f1c8
addq %rdx, %rdi
cmpl $-0x1, %r15d
je 0x19f1b0
cmpl 0x4(%rdi), %ebp
jae 0x19f1b9
addl %eax, %ebp
addl %ebp, %r10d
incl %r10d
movl 0x4(%rdi), %r15d
movl 0x8(%rdi), %ebp
jmp 0x19f1c3
movl 0x8(%rdi), %eax
cmpl %eax, %ebp
cmoval %ebp, %eax
movl %eax, %ebp
testq %r9, %r9
jne 0x19f1dd
incl %r13d
movl %r15d, %eax
negl %eax
cmpq %r13, 0x10(%r12)
ja 0x19f133
jmp 0x19f203
movzbl %cl, %edx
movq %r9, 0x10(%rsp)
movq %r10, 0x8(%rsp)
movq %rsi, (%rsp)
callq 0x29ebf
movq (%rsp), %rsi
movq 0x8(%rsp), %r10
movq 0x10(%rsp), %r9
jmp 0x19f1c8
subl %r15d, %ebp
incl %ebp
xorl %eax, %eax
cmpl $-0x1, %r15d
cmovnel %ebp, %eax
addl %r10d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq