// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Correct.cpp
// Function: hpc_mask_ff_region(char*, long, long, long, long, long, long, double)
uint8_t hpc_mask_ff_region(char *sa, int64_t sn, int64_t s0, int64_t e0, int64_t hpc_flk, int64_t hpc_rr, int64_t hpc_cutoff, double hpc_rate)
{
    assert(e0>=s0);
    int64_t s = ((s0>=hpc_flk)?(s0-hpc_flk):0), e = (((e0+hpc_flk)<=sn)?(e0+hpc_flk):(sn)), k, r, rc, zs, ze, os, oe, ovlp; 

    for (r = 1; r <= hpc_rr; r++) {
        rc = r * (MAX(hpc_cutoff, hpc_rr));///hpc_cutoff = 6;
        
        ///inlcuding p
        for (k = ((e0>s0)?(e0-1):(e0))+r; (k < e) && ((k-r) >= s) && (sa[k] == sa[k-r]); k++); ze = k; if(ze > e) ze = e; 
        for (k = ((e0>s0)?(e0-1):(e0))-1; (k >= s) && ((k+r) < e) && (sa[k] == sa[k+r]); k--); zs = k + 1; if(zs < s) zs = s;
        if(((ze - zs) > r) && ((ze - zs) >= rc)) {
            os = MAX(zs, s0); oe = MIN(ze, e0);
	        ovlp = ((oe>os)? (oe-os):0);
            if(e0 > s0) {
                if(ovlp > 0 && (ovlp >= ((e0 - s0)*hpc_rate))) return 1;///hpc_rate = 0.51
            } else {
                if(zs <= s0 && ze >= e0) return 1;
            }
        } 

        ///do not inlcude p
        if(e0 <= s0) {
            for (k = e0 + r + 1; (k < e) && ((k-r) >= s) && (sa[k] == sa[k-r]); k++); 
            zs = e0 + 1; if(zs < s) zs = s; ze = k; if(ze > e) ze = e; 
            if(((ze - zs) > r) && ((ze - zs) >= rc)) {
                // fprintf(stderr, "-1-[M::%s] p::%ld, hh::[%ld,%ld), f::%u, %.*s\n", __func__, p, zs, ze, f?1:0, (int32_t)(ze - zs), sa + zs);
                return 1;
            }  
        }

        ///inlcuding p
        for (k = s0 - r; (k >= s) && ((k+r) < e) && (sa[k] == sa[k+r]); k--); zs = k + 1; if(zs < s) zs = s; 
        for (k = s0 + 1; (k < e) && ((k-r) >= s) && (sa[k] == sa[k-r]); k++); ze = k; if(ze > e) ze = e; 
        if(((ze - zs) > r) && ((ze - zs) >= rc)) {
            os = MAX(zs, s0); oe = MIN(ze, e0);
	        ovlp = ((oe>os)? (oe-os):0);
            if(e0 > s0) {
                if(ovlp > 0 && (ovlp >= ((e0 - s0)*hpc_rate))) return 1;
            } else {
                if(zs <= s0 && ze >= e0) return 1;
            }
        } 

        ///do not inlcude p
        if(e0 <= s0) {
            for (k = s0 - r - 1; (k >= s) && ((k+r) < e) && (sa[k] == sa[k+r]); k--); 
            zs = k + 1; if(zs < s) zs = s; ze = s0; if(ze > e) ze = e; 
            if(((ze - zs) > r) && ((ze - zs) >= rc)) {
                return 1;
            } 
        }
    }
    // fprintf(stderr, "-6-[M::%s] p::%ld, hh::[,), %.*s\n", __func__, p, (int32_t)(e - s), sa + s);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
cmpq %rdx, %rcx
jl 0x57cf1
xorl %eax, %eax
movq %rdx, %r11
subq %r8, %r11
movl $0x0, %r10d
cmovgeq %r11, %r10
addq %rcx, %r8
cmpq %rsi, %r8
cmovgeq %rsi, %r8
testq %r9, %r9
jle 0x57ce2
movq 0x90(%rsp), %rax
cmpq %r9, %rax
cmovleq %r9, %rax
movq %rax, 0x50(%rsp)
xorl %eax, %eax
movq %rcx, %r11
subq %rdx, %r11
setg %al
movq %rcx, %rsi
subq %rax, %rsi
cvtsi2sd %r11, %xmm1
leaq 0x1(%rcx), %rax
cmpq %r10, %rax
movq %r10, %r11
movq %rax, 0x48(%rsp)
cmovgq %rax, %r11
movq %r11, 0x40(%rsp)
cmpq %rdx, %r8
movq %rdx, %rax
cmovlq %r8, %rax
movq %rax, 0x38(%rsp)
cmpq %rsi, %r10
movq %rsi, %rax
cmovlq %r10, %rax
movq %rax, 0x28(%rsp)
leaq 0x1(%rdx), %rax
cmpq %rax, %r8
cmovgq %r8, %rax
mulsd %xmm0, %xmm1
movq %rax, 0x20(%rsp)
decq %rax
movq %rax, 0x18(%rsp)
leaq 0x2(%rcx), %rax
movq %rax, 0x8(%rsp)
leaq -0x1(%rdx), %rax
movq %rax, 0x30(%rsp)
movl $0x1, %r14d
xorl %r13d, %r13d
movq %rdi, %r15
movq %rcx, 0x10(%rsp)
movq %rdx, %rcx
leaq (%r14,%rsi), %rdx
cmpq %r8, %rdx
jge 0x57a7c
movq %rsi, %r11
cmpq %r10, %rsi
jl 0x57a7c
movb (%rdi,%rdx), %bl
cmpb (%rdi,%r11), %bl
jne 0x57a7c
incq %rdx
incq %r11
cmpq %r8, %rdx
jl 0x57a60
movq %r8, %rdx
movq %r14, %r11
imulq 0x50(%rsp), %r11
cmpq %r8, %rdx
cmovgeq %r8, %rdx
movq %rsi, %r12
cmpq %r10, %r12
jle 0x57aae
movq %r12, %rbx
decq %r12
leaq (%r12,%r14), %rbp
cmpq %r8, %rbp
jge 0x57ab3
movb (%rdi,%r12), %al
cmpb (%rdi,%rbp), %al
je 0x57a8f
jmp 0x57ab3
movq 0x28(%rsp), %rbx
cmpq %r10, %rbx
cmovleq %r10, %rbx
movq %rdx, %rax
subq %rbx, %rax
cmpq %r14, %rax
setle %bpl
cmpq %r11, %rax
setl %al
orb %bpl, %al
movq 0x10(%rsp), %rax
movq %rcx, %r12
je 0x57b6a
cmpq %r12, %rax
jg 0x57b37
movq 0x48(%rsp), %rbx
movq 0x8(%rsp), %r12
movq %r12, %rdx
cmpq %r8, %r12
jge 0x57b0d
cmpq %r10, %rbx
jl 0x57b0d
movb (%rdi,%rdx), %al
leaq 0x1(%rdx), %r12
leaq 0x1(%rbx), %rbp
cmpb (%rdi,%rbx), %al
movq %rbp, %rbx
je 0x57aed
leaq -0x1(%rdx), %rax
cmpq %r8, %rax
cmovgeq %r8, %rdx
subq 0x40(%rsp), %rdx
cmpq %r14, %rdx
setle %al
cmpq %r11, %rdx
setl %dl
orb %al, %dl
cmpb $0x1, %dl
movq %rcx, %r12
jne 0x57cdc
movq %r12, %rbx
subq %r14, %rbx
movq %rbx, %rdx
cmpq %r10, %rbx
jl 0x57bb0
movq %rcx, %r12
movq %rbx, %rbp
cmpq %rcx, %r8
jle 0x57bad
movb (%rdi,%rbp), %al
cmpb (%rdi,%r12), %al
jne 0x57bad
leaq -0x1(%rbp), %rdx
decq %r12
cmpq %r10, %rbp
movq %rdx, %rbp
jg 0x57b4b
jmp 0x57bb0
cmpq %r12, %rax
jle 0x57cb6
cmpq %rax, %rdx
cmovgeq %rax, %rdx
cmpq %r12, %rbx
cmovleq %r12, %rbx
subq %rbx, %rdx
movl $0x0, %ebx
cmovleq %rbx, %rdx
testq %rdx, %rdx
jle 0x57ade
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
ucomisd %xmm1, %xmm0
jb 0x57ade
jmp 0x57cdc
movq %rbp, %rdx
incq %rdx
cmpq %r10, %rdx
cmovleq %r10, %rdx
movq %rcx, %rbp
movq %rbp, %r12
incq %rbp
cmpq %r8, %rbp
jge 0x57bde
leaq (%r12,%r13), %rax
cmpq %r10, %rax
jl 0x57be8
movb 0x1(%rdi,%r12), %al
cmpb (%r15,%r12), %al
je 0x57bbd
jmp 0x57be8
movq 0x18(%rsp), %r12
movq 0x20(%rsp), %rbp
cmpq %r8, %r12
cmovgeq %r8, %rbp
movq %rbp, %rax
subq %rdx, %rax
cmpq %r14, %rax
setle %r12b
cmpq %r11, %rax
setl %al
orb %r12b, %al
movq 0x10(%rsp), %rax
movq %rcx, %r12
je 0x57c7a
cmpq %r12, %rax
jg 0x57c5d
movq 0x30(%rsp), %r12
movq %rbx, %rdx
cmpq %r10, %rbx
jle 0x57c3c
cmpq %r8, %r12
jge 0x57c3c
movb -0x1(%rdi,%rdx), %al
leaq -0x1(%r12), %rbp
leaq -0x1(%rdx), %rbx
cmpb (%rdi,%r12), %al
movq %rbp, %r12
je 0x57c19
cmpq %r10, %rdx
cmovleq %r10, %rdx
movq 0x38(%rsp), %rax
subq %rdx, %rax
cmpq %r14, %rax
setle %dl
cmpq %r11, %rax
setl %al
orb %dl, %al
cmpb $0x1, %al
jne 0x57cdc
leaq 0x1(%r14), %rax
incq 0x8(%rsp)
decq %r15
decq %r13
cmpq %r9, %r14
movq %rax, %r14
jne 0x57a54
jmp 0x57ce0
cmpq %r12, %rax
jle 0x57cca
cmpq %rax, %rbp
cmovgeq %rax, %rbp
cmpq %r12, %rdx
cmovleq %r12, %rdx
subq %rdx, %rbp
movl $0x0, %edx
cmovleq %rdx, %rbp
testq %rbp, %rbp
jle 0x57c0f
xorps %xmm0, %xmm0
cvtsi2sd %rbp, %xmm0
ucomisd %xmm1, %xmm0
jb 0x57c0f
jmp 0x57cdc
cmpq %r12, %rbx
jg 0x57ade
cmpq %rax, %rdx
jl 0x57ade
jmp 0x57cdc
cmpq %r12, %rdx
jg 0x57c0f
cmpq %rax, %rbp
jl 0x57c0f
movb $0x1, %al
jmp 0x57ce2
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1ce303(%rip), %rdi    # 0x225ffb
leaq 0x1cd944(%rip), %rsi    # 0x225643
leaq 0x1ce2fc(%rip), %rcx    # 0x226002
movl $0x28d8, %edx           # imm = 0x28D8
callq 0x2110