// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: update_ava_het_site(haplotype_evdience_alloc*, unsigned long, unsigned long*, unsigned long*, unsigned long)
uint64_t update_ava_het_site(haplotype_evdience_alloc *h, uint64_t oid, uint64_t *beg, uint64_t *end, uint64_t is_srt)
{
	uint64_t k, l, i, occ = 0, n = h->length, need_srt = 0; SnpStats *s = NULL;
	haplotype_evdience tt;
	l = beg? (*beg):0; if(end) (*end) = n; if(beg) (*beg) = n;
	if(l < n && h->list[l].overlapID > oid){
		if(end) (*end) = l;
		return 0;
	}
	for (k = l + 1; k <= n; ++k) {  
		if(h->list[l].overlapID > oid) {
			if(end) (*end) = l;
			break;
		}
        if (k == n || h->list[k].overlapID != h->list[l].overlapID) {
			if(h->list[l].overlapID == oid) {
				for (i = l; i < k; i++) {
					if(h->list[i].type!=1) continue; 
					s = &(h->snp_stat.a[h->list[i].overlapSite]);
					if(s->score == 1 && (!(s->occ_0 < 2 || s->occ_1 < 2))) {
						if(l+occ != i) {
							tt = h->list[l+occ];
							h->list[l+occ] = h->list[i];
							h->list[i] = tt;
						}
						if((occ>0) && (h->list[l+occ].cov<h->list[l+occ-1].cov)) need_srt = 1;
						occ++;
					}
				}
				if(beg) (*beg) = l;
				if(end) (*end) = k;
				break;
			}
            l = k;
        }
    }
	// if(oid == 160) {
	// 	fprintf(stderr, "###[M::%s] l:%lu, occ:%lu\n", __func__, l, occ);
	// 	for (k = l; k < l + occ; k++) {
	// 		fprintf(stderr, "h->list[%lu]:%u\n", k, h->list[k].cov);
	// 	}
	// }
	if(occ && is_srt && need_srt) {
		radix_sort_hap_ev_cov_srt(h->list+l, h->list+l+occ);
	}

	return occ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl 0x10(%rdi), %r11d
testq %rdx, %rdx
je 0x1a7f69
movq (%rdx), %r9
jmp 0x1a7f6c
xorl %r9d, %r9d
testq %rcx, %rcx
je 0x1a7f74
movq %r11, (%rcx)
testq %rdx, %rdx
je 0x1a7f7c
movq %r11, (%rdx)
cmpq %r11, %r9
jae 0x1a7f9c
movq (%rdi), %rax
leaq (%r9,%r9,2), %r10
movl 0x4(%rax,%r10,8), %eax
cmpq %rsi, %rax
jbe 0x1a7f9c
testq %rcx, %rcx
je 0x1a7fa5
movq %r9, (%rcx)
jmp 0x1a7fa5
leaq 0x1(%r9), %r10
cmpq %r11, %r10
jbe 0x1a7fb9
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rdi), %r14
negq %r11
leaq (%r9,%r9,2), %rax
leaq (%r14,%rax,8), %r15
addq $0x1c, %r15
xorl %ebx, %ebx
leaq (%r9,%r9,2), %rax
movl 0x4(%r14,%rax,8), %r12d
cmpq %rsi, %r12
ja 0x1a7f92
movq %r11, %r13
addq %r10, %r13
je 0x1a7fed
cmpl %r12d, (%r15)
jne 0x1a7fed
movq %r9, %r13
jmp 0x1a7ff5
movq %r10, %r13
cmpq %rsi, %r12
je 0x1a800e
leaq (%r11,%r10), %rax
incq %rax
incq %r10
addq $0x18, %r15
movq %r13, %r9
cmpq $0x1, %rax
jne 0x1a7fcd
jmp 0x1a7fa7
cmpq %r10, %r9
jae 0x1a811d
leaq (,%r9,8), %rsi
leaq (%rsi,%rsi,2), %r11
movq $0x0, 0x8(%rsp)
xorl %ebx, %ebx
movq %r9, %r15
movq (%rdi), %r12
cmpb $0x1, 0xc(%r12,%r11)
jne 0x1a8101
movq 0x218(%rdi), %r13
movl 0x8(%r12,%r11), %ebp
leaq (%rbp,%rbp,4), %rbp
cmpl $0x1, 0x1c(%r13,%rbp,8)
jne 0x1a8101
leaq (%r13,%rbp,8), %r13
cmpl $0x2, 0x8(%r13)
jb 0x1a8101
cmpl $0x2, 0xc(%r13)
jb 0x1a8101
leaq (%rbx,%r9), %r13
cmpq %r13, %r15
je 0x1a80cd
leaq (%r12,%r11), %rbp
leaq (,%r13,2), %r14
addq %r13, %r14
movq 0x10(%r12,%r14,8), %rsi
movq %rsi, 0x20(%rsp)
movups (%r12,%r14,8), %xmm0
movaps %xmm0, 0x10(%rsp)
movups (%rbp), %xmm0
movups %xmm0, (%r12,%r14,8)
movq 0x10(%rbp), %rsi
movq %rsi, 0x10(%r12,%r14,8)
movq (%rdi), %rsi
movq 0x20(%rsp), %r14
movq %r14, 0x10(%rsi,%r11)
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rsi,%r11)
testq %rbx, %rbx
je 0x1a80fe
movq (%rdi), %rsi
leaq (,%r13,2), %r14
addq %r13, %r14
movl 0x10(%rsi,%r14,8), %ebp
cmpl -0x8(%rsi,%r14,8), %ebp
movq 0x8(%rsp), %rsi
movl $0x1, %r14d
cmovbq %r14, %rsi
movq %rsi, 0x8(%rsp)
incq %rbx
incq %r15
addq $0x18, %r11
cmpq %r10, %r15
jb 0x1a8031
cmpq $0x0, 0x8(%rsp)
setne %sil
jmp 0x1a8121
xorl %ebx, %ebx
xorl %esi, %esi
testq %rdx, %rdx
je 0x1a8129
movq %r9, (%rdx)
testq %rcx, %rcx
je 0x1a8131
movq %r10, (%rcx)
testq %rbx, %rbx
setne %cl
testq %r8, %r8
setne %dl
andb %cl, %dl
andb %sil, %dl
cmpb $0x1, %dl
jne 0x1a7fa7
shlq $0x3, %rax
addq (%rdi), %rax
leaq (%rbx,%rbx,2), %rcx
leaq (%rax,%rcx,8), %rsi
movq %rax, %rdi
callq 0x19f19b
jmp 0x1a7fa7