// File: /workspace/github_cpp_makefile_star2_O1/shangjingbo1226[P]MACFP/src/methods/MACFP.cpp
// Function: enumerateEdit(int, int, int, int, int, int, int, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>&)
bool enumerateEdit(int ptr, int length, int l, int r, int left, int right, int remainDist, vector<PII> &ret)
{
    if (remainDist == 0 && left == right) {
        return false;
    }
    if (ptr == r + 1) {
        ULL key = (left * MAGIC + right) * MAGIC + length;
        if (checked.count(key)) {
            return false;
        }
        checked.insert(key);
        for (int i = left; i <= right; ++ i) {
            int start = s->sa->sa[i];
            int end = s->sa->sa[i] + length - 1;
            if (max(start, l) > min(end, r)) {
                ret.push_back(make_pair(start, end));
            }
        }
        if (makeMaximal(ret).size() >= MIN_SUP) {
            return true;
        }
    }
    int last[alphabet.size()];
    for (int i = 0; i < alphabet.size(); ++ i) {
        int l = (i == 0) ? left - 1 : last[i - 1];
        int r = right + 1;
        while (l + 1 < r) {
            int mid = l + r >> 1;
            int index = s->sa->sa[mid] + length;
            if (index < s->size() && alphabet[i] < s->s[index]) {
                r = mid;
            } else {
                l = mid;
            }
        }
        last[i] = l;
    }
    for (int i = 0; i < alphabet.size(); ++ i) {
        int new_left = (i == 0) ? left : last[i - 1] + 1;
        while (s->sa->sa[new_left] + length == s->size()) {
            ++ new_left;
        }
        int new_right = last[i];

        if (new_left > new_right) {
            continue;
        }
        myAssert(s->s[s->sa->sa[new_left] + length] == alphabet[i], "index error");
        myAssert(s->s[s->sa->sa[new_right] + length] == alphabet[i], "index error");

        // replace
        if (ptr <= r && remainDist >= (s->s[ptr] != alphabet[i])) {
            if (enumerateEdit(ptr + 1, length + 1, l, r, new_left, new_right, remainDist - (s->s[ptr] != alphabet[i]), ret)) {
                return true;
            }
        }
        //insert
        if (remainDist > 0) {
            if (enumerateEdit(ptr, length + 1, l, r, new_left, new_right, remainDist - 1, ret)) {
                return true;
            }
        }
    }
    // delete
    if (remainDist > 0 && ptr <= r) {
        if (enumerateEdit(ptr + 1, length, l, r, left, right, remainDist - 1, ret)) {
            return true;
        }
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %edx, -0x34(%rbp)
movl 0x10(%rbp), %edx
movl %r8d, %eax
xorl %r9d, %eax
orl %edx, %eax
jne 0x456e
xorl %eax, %eax
jmp 0x4a34
movq %rcx, -0x50(%rbp)
incl %ecx
movq %rsi, -0x78(%rbp)
movslq %esi, %r15
movq %rdi, -0x48(%rbp)
cmpl %edi, %ecx
movq %r9, -0x68(%rbp)
movq %r8, -0x40(%rbp)
jne 0x46af
movq %r9, %r14
movslq %r8d, %rbx
imulq $0xabcdef, %rbx, %rax   # imm = 0xABCDEF
movslq %r14d, %rcx
addq %rax, %rcx
imulq $0xabcdef, %rcx, %rax   # imm = 0xABCDEF
addq %r15, %rax
leaq -0xc0(%rbp), %rsi
movq %rax, (%rsi)
leaq 0x5f67e83(%rip), %r12   # 0x5f6c440
movq %r12, %rdi
movq %r8, %r13
callq 0x8b80
testq %rax, %rax
sete %al
jne 0x4a34
movl %eax, -0x2c(%rbp)
leaq -0xf8(%rbp), %rdx
movq %r12, (%rdx)
leaq -0xc0(%rbp), %rsi
movq %r12, %rdi
callq 0x8bfc
cmpl %r14d, %r13d
jg 0x4661
movq %r13, %rcx
movq -0x78(%rbp), %rax
leal -0x1(%rax), %r14d
movq -0x68(%rbp), %rax
movl %eax, %r13d
subl %ecx, %r13d
incl %r13d
leaq -0xf8(%rbp), %r12
movq 0x5f67d4d(%rip), %rax   # 0x5f6c368
movq 0x20(%rax), %rax
movq 0x28(%rax), %rax
movl (%rax,%rbx,4), %eax
leal (%r14,%rax), %ecx
movl -0x34(%rbp), %edx
cmpl %edx, %eax
cmovgl %eax, %edx
movq -0x50(%rbp), %rsi
cmpl %esi, %ecx
cmovll %ecx, %esi
cmpl %esi, %edx
jle 0x4659
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, -0xf8(%rbp)
movq 0x18(%rbp), %rdi
movq %r12, %rsi
callq 0x8e7a
incq %rbx
decl %r13d
jne 0x4614
leaq -0xf8(%rbp), %r12
movq %r12, %rdi
movq 0x18(%rbp), %rsi
callq 0x27d5
movq (%r12), %rdi
movq 0x8(%r12), %rbx
subq %rdi, %rbx
sarq $0x3, %rbx
movslq 0x9b41(%rip), %r14      # 0xe1cc
testq %rdi, %rdi
je 0x469f
movq -0xe8(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
cmpq %r14, %rbx
movq -0x68(%rbp), %r9
movl -0x2c(%rbp), %eax
jae 0x4a34
movl %eax, -0x2c(%rbp)
movq %rsp, -0xa8(%rbp)
movq 0x5f67c90(%rip), %rax   # 0x5f6c350
movq %rsp, %r10
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r10
movq %r10, %rsp
movq 0x5f67c74(%rip), %rax   # 0x5f6c350
testq %rax, %rax
movq %r10, -0x70(%rbp)
je 0x4773
movq -0x40(%rbp), %rcx
decl %ecx
movl %ecx, -0x58(%rbp)
leal 0x1(%r9), %ecx
movl %ecx, -0x30(%rbp)
movq 0x5f67c68(%rip), %rsi   # 0x5f6c368
movq 0x5f67c41(%rip), %rdi   # 0x5f6c348
xorl %r8d, %r8d
movl -0x58(%rbp), %ecx
testq %r8, %r8
je 0x4717
movl -0x4(%r10,%r8,4), %ecx
cmpl %r9d, %ecx
jge 0x475f
movq 0x8(%rsi), %r10
movq 0x20(%rsi), %r11
movq 0x28(%r11), %r11
movl -0x30(%rbp), %edx
movl %edx, %ebx
leal (%rbx,%rcx), %r14d
sarl %r14d
movslq %r14d, %r12
movslq (%r11,%r12,4), %r12
addq %r15, %r12
cmpq %r12, %r10
jbe 0x4755
movb (%rdi,%r8), %r13b
movq (%rsi), %rdx
cmpb (%rdx,%r12), %r13b
jge 0x4755
movl %r14d, %ebx
jmp 0x4758
movl %r14d, %ecx
leal 0x1(%rcx), %edx
cmpl %ebx, %edx
jl 0x472d
movq -0x70(%rbp), %r10
movl %ecx, (%r10,%r8,4)
incq %r8
cmpq %rax, %r8
movq -0x68(%rbp), %r9
jne 0x470a
cmpq $0x0, 0x5f67bd5(%rip)   # 0x5f6c350
setne %r11b
je 0x49d8
leaq -0x90(%rbp), %r12
movq -0x48(%rbp), %rdi
movslq %edi, %rax
movq %rax, -0xb0(%rbp)
leal 0x1(%rdi), %eax
movl %eax, -0x7c(%rbp)
movq -0x78(%rbp), %rax
incl %eax
movl %eax, -0x5c(%rbp)
movl 0x10(%rbp), %eax
decl %eax
movq %rax, -0xb8(%rbp)
xorl %ebx, %ebx
movq -0x40(%rbp), %r8
movl %r8d, %edx
testq %rbx, %rbx
je 0x47ca
movl -0x4(%r10,%rbx,4), %edx
incl %edx
movq 0x5f67b97(%rip), %rax   # 0x5f6c368
movq 0x8(%rax), %rcx
movq 0x20(%rax), %rsi
movslq %edx, %rdx
leal -0x1(%rdx), %r13d
shlq $0x2, %rdx
addq 0x28(%rsi), %rdx
movslq (%rdx), %rsi
addq %r15, %rsi
incl %r13d
addq $0x4, %rdx
cmpq %rsi, %rcx
je 0x47e8
movslq (%r10,%rbx,4), %r14
movl $0xc, %ecx
movq %r14, -0x58(%rbp)
cmpl %r13d, %r14d
jl 0x49b9
movb %r11b, -0x30(%rbp)
movq (%rax), %rax
movb (%rax,%rsi), %al
movq 0x5f67b27(%rip), %rcx   # 0x5f6c348
xorl %r14d, %r14d
cmpb (%rcx,%rbx), %al
movq %r12, -0xa0(%rbp)
sete %r14b
leaq -0xa0(%rbp), %rdi
leaq 0x58d5(%rip), %rsi      # 0xa115
leaq 0x58d9(%rip), %rdx      # 0xa120
callq 0x809c
movl %r14d, %edi
leaq -0xa0(%rbp), %rsi
callq 0x28d7
movq -0xa0(%rbp), %rdi
cmpq %r12, %rdi
je 0x4876
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x21f0
movq 0x5f67aeb(%rip), %rax   # 0x5f6c368
movq (%rax), %rcx
movq 0x20(%rax), %rax
movq 0x28(%rax), %rax
movq -0x58(%rbp), %rdx
movslq (%rax,%rdx,4), %rax
addq %r15, %rax
movb (%rcx,%rax), %al
movq 0x5f67aab(%rip), %rcx   # 0x5f6c348
xorl %r14d, %r14d
cmpb (%rcx,%rbx), %al
leaq -0xd0(%rbp), %r12
movq %r12, -0xe0(%rbp)
sete %r14b
leaq -0xe0(%rbp), %rdi
leaq 0x5852(%rip), %rsi      # 0xa115
leaq 0x5856(%rip), %rdx      # 0xa120
callq 0x809c
movl %r14d, %edi
leaq -0xe0(%rbp), %rsi
callq 0x28d7
movq -0xe0(%rbp), %rdi
cmpq %r12, %rdi
je 0x48f9
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x21f0
movq -0x48(%rbp), %rdi
cmpl %edi, -0x50(%rbp)
movl 0x10(%rbp), %esi
jl 0x4965
movq 0x5f67a5c(%rip), %rax   # 0x5f6c368
movq (%rax), %rax
movq -0xb0(%rbp), %rcx
movb (%rax,%rcx), %al
movq 0x5f67a28(%rip), %rcx   # 0x5f6c348
movb (%rcx,%rbx), %cl
xorl %edx, %edx
cmpb %cl, %al
setne %dl
cmpl %esi, %edx
jg 0x4965
xorl %edx, %edx
cmpb %cl, %al
setne %dl
movl %esi, %eax
subl %edx, %eax
movl -0x7c(%rbp), %edi
movl -0x5c(%rbp), %esi
movl -0x34(%rbp), %edx
movq -0x50(%rbp), %rcx
movl %r13d, %r8d
movq -0x58(%rbp), %r9
pushq 0x18(%rbp)
pushq %rax
callq 0x4543
movq -0x48(%rbp), %rdi
movl 0x10(%rbp), %esi
addq $0x10, %rsp
testb %al, %al
jne 0x4998
testl %esi, %esi
jle 0x49a4
movq -0x48(%rbp), %rdi
movl -0x5c(%rbp), %esi
movl -0x34(%rbp), %edx
movq -0x50(%rbp), %rcx
movl %r13d, %r8d
movq -0x58(%rbp), %r9
pushq 0x18(%rbp)
pushq -0xb8(%rbp)
callq 0x4543
movq -0x48(%rbp), %rdi
addq $0x10, %rsp
testb %al, %al
je 0x49a4
movb $0x1, %al
movl %eax, -0x2c(%rbp)
movl $0x1, %ecx
jmp 0x49a6
xorl %ecx, %ecx
movq -0x40(%rbp), %r8
movq -0x70(%rbp), %r10
leaq -0x90(%rbp), %r12
movb -0x30(%rbp), %r11b
cmpl $0xc, %ecx
je 0x49c2
testl %ecx, %ecx
jne 0x49e0
incq %rbx
cmpq %rbx, 0x5f67984(%rip)   # 0x5f6c350
seta %r11b
ja 0x47bb
jmp 0x49e0
movq -0x40(%rbp), %r8
movq -0x48(%rbp), %rdi
testb $0x1, %r11b
movq -0x50(%rbp), %rcx
jne 0x4a2a
movl 0x10(%rbp), %eax
testl %eax, %eax
setle %al
cmpl %edi, %ecx
setl %dl
orb %al, %dl
jne 0x4a23
incl %edi
movl 0x10(%rbp), %eax
decl %eax
movq -0x78(%rbp), %rsi
movl -0x34(%rbp), %edx
movq -0x68(%rbp), %r9
pushq 0x18(%rbp)
pushq %rax
callq 0x4543
addq $0x10, %rsp
movb $0x1, %cl
movl %ecx, -0x2c(%rbp)
testb %al, %al
jne 0x4a2a
movl $0x0, -0x2c(%rbp)
movq -0xa8(%rbp), %rsp
movl -0x2c(%rbp), %eax
andb $0x1, %al
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
jmp 0x4a5b
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
movq %r12, %rax
cmpq %r12, %rdi
je 0x4a6e
movq (%rax), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x2330