// File: 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
subq $0x1b0, %rsp            # imm = 0x1B0
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movl %r9d, -0x1c(%rbp)
cmpl $0x0, 0x10(%rbp)
jne 0x68cd
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x68cd
movb $0x0, -0x1(%rbp)
jmp 0x7136
movl -0x8(%rbp), %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6a47
movslq -0x18(%rbp), %rax
imulq $0xabcdef, %rax, %rax   # imm = 0xABCDEF
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
imulq $0xabcdef, %rax, %rax   # imm = 0xABCDEF
movslq -0xc(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x5f80bd7(%rip), %rdi   # 0x5f874e0
leaq -0x28(%rbp), %rsi
callq 0x8f40
cmpq $0x0, %rax
je 0x6921
movb $0x0, -0x1(%rbp)
jmp 0x7136
leaq 0x5f80bb8(%rip), %rdi   # 0x5f874e0
leaq -0x28(%rbp), %rsi
callq 0x8f70
movq %rax, -0x38(%rbp)
movb %dl, -0x30(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x69f5
movq 0x5f80ab7(%rip), %rax   # 0x5f87408
movq 0x20(%rax), %rdi
addq $0x28, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x8590
movl (%rax), %eax
movl %eax, -0x40(%rbp)
movq 0x5f80a9a(%rip), %rax   # 0x5f87408
movq 0x20(%rax), %rdi
addq $0x28, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x8590
movl (%rax), %eax
addl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x44(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x8be0
movl (%rax), %eax
movl %eax, -0xfc(%rbp)
leaq -0x44(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x8b30
movq %rax, %rcx
movl -0xfc(%rbp), %eax
cmpl (%rcx), %eax
jle 0x69e5
movq 0x18(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x8fe0
movq -0x108(%rbp), %rdi
movq %rax, -0x4c(%rbp)
leaq -0x4c(%rbp), %rsi
callq 0x8fb0
jmp 0x69e7
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x693e
movq 0x18(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x38e0
leaq -0x68(%rbp), %rdi
callq 0x80c0
movq %rax, -0x110(%rbp)
movslq 0x2284b(%rip), %rax     # 0x29264
movq %rax, -0x118(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x8170
movq -0x118(%rbp), %rcx
movq -0x110(%rbp), %rax
cmpq %rcx, %rax
jb 0x6a45
movb $0x1, -0x1(%rbp)
jmp 0x7136
jmp 0x6a47
leaq 0x5f8099a(%rip), %rdi   # 0x5f873e8
callq 0x31a0
movq %rax, %rcx
movq %rcx, %rax
movq %rsp, %rdx
movq %rdx, -0x70(%rbp)
leaq 0xf(,%rcx,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x120(%rbp)
movq %rcx, %rsp
movq %rax, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movslq -0x7c(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq 0x5f8094f(%rip), %rdi   # 0x5f873e8
callq 0x31a0
movq %rax, %rcx
movq -0x128(%rbp), %rax
cmpq %rcx, %rax
jae 0x6bdc
cmpl $0x0, -0x7c(%rbp)
jne 0x6ac5
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x12c(%rbp)
jmp 0x6ade
movq -0x120(%rbp), %rax
movl -0x7c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x12c(%rbp)
movl -0x12c(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
movl -0x80(%rbp), %eax
addl $0x1, %eax
cmpl -0x84(%rbp), %eax
jge 0x6bbd
movl -0x80(%rbp), %eax
addl -0x84(%rbp), %eax
sarl %eax
movl %eax, -0x88(%rbp)
movq 0x5f808eb(%rip), %rax   # 0x5f87408
movq 0x20(%rax), %rdi
addq $0x28, %rdi
movslq -0x88(%rbp), %rsi
callq 0x8590
movl (%rax), %eax
addl -0xc(%rbp), %eax
movl %eax, -0x8c(%rbp)
movslq -0x8c(%rbp), %rax
movq %rax, -0x138(%rbp)
movq 0x5f808b7(%rip), %rdi   # 0x5f87408
callq 0x8620
movq %rax, %rcx
movq -0x138(%rbp), %rax
cmpq %rcx, %rax
jae 0x6baf
movslq -0x7c(%rbp), %rsi
leaq 0x5f80878(%rip), %rdi   # 0x5f873e8
callq 0x32e0
movsbl (%rax), %eax
movl %eax, -0x13c(%rbp)
movq 0x5f80883(%rip), %rdi   # 0x5f87408
movslq -0x8c(%rbp), %rsi
callq 0x3490
movq %rax, %rcx
movl -0x13c(%rbp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jge 0x6baf
movl -0x88(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x6bb8
movl -0x88(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0x6af3
movq -0x120(%rbp), %rax
movl -0x80(%rbp), %edx
movslq -0x7c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x6a87
movl $0x0, -0x90(%rbp)
movslq -0x90(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq 0x5f807ed(%rip), %rdi   # 0x5f873e8
callq 0x31a0
movq %rax, %rcx
movq -0x148(%rbp), %rax
cmpq %rcx, %rax
jae 0x70c2
cmpl $0x0, -0x90(%rbp)
jne 0x6c27
movl -0x18(%rbp), %eax
movl %eax, -0x14c(%rbp)
jmp 0x6c46
movq -0x120(%rbp), %rax
movl -0x90(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
addl $0x1, %eax
movl %eax, -0x14c(%rbp)
movl -0x14c(%rbp), %eax
movl %eax, -0x94(%rbp)
movq 0x5f807af(%rip), %rax   # 0x5f87408
movq 0x20(%rax), %rdi
addq $0x28, %rdi
movslq -0x94(%rbp), %rsi
callq 0x8590
movl (%rax), %eax
addl -0xc(%rbp), %eax
cltq
movq %rax, -0x158(%rbp)
movq 0x5f80786(%rip), %rdi   # 0x5f87408
callq 0x8620
movq %rax, %rcx
movq -0x158(%rbp), %rax
cmpq %rcx, %rax
jne 0x6ca7
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x6c52
movq -0x120(%rbp), %rax
movslq -0x90(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x98(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x98(%rbp), %eax
jle 0x6cd1
jmp 0x70ae
movq 0x5f80730(%rip), %rax   # 0x5f87408
movq %rax, -0x170(%rbp)
movq 0x20(%rax), %rdi
addq $0x28, %rdi
movslq -0x94(%rbp), %rsi
callq 0x8590
movq -0x170(%rbp), %rdi
movl (%rax), %eax
movl -0xc(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x3490
movsbl (%rax), %eax
movl %eax, -0x168(%rbp)
movslq -0x90(%rbp), %rsi
leaq 0x5f806c8(%rip), %rdi   # 0x5f873e8
callq 0x32e0
movq %rax, %rcx
movl -0x168(%rbp), %eax
movsbl (%rcx), %ecx
subl %ecx, %eax
sete %al
movb %al, -0x161(%rbp)
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x3430
movq -0x160(%rbp), %rdx
leaq 0x153c1(%rip), %rsi     # 0x1c11e
leaq -0xb8(%rbp), %rdi
callq 0x8300
jmp 0x6d6b
movb -0x161(%rbp), %al
movzbl %al, %edi
andl $0x1, %edi
leaq -0xb8(%rbp), %rsi
callq 0x3a80
jmp 0x6d85
leaq -0xb8(%rbp), %rdi
callq 0x34a8
leaq -0xb9(%rbp), %rdi
callq 0x32c0
movq 0x5f80664(%rip), %rax   # 0x5f87408
movq %rax, -0x188(%rbp)
movq 0x20(%rax), %rdi
addq $0x28, %rdi
movslq -0x98(%rbp), %rsi
callq 0x8590
movq -0x188(%rbp), %rdi
movl (%rax), %eax
movl -0xc(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x3490
movsbl (%rax), %eax
movl %eax, -0x180(%rbp)
movslq -0x90(%rbp), %rsi
leaq 0x5f805fc(%rip), %rdi   # 0x5f873e8
callq 0x32e0
movq %rax, %rcx
movl -0x180(%rbp), %eax
movsbl (%rcx), %ecx
subl %ecx, %eax
sete %al
movb %al, -0x179(%rbp)
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x3430
movq -0x178(%rbp), %rdx
leaq 0x152f5(%rip), %rsi     # 0x1c11e
leaq -0xf0(%rbp), %rdi
callq 0x8300
jmp 0x6e37
movb -0x179(%rbp), %al
movzbl %al, %edi
andl $0x1, %edi
leaq -0xf0(%rbp), %rsi
callq 0x3a80
jmp 0x6e51
leaq -0xf0(%rbp), %rdi
callq 0x34a8
leaq -0xf1(%rbp), %rdi
callq 0x32c0
movl -0x8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x704c
movl 0x10(%rbp), %eax
movl %eax, -0x18c(%rbp)
movq 0x5f80583(%rip), %rdi   # 0x5f87408
movslq -0x8(%rbp), %rsi
callq 0x3490
movsbl (%rax), %eax
movl %eax, -0x190(%rbp)
movslq -0x90(%rbp), %rsi
leaq 0x5f80543(%rip), %rdi   # 0x5f873e8
callq 0x32e0
movl -0x190(%rbp), %ecx
movq %rax, %rdx
movl -0x18c(%rbp), %eax
movsbl (%rdx), %edx
cmpl %edx, %ecx
setne %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jl 0x704c
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ac(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a8(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x1a4(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x1a0(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x19c(%rbp)
movl -0x98(%rbp), %eax
movl %eax, -0x198(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0x1b0(%rbp)
movq 0x5f804e7(%rip), %rdi   # 0x5f87408
movslq -0x8(%rbp), %rsi
callq 0x3490
movsbl (%rax), %eax
movl %eax, -0x194(%rbp)
movslq -0x90(%rbp), %rsi
leaq 0x5f804a7(%rip), %rdi   # 0x5f873e8
callq 0x32e0
movl -0x1b0(%rbp), %r10d
movl -0x1ac(%rbp), %edi
movl -0x1a8(%rbp), %esi
movl -0x1a4(%rbp), %edx
movl -0x1a0(%rbp), %ecx
movl -0x19c(%rbp), %r8d
movl -0x198(%rbp), %r9d
movq %rax, %r11
movl -0x194(%rbp), %eax
movsbl (%r11), %r11d
cmpl %r11d, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
subl %eax, %r10d
movq 0x18(%rbp), %rax
subq $0x10, %rsp
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x6890
addq $0x10, %rsp
testb $0x1, %al
jne 0x6fb1
jmp 0x704a
movb $0x1, -0x1(%rbp)
movl $0x1, -0xf8(%rbp)
jmp 0x712f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x6ff6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x34a8
leaq -0xb9(%rbp), %rdi
callq 0x32c0
jmp 0x7140
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x7039
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x34a8
leaq -0xf1(%rbp), %rdi
callq 0x32c0
jmp 0x7140
jmp 0x704c
cmpl $0x0, 0x10(%rbp)
jle 0x70ac
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
addl $0x1, %esi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %ecx
movl -0x94(%rbp), %r8d
movl -0x98(%rbp), %r9d
movl 0x10(%rbp), %r10d
subl $0x1, %r10d
movq 0x18(%rbp), %rax
subq $0x10, %rsp
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x6890
addq $0x10, %rsp
testb $0x1, %al
jne 0x7097
jmp 0x70aa
movb $0x1, -0x1(%rbp)
movl $0x1, -0xf8(%rbp)
jmp 0x712f
jmp 0x70ac
jmp 0x70ae
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x6be6
cmpl $0x0, 0x10(%rbp)
jle 0x7121
movl -0x8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x7121
movl -0x8(%rbp), %edi
addl $0x1, %edi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %ecx
movl -0x18(%rbp), %r8d
movl -0x1c(%rbp), %r9d
movl 0x10(%rbp), %r10d
subl $0x1, %r10d
movq 0x18(%rbp), %rax
subq $0x10, %rsp
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x6890
addq $0x10, %rsp
testb $0x1, %al
jne 0x710f
jmp 0x711f
movb $0x1, -0x1(%rbp)
movl $0x1, -0xf8(%rbp)
jmp 0x712f
jmp 0x7121
movb $0x0, -0x1(%rbp)
movl $0x1, -0xf8(%rbp)
movq -0x70(%rbp), %rax
movq %rax, %rsp
movb -0x1(%rbp), %al
andb $0x1, %al
movq %rbp, %rsp
popq %rbp
retq
movq -0xc8(%rbp), %rdi
callq 0x3420
nopl (%rax)