// File: chhylp123[P]hifiasm/inter.cpp
// Function: get_high_simi(overlap_region*, double, unsigned long, unsigned long, unsigned long*, unsigned long*)
uint64_t get_high_simi(overlap_region *z, double erate, uint64_t maxe, uint64_t minov, uint64_t *re0, uint64_t *re1)
{
	uint64_t ol, err = z->non_homopolymer_errors, e0, e1, f0 = 0, f1 = 0;
	ol = z->x_pos_e+1-z->x_pos_s; (*re0) = (*re1) = (uint64_t)-1;
	if(ol > (z->y_pos_e+1-z->y_pos_s)) ol = z->y_pos_e+1-z->y_pos_s;
	if((err <= (ol*erate)) && (err <= maxe)) return 1;
	if(ol <= minov) return 0;///too short
	e0 = cal_cigar_err(z, 0, minov, 0);
	e1 = cal_cigar_err(z, z->x_pos_e+1-minov, z->x_pos_e+1, 1);
	if((e0 <= (minov*erate)) && (e0 <= maxe)) f0 = 1;
	if((e1 <= (minov*erate)) && (e1 <= maxe)) f1 = 1;
	if(f0 && f1 && (ol <= (minov<<1))) {
		if(e0 >= e1) f0 = 0;
		else f1 = 0;
	}
	if((!f0) && (!f1)) return 0;
	if(f0) (*re0) = e0;
	if(f1) (*re1) = e1;
	return 2; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movq %rax, -0x48(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq $-0x1, (%rax)
movq -0x30(%rbp), %rax
movq $-0x1, (%rax)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x18(%rcx), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rdx
subl 0x14(%rdx), %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jbe 0x2c398c
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
subl 0x14(%rcx), %eax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %xmm1
movaps 0xbe678(%rip), %xmm3    # 0x382010
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xbe67c(%rip), %xmm2    # 0x382020
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq -0x40(%rbp), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
mulsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x2c39ed
movq -0x48(%rbp), %rax
cmpq -0x20(%rbp), %rax
ja 0x2c39ed
movq $0x1, -0x8(%rbp)
jmp 0x2c3b77
movq -0x40(%rbp), %rax
cmpq -0x28(%rbp), %rax
ja 0x2c3a04
movq $0x0, -0x8(%rbp)
jmp 0x2c3b77
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
callq 0x2c2f20
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movl 0x8(%rdi), %eax
incl %eax
movl %eax, %edx
movq -0x28(%rbp), %rax
movq %rdx, %rsi
subq %rax, %rsi
movl $0x1, %ecx
callq 0x2c2f20
movq %rax, -0x58(%rbp)
movaps 0xbe5ca(%rip), %xmm3    # 0x382010
movq -0x50(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xbe5c9(%rip), %xmm2    # 0x382020
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq -0x28(%rbp), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
mulsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x2c3a9b
movq -0x50(%rbp), %rax
cmpq -0x20(%rbp), %rax
ja 0x2c3a9b
movq $0x1, -0x60(%rbp)
movq -0x58(%rbp), %xmm1
movaps 0xbe569(%rip), %xmm3    # 0x382010
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xbe56d(%rip), %xmm2    # 0x382020
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq -0x28(%rbp), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
mulsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x2c3af7
movq -0x58(%rbp), %rax
cmpq -0x20(%rbp), %rax
ja 0x2c3af7
movq $0x1, -0x68(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x2c3b33
cmpq $0x0, -0x68(%rbp)
je 0x2c3b33
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
shlq %rcx
cmpq %rcx, %rax
ja 0x2c3b33
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jb 0x2c3b29
movq $0x0, -0x60(%rbp)
jmp 0x2c3b31
movq $0x0, -0x68(%rbp)
jmp 0x2c3b33
cmpq $0x0, -0x60(%rbp)
jne 0x2c3b4b
cmpq $0x0, -0x68(%rbp)
jne 0x2c3b4b
movq $0x0, -0x8(%rbp)
jmp 0x2c3b77
cmpq $0x0, -0x60(%rbp)
je 0x2c3b5d
movq -0x50(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, -0x68(%rbp)
je 0x2c3b6f
movq -0x58(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq $0x2, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)