// File: /workspace/github_cpp_makefile_star2_O3/shangjingbo1226[P]MACFP/src/methods/MACFP.cpp
// Function: expandLeft(int, int, int, int)
vector<int> expandLeft(int leftBound, int l, int x, int remainDistance)
{
    ULL key = leftBound;
    key = key * MAGIC + l;
    key = key * MAGIC + x;
    key = key * MAGIC + remainDistance;
    if (bufferLeft.count(key)) {
        return bufferLeft[key];
    }
    vector<int> best(remainDistance + 1, -1);

    deque< pair<int, PII> > q;
    q.push_back(make_pair(0, make_pair(l - 1, x - 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 < leftBound) {
            if (best[dist] == -1 || best[dist] < v + 1) {
                best[dist] = v + 1;
            }
            continue;
        }

        int rev_u = (int)rev_s->size() - 1 - u;
        int rev_v = (int)rev_s->size() - 1 - v;
        if (u >= leftBound && v >= 0 && rev_s->s[rev_u] == rev_s->s[rev_v]) {
            int lcp = rev_s->sa->lcp(rev_u, rev_v);
            myAssert(u - lcp >= -1, "u-lcp error");
            myAssert(v - lcp >= -1, "v-lcp error");
            lcp = min(lcp, u - leftBound + 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 < leftBound - 1) {
                    break;
                }
                for (int dv = 0; dv <= remainDistance - dist; ++ dv) {
                    if (v - dv < -1) {
                        break;
                    }
                    if (du + dv > 0){
                        if (u - du == leftBound - 1 || v - dv == -1 || rev_s->s[rev_u + du] == rev_s->s[rev_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 bufferLeft[key] = best;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movl %r8d, %r14d
movl %ecx, %r12d
movl %edx, %r13d
movl %esi, %r15d
movq %rdi, %rbx
movslq %esi, %rax
imulq $0xabcdef, %rax, %rax   # imm = 0xABCDEF
movslq %edx, %rcx
addq %rax, %rcx
imulq $0xabcdef, %rcx, %rax   # imm = 0xABCDEF
movslq %r12d, %rcx
addq %rax, %rcx
imulq $0xabcdef, %rcx, %rax   # imm = 0xABCDEF
movslq %r8d, %rcx
addq %rax, %rcx
leaq 0x50(%rsp), %rsi
movq %rcx, (%rsi)
leaq 0x5f69119(%rip), %rdi   # 0x5f6c390
callq 0x8b9e
testq %rax, %rax
je 0x32a2
leaq 0x5f69108(%rip), %rdi   # 0x5f6c390
leaq 0x50(%rsp), %rsi
callq 0x8bfa
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5858
jmp 0x37d1
leal 0x1(%r14), %eax
movl %eax, 0x3c(%rsp)
movslq %eax, %rsi
leaq 0x70(%rsp), %rbp
movl $0xffffffff, (%rbp)     # imm = 0xFFFFFFFF
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rcx
movq %rbp, %rdx
callq 0x5682
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rbp)
movaps %xmm0, 0x30(%rbp)
movaps %xmm0, 0x20(%rbp)
movaps %xmm0, 0x10(%rbp)
movaps %xmm0, (%rbp)
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
callq 0x5eea
movq %r14, 0x40(%rsp)
movq %rbx, 0xc0(%rsp)
decl %r13d
decl %r12d
movq %r12, %rax
shlq $0x20, %rax
orq %rax, %r13
movl $0x0, 0x10(%rsp)
movq %r13, 0x14(%rsp)
movq 0x10(%rsp), %rax
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
movl %r12d, 0x8(%rsi)
leaq 0x70(%rsp), %rdi
callq 0x8f3c
movq %r15, 0x30(%rsp)
leal -0x1(%r15), %eax
cltq
movq %rax, 0x48(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, %rcx
subq 0x98(%rsp), %rcx
sarq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
imulq $0x2a, %rcx, %rax
movq 0xa0(%rsp), %rdx
subq 0xa8(%rsp), %rdx
sarq $0x2, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
addq %rax, %rdx
movq 0x80(%rsp), %rax
movq 0x90(%rsp), %rcx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x2, %rsi
movabsq $0x5555555555555555, %rdi # imm = 0x5555555555555555
imulq %rdi, %rsi
cmpq %rsi, %rdx
je 0x374a
movl (%rax), %edx
movl %edx, 0xc(%rsp)
movl 0x4(%rax), %r14d
movl 0x8(%rax), %ebp
addq $-0xc, %rcx
cmpq %rcx, %rax
je 0x33d8
addq $0xc, %rax
jmp 0x3419
movq 0x88(%rsp), %rdi
movl $0x1f8, %esi            # imm = 0x1F8
callq 0x21f0
movq 0x98(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x98(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x88(%rsp)
leaq 0x1f8(%rax), %rcx
movq %rcx, 0x90(%rsp)
movq 0x30(%rsp), %rbx
movslq 0xc(%rsp), %rcx
movq %rax, 0x80(%rsp)
movq 0x58(%rsp), %rax
movl (%rax,%rcx,4), %edx
cmpl $-0x1, %edx
je 0x3445
cmpl %ebp, %edx
jg 0x3343
movq 0x30(%rsp), %rbx
cmpl %ebx, %r14d
jge 0x3454
incl %ebp
movl %ebp, (%rax,%rcx,4)
jmp 0x3343
movq 0x5f68f15(%rip), %rcx   # 0x5f6c370
movl 0x8(%rcx), %edx
movl %r14d, %eax
notl %eax
addl %edx, %eax
movl %ebp, %edi
notl %edi
addl %edx, %edi
testl %ebp, %ebp
js 0x35c8
movslq %eax, %rsi
movq (%rcx), %r8
movb (%r8,%rsi), %r9b
movslq %edi, %rdx
cmpb (%r8,%rdx), %r9b
jne 0x35c8
movq %r14, %r12
movq 0x20(%rcx), %rdi
callq 0x58d8
movq %rax, %r13
leaq 0x138(%rsp), %r14
movq %r14, 0x128(%rsp)
leaq 0x128(%rsp), %r15
movq %r15, %rdi
leaq 0x6c44(%rip), %rsi      # 0xa0ff
leaq 0x6c48(%rip), %rdx      # 0xa10a
callq 0x87ec
movl %r12d, %eax
subl %r13d, %eax
xorl %edi, %edi
cmpl $-0x1, %eax
setge %dil
movq %r15, %rsi
callq 0x2920
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
leaq 0x108(%rsp), %r15
je 0x3503
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x118(%rsp), %r14
movq %r14, 0x108(%rsp)
movq %r15, %rdi
leaq 0x6bee(%rip), %rsi      # 0xa10b
leaq 0x6bf2(%rip), %rdx      # 0xa116
callq 0x87ec
movl %ebp, %eax
subl %r13d, %eax
xorl %edi, %edi
cmpl $-0x1, %eax
setge %dil
movq %r15, %rsi
callq 0x2920
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x355c
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x21f0
movl %r12d, %eax
subl %ebx, %eax
incl %eax
cmpl %r13d, %eax
cmovgel %r13d, %eax
subl %eax, %r12d
subl %eax, %ebp
movq %rbp, %rax
shlq $0x20, %rax
orq %rax, %r12
movl 0xc(%rsp), %eax
movl %eax, 0x10(%rsp)
movq %r12, 0x14(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %ebp, 0x28(%rsp)
movq 0x80(%rsp), %rax
cmpq 0x88(%rsp), %rax
je 0x3736
movl 0x28(%rsp), %ecx
movl %ecx, -0x4(%rax)
movq 0x20(%rsp), %rcx
movq %rcx, -0xc(%rax)
addq $-0xc, 0x80(%rsp)
jmp 0x3343
movl 0xc(%rsp), %ecx
cmpl 0x40(%rsp), %ecx
jg 0x3343
movslq %r14d, %rcx
movq %rcx, 0xd8(%rsp)
movslq %ebp, %rdx
movslq %edi, %rcx
movq %rcx, 0xf0(%rsp)
cmpl $-0x2, %ebp
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
cmovll %ebp, %ecx
movl %ebp, %r13d
subl %ecx, %r13d
movl 0x3c(%rsp), %ecx
movl %ecx, %r12d
subl 0xc(%rsp), %r12d
cltq
movq %rax, 0xe8(%rsp)
movq %rdx, %rax
shlq $0x20, %rax
movq %rax, 0xd0(%rsp)
incq %rdx
movq %rdx, 0xf8(%rsp)
xorl %ebx, %ebx
movq %rbp, 0xc8(%rsp)
movl %r14d, %r15d
addq 0xd0(%rsp), %r15
movq 0xd8(%rsp), %rax
subq %rbx, %rax
movq %rax, 0x100(%rsp)
cmpq 0x48(%rsp), %rax
jl 0x3343
movq %r14, 0xe0(%rsp)
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x3712
movl %r14d, %eax
orl %ebx, %eax
je 0x36f7
movq 0x100(%rsp), %rax
cmpq 0x48(%rsp), %rax
sete %al
cmpq %r14, 0xf8(%rsp)
sete %cl
orb %al, %cl
jne 0x36c4
movq 0x5f68ccc(%rip), %rax   # 0x5f6c370
movq (%rax), %rax
leaq (%rax,%rbx), %rcx
movq 0xe8(%rsp), %rdx
movb (%rdx,%rcx), %cl
addq 0xf0(%rsp), %rax
cmpb (%r14,%rax), %cl
jne 0x36f7
cmpl %r14d, %ebx
movl %r14d, %eax
cmoval %ebx, %eax
addl 0xc(%rsp), %eax
movl %eax, 0x10(%rsp)
movq %r15, 0x14(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %ebp, 0x28(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8f3c
incq %r14
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
addq %rax, %r15
decl %ebp
cmpq %r14, %r12
jne 0x366e
incq %rbx
movq 0xe0(%rsp), %r14
decl %r14d
cmpq %r12, %rbx
movq 0xc8(%rsp), %rbp
jne 0x363a
jmp 0x3343
leaq 0x70(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x91be
jmp 0x3343
movq 0x40(%rsp), %rcx
testl %ecx, %ecx
movq 0xc0(%rsp), %rbx
jle 0x3787
movq 0x58(%rsp), %rax
movl %ecx, %ecx
xorl %edx, %edx
movl (%rax,%rdx,4), %esi
cmpl $-0x1, %esi
je 0x377f
movl 0x4(%rax,%rdx,4), %edi
cmpl $-0x1, %edi
je 0x3779
cmpl %esi, %edi
jg 0x377f
incl %esi
movl %esi, 0x4(%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x3764
leaq 0x5f68c02(%rip), %rdi   # 0x5f6c390
leaq 0x50(%rsp), %rsi
callq 0x8bfa
leaq 0x58(%rsp), %rsi
movq %rax, %rdi
callq 0x5914
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5858
leaq 0x70(%rsp), %rdi
callq 0x8ee4
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x37d1
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq %rbx, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3833
movq %rax, %rbx
jmp 0x3840
jmp 0x3833
jmp 0x3833
movq %rax, %rbx
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x3836
movq 0x118(%rsp), %rsi
jmp 0x3825
jmp 0x3833
movq %rax, %rbx
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0x3836
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x3836
jmp 0x3833
jmp 0x3833
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x8ee4
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x3857
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x2330