// File: /workspace/github_cpp_makefile_star2_O3/shangjingbo1226[P]MACFP/src/methods/MACFP.cpp
// Function: expandRight(int, int, int, int)
vector<int> expandRight(int rightBound, int r, int y, int remainDistance)
{
    ULL key = rightBound;
    key = key * MAGIC + r;
    key = key * MAGIC + y;
    key = key * MAGIC + remainDistance;
    if (bufferRight.count(key)) {
        return bufferRight[key];
    }
    vector<int> best(remainDistance + 1, -1);

    deque< pair<int, PII> > q;
    q.push_front(make_pair(0, make_pair(r + 1, y + 1)));
    while (q.size()) {
        int dist = q.front().first;
        int u = q.front().second.first;
        int v = q.front().second.second;
        q.pop_front();

        if (best[dist] != -1 && best[dist] <= v - 1) {
            continue;
        }

        if (u > rightBound) {
            if (best[dist] == -1 || best[dist] > v - 1) {
                best[dist] = v - 1;
            }
            continue;
        }

        if (u <= rightBound && v < s->size() && s->s[u] == s->s[v]) {
            int lcp = s->sa->lcp(u, v);
            myAssert(u + lcp <= s->size(), "u+lcp error");
            myAssert(v + lcp <= s->size(), "v+lcp error");
            lcp = min(lcp, rightBound - u + 1);
            q.push_front(make_pair(dist, make_pair(u + lcp, v + lcp)));
        } else {
            for (int du = 0; du <= remainDistance - dist; ++ du) {
                if (u + du > rightBound + 1) {
                    break;
                }
                for (int dv = 0; dv <= remainDistance - dist; ++ dv) {
                    if (v + dv > s->size()) {
                        break;
                    }
                    if (du + dv > 0){
                        if (u + du == rightBound + 1 || v + dv == s->size() || s->s[u + du] == s->s[v + dv]) {
                            q.push_back(make_pair(dist + max(du, dv), make_pair(u + du, v + dv)));
                        }
                    }
                }
            }
        }
    }
    for (int i = 0; i < remainDistance; ++ i) {
        if (best[i] != -1) {
            if (best[i + 1] == -1 || best[i + 1] > best[i] - 1) {
                best[i + 1] = best[i] - 1;
            }
        }
    }
    return bufferRight[key] = best;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movl %r8d, %r15d
movl %ecx, %ebx
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %r14
movslq %esi, %rax
imulq $0xabcdef, %rax, %rax   # imm = 0xABCDEF
movslq %edx, %rcx
addq %rax, %rcx
imulq $0xabcdef, %rcx, %rax   # imm = 0xABCDEF
movslq %ebx, %rcx
addq %rax, %rcx
imulq $0xabcdef, %rcx, %rax   # imm = 0xABCDEF
movslq %r8d, %rcx
addq %rax, %rcx
leaq 0x60(%rsp), %rsi
movq %rcx, (%rsi)
leaq 0x5f68b12(%rip), %rdi   # 0x5f6c3c8
callq 0x8b9e
testq %rax, %rax
je 0x38e1
leaq 0x5f68b01(%rip), %rdi   # 0x5f6c3c8
leaq 0x60(%rsp), %rsi
callq 0x8bfa
movq %r14, %rdi
movq %rax, %rsi
callq 0x5858
jmp 0x3e10
leal 0x1(%r15), %eax
movl %eax, 0x4c(%rsp)
movslq %eax, %rsi
leaq 0x80(%rsp), %r13
movl $0xffffffff, (%r13)     # imm = 0xFFFFFFFF
leaq 0x68(%rsp), %rdi
leaq 0x20(%rsp), %rcx
movq %r13, %rdx
callq 0x5682
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%r13)
movaps %xmm0, 0x30(%r13)
movaps %xmm0, 0x20(%r13)
movaps %xmm0, 0x10(%r13)
movaps %xmm0, (%r13)
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x5eea
incl %r12d
incl %ebx
movq %rbx, %rax
shlq $0x20, %rax
orq %rax, %r12
movl $0x0, 0x20(%rsp)
movq %r12, 0x24(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movl %ebx, 0x18(%rsp)
movq 0x90(%rsp), %rax
cmpq 0x98(%rsp), %rax
movq %r14, 0xd0(%rsp)
movq %r15, 0x50(%rsp)
je 0x399d
movl 0x18(%rsp), %ecx
movl %ecx, -0x4(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, -0xc(%rax)
addq $-0xc, 0x90(%rsp)
jmp 0x39af
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x91be
movq %rbp, 0x30(%rsp)
leal 0x1(%rbp), %eax
movl %eax, 0x48(%rsp)
cltq
movq %rax, 0x58(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, %rcx
subq 0xa8(%rsp), %rcx
sarq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
imulq $0x2a, %rcx, %rax
movq 0xb0(%rsp), %rdx
subq 0xb8(%rsp), %rdx
sarq $0x2, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
addq %rax, %rdx
movq 0x90(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x2, %rsi
movabsq $0x5555555555555555, %rdi # imm = 0x5555555555555555
imulq %rdi, %rsi
cmpq %rsi, %rdx
je 0x3d86
movl (%rax), %edx
movl %edx, 0xc(%rsp)
movl 0x4(%rax), %r12d
movslq 0x8(%rax), %r14
addq $-0xc, %rcx
cmpq %rcx, %rax
je 0x3a58
addq $0xc, %rax
jmp 0x3a99
movq 0x98(%rsp), %rdi
movl $0x1f8, %esi            # imm = 0x1F8
callq 0x21f0
movq 0xa8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0xa8(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x98(%rsp)
leaq 0x1f8(%rax), %rcx
movq %rcx, 0xa0(%rsp)
movq 0x30(%rsp), %rsi
movslq 0xc(%rsp), %rcx
movq %rax, 0x90(%rsp)
movq 0x68(%rsp), %rax
movl (%rax,%rcx,4), %edx
cmpl $-0x1, %edx
je 0x3c63
cmpl %r14d, %edx
jl 0x39c2
cmpl 0x30(%rsp), %r12d
jg 0x3c6c
movslq %r12d, %rsi
movq 0x5f6888e(%rip), %rax   # 0x5f6c368
cmpq %r14, 0x8(%rax)
movq %r14, 0x38(%rsp)
movq %rsi, 0x40(%rsp)
jbe 0x3c78
movq (%rax), %rcx
movq 0x40(%rsp), %rdx
movb (%rcx,%rdx), %dl
cmpb (%rcx,%r14), %dl
movq 0x40(%rsp), %rsi
jne 0x3c78
movq 0x20(%rax), %rdi
movq %r14, %rdx
callq 0x58d8
movq %rax, %r13
movq 0x5f6884a(%rip), %rax   # 0x5f6c368
movq 0x8(%rax), %rbx
leaq 0x118(%rsp), %r14
movq %r14, 0x108(%rsp)
leaq 0x108(%rsp), %r15
movq %r15, %rdi
leaq 0x65d3(%rip), %rsi      # 0xa117
leaq 0x65d7(%rip), %rdx      # 0xa122
callq 0x87ec
leal (%r12,%r13), %eax
cltq
xorl %edi, %edi
cmpq %rax, %rbx
setae %dil
movq %r15, %rsi
callq 0x2920
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
leaq 0xe8(%rsp), %r15
je 0x3b8c
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x5f687d5(%rip), %rax   # 0x5f6c368
movq 0x8(%rax), %rbx
leaq 0xf8(%rsp), %r14
movq %r14, 0xe8(%rsp)
movq %r15, %rdi
leaq 0x6572(%rip), %rsi      # 0xa123
leaq 0x6576(%rip), %rdx      # 0xa12e
callq 0x87ec
movq 0x38(%rsp), %rax
addl %r13d, %eax
cltq
xorl %edi, %edi
cmpq %rax, %rbx
setae %dil
movq %r15, %rsi
callq 0x2920
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0x3bf5
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x21f0
movl 0x48(%rsp), %eax
subl %r12d, %eax
cmpl %r13d, %eax
cmovgel %r13d, %eax
addl %eax, %r12d
addl 0x38(%rsp), %eax
movq %rax, %rcx
shlq $0x20, %rcx
orq %rcx, %r12
movl 0xc(%rsp), %ecx
movl %ecx, 0x20(%rsp)
movq %r12, 0x24(%rsp)
movq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movq 0x90(%rsp), %rax
cmpq 0x98(%rsp), %rax
je 0x3d6f
movl 0x18(%rsp), %ecx
movl %ecx, -0x4(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, -0xc(%rax)
addq $-0xc, 0x90(%rsp)
jmp 0x39c2
cmpl %esi, %r12d
jle 0x3ad0
decl %r14d
movl %r14d, (%rax,%rcx,4)
jmp 0x39c2
movl 0xc(%rsp), %eax
cmpl 0x50(%rsp), %eax
jg 0x39c2
movl 0x4c(%rsp), %eax
movl %eax, %r13d
subl 0xc(%rsp), %r13d
movq %r14, %rax
shlq $0x20, %rax
movq %rax, 0xd8(%rsp)
xorl %ebp, %ebp
movl %r12d, %r15d
addq 0xd8(%rsp), %r15
leaq (%rsi,%rbp), %rbx
cmpq 0x58(%rsp), %rbx
jg 0x39c2
movq %r12, 0xe0(%rsp)
movq %r14, %r12
xorl %r14d, %r14d
movq 0x5f68696(%rip), %rax   # 0x5f6c368
movq 0x8(%rax), %rcx
cmpq %r12, %rcx
jb 0x3d49
movl %r14d, %edx
orl %ebp, %edx
je 0x3d31
cmpq 0x58(%rsp), %rbx
je 0x3cfa
cmpq %rcx, %r12
je 0x3cfa
movq (%rax), %rax
movb (%rax,%rbx), %cl
cmpb (%rax,%r12), %cl
jne 0x3d31
cmpl %r14d, %ebp
movl %r14d, %eax
cmoval %ebp, %eax
addl 0xc(%rsp), %eax
movl %eax, 0x20(%rsp)
movq %r15, 0x24(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movl %r12d, 0x18(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x8f3c
incq %r14
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r15
incq %r12
cmpq %r14, %r13
jne 0x3ccb
incq %rbp
movq 0xe0(%rsp), %r12
incl %r12d
cmpq %r13, %rbp
movq 0x38(%rsp), %r14
movq 0x40(%rsp), %rsi
jne 0x3ca3
jmp 0x39c2
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x91be
jmp 0x39c2
movq 0x50(%rsp), %rcx
testl %ecx, %ecx
movq 0xd0(%rsp), %r14
jle 0x3dc3
movq 0x68(%rsp), %rax
movl %ecx, %ecx
xorl %edx, %edx
movl (%rax,%rdx,4), %esi
cmpl $-0x1, %esi
je 0x3dbb
movl 0x4(%rax,%rdx,4), %edi
cmpl $-0x1, %edi
je 0x3db5
cmpl %esi, %edi
jl 0x3dbb
decl %esi
movl %esi, 0x4(%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x3da0
leaq 0x5f685fe(%rip), %rdi   # 0x5f6c3c8
leaq 0x60(%rsp), %rsi
callq 0x8bfa
leaq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x5914
movq %r14, %rdi
movq %rax, %rsi
callq 0x5858
leaq 0x80(%rsp), %rdi
callq 0x8ee4
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x3e10
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq %r14, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3e72
jmp 0x3e72
movq %rax, %rbx
jmp 0x3e82
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0x3e75
movq 0xf8(%rsp), %rsi
jmp 0x3e62
jmp 0x3e72
movq %rax, %rbx
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x3e75
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x3e75
jmp 0x3e72
jmp 0x3e72
jmp 0x3e72
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x8ee4
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x3e99
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x2330