// File: chhylp123[P]hifiasm/inter.cpp
// Function: ck_w_err(overlap_region*, unsigned long*, long, long)
uint32_t ck_w_err(overlap_region *z, uint64_t *w_idx, int64_t wl, int64_t ql)
{
	int64_t wid, k, wn = z->w_list.n, ws, we, ol, e[2];
	ol = e[0] = e[1] = 0;
	for (k = 0; k < wn; k++) {
		wid = z->w_list.a[k].x_start/wl;
		if(w_idx[wid] == (uint64_t)-1) continue;
		ws = wid*wl; we = ws+wl; if(we > ql) we = ql; we--;
		if(ws == z->w_list.a[k].x_start && we == z->w_list.a[k].x_end) {
			ol += we+1-ws; e[0] += w_idx[wid]; 
			if(z->w_list.a[k].y_end != -1) e[1] += z->w_list.a[k].error;
			else e[1] += THRESHOLD_MAX_SIZE + 1;
		}
	}
	// fprintf(stderr, "[M::%s::utg%.6dl] x::[%u, %u), ol::%ld, e[0]::%ld, e[1]::%ld\n", 
	// __func__, (int32_t)z->y_id+1, z->x_pos_s, z->x_pos_e+1, ol, e[0], e[1]);
	if(e[1] > (e[0]+64)) {
		if((e[1] > (e[0]+(ol*0.01)))/**||(e[1] > (e[0]+(e[0]*0.03)))**/) {
			z->non_homopolymer_errors = e[1] - e[0];
			return 0;
		}
	}
	// if((e[1] > (e[0]+16)) && (e[1] > (e[0]+(ol*0.01)))) return 0;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0x2ad070
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
cqto
idivq -0x20(%rbp)
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq $-0x1, (%rax,%rcx,8)
jne 0x2acf72
jmp 0x2ad05f
movq -0x30(%rbp), %rax
imulq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x28(%rbp), %rax
jle 0x2acf9d
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
cmpq %rcx, %rax
jne 0x2ad05d
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq 0x4(%rcx), %rcx
cmpq %rcx, %rax
jne 0x2ad05d
movq -0x50(%rbp), %rax
addq $0x1, %rax
subq -0x48(%rbp), %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x2ad04f
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswq 0x14(%rax), %rax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x2ad05b
movq -0x68(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x68(%rbp)
jmp 0x2ad05d
jmp 0x2ad05f
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2acf30
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rcx
addq $0x40, %rcx
cmpq %rcx, %rax
jle 0x2ad0c5
cvtsi2sdq -0x68(%rbp), %xmm0
cvtsi2sdq -0x70(%rbp), %xmm2
cvtsi2sdq -0x58(%rbp), %xmm1
movsd 0xde795(%rip), %xmm3    # 0x38b830
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2ad0c3
movq -0x68(%rbp), %rax
subq -0x70(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x30(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x2ad0cc
jmp 0x2ad0c5
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)