// File: /workspace/github_cpp_makefile_star2_O3/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 0x5714b
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 0x5713c
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, 0x10(%rsp)
leaq -0x1(%rdx), %rax
movq %rax, 0x30(%rsp)
movl $0x1, %r14d
xorl %r13d, %r13d
movq %rdi, %r15
movq %rcx, 0x8(%rsp)
movq %rdx, %rcx
leaq (%r14,%rsi), %rdx
cmpq %r8, %rdx
jge 0x56eeb
movq %rsi, %r11
cmpq %r10, %rsi
jl 0x56eeb
movb (%rdi,%rdx), %bl
cmpb (%rdi,%r11), %bl
jne 0x56eeb
incq %rdx
incq %r11
cmpq %r8, %rdx
jl 0x56ecf
movq %r8, %rdx
movq %r14, %r11
imulq 0x50(%rsp), %r11
cmpq %r8, %rdx
cmovgeq %r8, %rdx
movq %rsi, %r12
cmpq %r10, %r12
jle 0x56f1d
movq %r12, %rbx
decq %r12
leaq (%r12,%r14), %rbp
cmpq %r8, %rbp
jge 0x56f22
movb (%rdi,%r12), %al
cmpb (%rdi,%rbp), %al
je 0x56efe
jmp 0x56f22
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
je 0x56f50
movq %rcx, %r12
cmpq %rcx, 0x8(%rsp)
jle 0x56f9f
jmp 0x56ff3
movq 0x8(%rsp), %rax
movq %rcx, %r12
cmpq %rcx, %rax
jle 0x56f8f
cmpq %rax, %rdx
cmovgeq %rax, %rdx
cmpq %r12, %rbx
cmovleq %r12, %rbx
subq %rbx, %rdx
movl $0x0, %eax
cmovleq %rax, %rdx
testq %rdx, %rdx
jle 0x56ff3
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
ucomisd %xmm1, %xmm0
jb 0x56ff3
jmp 0x5713a
cmpq %r12, %rbx
jg 0x56f9f
cmpq 0x8(%rsp), %rdx
jge 0x5713a
movq 0x48(%rsp), %rbx
movq 0x10(%rsp), %r12
movq %r12, %rdx
cmpq %r8, %r12
jge 0x56fc9
cmpq %r10, %rbx
jl 0x56fc9
movb (%rdi,%rdx), %al
leaq 0x1(%rdx), %r12
leaq 0x1(%rbx), %rbp
cmpb (%rdi,%rbx), %al
movq %rbp, %rbx
je 0x56fa9
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 0x5713a
movq %r12, %rbx
subq %r14, %rbx
movq %rbx, %rdx
cmpq %r10, %rbx
jl 0x57029
movq %rcx, %r12
movq %rbx, %rbp
cmpq %rcx, %r8
jle 0x57026
movb (%rdi,%rbp), %al
cmpb (%rdi,%r12), %al
jne 0x57026
leaq -0x1(%rbp), %rdx
decq %r12
cmpq %r10, %rbp
movq %rdx, %rbp
jg 0x57007
jmp 0x57029
movq %rbp, %rdx
incq %rdx
cmpq %r10, %rdx
cmovleq %r10, %rdx
movq %rcx, %rbp
movq %rbp, %r12
incq %rbp
cmpq %r8, %rbp
jge 0x57057
leaq (%r12,%r13), %rax
cmpq %r10, %rax
jl 0x57061
movb 0x1(%rdi,%r12), %al
cmpb (%r15,%r12), %al
je 0x57036
jmp 0x57061
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
je 0x5708c
cmpq %rcx, 0x8(%rsp)
jle 0x570d2
jmp 0x5711b
movq 0x8(%rsp), %rax
movq %rcx, %r12
cmpq %rcx, %rax
jle 0x570c8
cmpq %rax, %rbp
cmovgeq %rax, %rbp
cmpq %r12, %rdx
cmovleq %r12, %rdx
subq %rdx, %rbp
movl $0x0, %eax
cmovleq %rax, %rbp
testq %rbp, %rbp
jle 0x5711b
xorps %xmm0, %xmm0
cvtsi2sd %rbp, %xmm0
ucomisd %xmm1, %xmm0
jb 0x5711b
jmp 0x5713a
cmpq %r12, %rdx
jg 0x570d2
cmpq %rax, %rbp
jge 0x5713a
movq 0x30(%rsp), %r12
movq %rbx, %rdx
cmpq %r10, %rbx
jle 0x570fa
cmpq %r8, %r12
jge 0x570fa
movb -0x1(%rdi,%rdx), %al
leaq -0x1(%r12), %rbp
leaq -0x1(%rdx), %rbx
cmpb (%rdi,%r12), %al
movq %rbp, %r12
je 0x570d7
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 0x5713a
leaq 0x1(%r14), %rax
incq 0x10(%rsp)
decq %r15
decq %r13
cmpq %r9, %r14
movq %rax, %r14
jne 0x56ec3
xorl %eax, %eax
jmp 0x5713c
movb $0x1, %al
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1dafb9(%rip), %rdi    # 0x23210b
leaq 0x1da5fa(%rip), %rsi    # 0x231753
leaq 0x1dafb2(%rip), %rcx    # 0x232112
movl $0x28d8, %edx           # imm = 0x28D8
callq 0x2110