// File: /workspace/github_cpp_makefile_star2_O2/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 $0x48, %rsp
cmpq %rdx, %rcx
jl 0x283b3
movq %rdx, %r11
xorl %ebx, %ebx
movq %rdx, %r10
subq %r8, %r10
cmovlq %rbx, %r10
addq %rcx, %r8
cmpq %rsi, %r8
cmovgeq %rsi, %r8
movq 0x80(%rsp), %rax
cmpq %r9, %rax
cmovleq %r9, %rax
movq %rax, 0x40(%rsp)
xorl %eax, %eax
movq %rcx, %rdx
subq %r11, %rdx
setg %al
movq %rcx, %rsi
cvtsi2sd %rdx, %xmm1
subq %rax, %rsi
mulsd %xmm0, %xmm1
leaq 0x1(%rcx), %rax
cmpq %r10, %rax
movq %r10, %rdx
movq %rax, 0x30(%rsp)
cmovgq %rax, %rdx
movq %rdx, 0x28(%rsp)
cmpq %r11, %r8
movq %r11, %rax
cmovlq %r8, %rax
movq %rax, 0x20(%rsp)
cmpq %rsi, %r10
movq %rsi, %rax
cmovlq %r10, %rax
movq %rax, 0x10(%rsp)
leaq 0x1(%r11), %rax
cmpq %rax, %r8
cmovgq %r8, %rax
movq %rax, 0x8(%rsp)
testq %r9, %r9
cmovleq %rbx, %r9
incq %r9
leaq 0x2(%rcx), %rax
movq %rax, (%rsp)
leaq -0x1(%r11), %rax
movq %rax, 0x18(%rsp)
pushq $0x1
popq %rax
xorl %r12d, %r12d
movq %rdi, %r13
movq %r9, 0x38(%rsp)
cmpq %r9, %rax
je 0x283a2
movq %rax, %r15
imulq 0x40(%rsp), %r15
leaq (%rax,%rsi), %rdx
movq %rsi, %rbx
cmpq %r8, %rdx
jge 0x28189
cmpq %r10, %rbx
jl 0x28189
movb (%rdi,%rdx), %bpl
cmpb (%rdi,%rbx), %bpl
jne 0x28189
incq %rdx
incq %rbx
jmp 0x2816d
cmpq %r8, %rdx
cmovgeq %r8, %rdx
movq %rsi, %r14
cmpq %r10, %r14
jle 0x281b3
movq %r14, %rbx
decq %r14
leaq (%r14,%rax), %rbp
cmpq %r8, %rbp
jge 0x281b8
movb (%rdi,%r14), %r9b
cmpb (%rdi,%rbp), %r9b
je 0x28193
jmp 0x281b8
movq 0x10(%rsp), %rbx
cmpq %r10, %rbx
cmovleq %r10, %rbx
movq %rdx, %r9
subq %rbx, %r9
cmpq %rax, %r9
setle %bpl
cmpq %r15, %r9
setl %r9b
orb %bpl, %r9b
je 0x281e2
cmpq %r11, %rcx
jle 0x28225
jmp 0x28279
cmpq %r11, %rcx
jle 0x28217
cmpq %rcx, %rdx
cmovgeq %rcx, %rdx
cmpq %r11, %rbx
cmovleq %r11, %rbx
subq %rbx, %rdx
movl $0x0, %r9d
cmovleq %r9, %rdx
testq %rdx, %rdx
jle 0x28279
cvtsi2sd %rdx, %xmm0
ucomisd %xmm1, %xmm0
jb 0x28279
jmp 0x2839e
cmpq %r11, %rbx
jg 0x28225
cmpq %rcx, %rdx
jge 0x2839e
movq 0x30(%rsp), %rbx
movq (%rsp), %r14
movq %r14, %rdx
cmpq %r8, %r14
jge 0x28250
cmpq %r10, %rbx
jl 0x28250
movb (%rdi,%rdx), %r9b
leaq 0x1(%rdx), %r14
leaq 0x1(%rbx), %rbp
cmpb (%rdi,%rbx), %r9b
movq %rbp, %rbx
je 0x2822e
leaq -0x1(%rdx), %r9
cmpq %r8, %r9
cmovgeq %r8, %rdx
subq 0x28(%rsp), %rdx
cmpq %rax, %rdx
setle %r9b
cmpq %r15, %rdx
setl %dl
orb %r9b, %dl
cmpb $0x1, %dl
jne 0x2839e
movq %r11, %rbx
subq %rax, %rbx
movq %r11, %r14
movq %rbx, %rdx
cmpq %r10, %rdx
jl 0x282a1
cmpq %r8, %r14
jge 0x282a1
movb (%rdi,%rdx), %r9b
cmpb (%rdi,%r14), %r9b
jne 0x282a1
decq %rdx
decq %r14
jmp 0x28285
incq %rdx
cmpq %r10, %rdx
cmovleq %r10, %rdx
movq %r11, %rbp
movq %rbp, %r14
incq %rbp
cmpq %r8, %rbp
jge 0x282d0
leaq (%r12,%r14), %r9
cmpq %r10, %r9
jl 0x282d5
movb 0x1(%rdi,%r14), %r9b
cmpb (%r13,%r14), %r9b
je 0x282ae
jmp 0x282d5
movq 0x8(%rsp), %rbp
cmpq %r8, %r14
cmovgeq %r8, %rbp
movq %rbp, %r9
subq %rdx, %r9
cmpq %rax, %r9
setle %r14b
cmpq %r15, %r9
setl %r9b
orb %r14b, %r9b
je 0x282ff
cmpq %r11, %rcx
jle 0x2833a
jmp 0x28387
cmpq %r11, %rcx
jle 0x28330
cmpq %rcx, %rbp
cmovgeq %rcx, %rbp
cmpq %r11, %rdx
cmovleq %r11, %rdx
subq %rdx, %rbp
movl $0x0, %edx
cmovleq %rdx, %rbp
testq %rbp, %rbp
jle 0x28387
cvtsi2sd %rbp, %xmm0
ucomisd %xmm1, %xmm0
jb 0x28387
jmp 0x2839e
cmpq %r11, %rdx
jg 0x2833a
cmpq %rcx, %rbp
jge 0x2839e
movq 0x18(%rsp), %r14
movq %rbx, %rdx
cmpq %r10, %rbx
jle 0x28362
cmpq %r8, %r14
jge 0x28362
movb -0x1(%rdi,%rdx), %r9b
leaq -0x1(%r14), %rbp
leaq -0x1(%rdx), %rbx
cmpb (%rdi,%r14), %r9b
movq %rbp, %r14
je 0x2833f
cmpq %r10, %rdx
cmovleq %r10, %rdx
movq 0x20(%rsp), %r9
subq %rdx, %r9
cmpq %rax, %r9
setle %dl
cmpq %r15, %r9
setl %r9b
orb %dl, %r9b
cmpb $0x1, %r9b
jne 0x2839e
incq %rax
incq (%rsp)
decq %r13
decq %r12
movq 0x38(%rsp), %r9
jmp 0x28154
movb $0x1, %al
jmp 0x283a4
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1bbca1(%rip), %rdi    # 0x1e405b
leaq 0x1bb2e2(%rip), %rsi    # 0x1e36a3
leaq 0x1bbc9a(%rip), %rcx    # 0x1e4062
movl $0x28d8, %edx           # imm = 0x28D8
callq 0x2110