// File: /workspace/github_cpp_makefile_star2_O2/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 $0x138, %rsp            # imm = 0x138
movl %r8d, %r15d
movl %ecx, %ebx
movl %edx, %r12d
movl %esi, %r13d
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 0x48(%rsp), %rsi
movq %rcx, (%rsi)
leaq 0x5f69521(%rip), %rdi   # 0x5f6c390
callq 0x78da
testq %rax, %rax
je 0x2e9a
leaq 0x5f69510(%rip), %rdi   # 0x5f6c390
leaq 0x48(%rsp), %rsi
callq 0x796a
movq %r14, %rdi
movq %rax, %rsi
callq 0x4a0c
jmp 0x3276
leal 0x1(%r15), %eax
movslq %eax, %rsi
leaq 0xa8(%rsp), %rdx
orl $-0x1, (%rdx)
leaq 0x90(%rsp), %rdi
leaq 0x8(%rsp), %rcx
callq 0x4970
leaq 0xa8(%rsp), %rdi
callq 0x4fec
movq %r15, 0x30(%rsp)
movq %r14, 0x50(%rsp)
decl %r12d
decl %ebx
movq %rbx, %rax
shlq $0x20, %rax
orq %rax, %r12
andl $0x0, 0x8(%rsp)
movq %r12, 0xc(%rsp)
movq 0x8(%rsp), %rax
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
movl %ebx, 0x8(%rsi)
leaq 0xa8(%rsp), %rdi
callq 0x7cc2
movq %r13, 0x40(%rsp)
leal -0x1(%r13), %eax
movl %eax, 0x3c(%rsp)
cltq
movq %rax, 0x58(%rsp)
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0x4a5a
testq %rax, %rax
je 0x31f2
movq 0xb8(%rsp), %rax
movl (%rax), %ebp
movl 0x4(%rax), %r14d
movslq 0x8(%rax), %r13
movq %rbx, %rdi
callq 0x4a6a
movl %ebp, 0x4(%rsp)
movslq %ebp, %rax
movq 0x90(%rsp), %rcx
movl (%rcx,%rax,4), %edx
cmpl $-0x1, %edx
je 0x30a8
cmpl %r13d, %edx
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
jg 0x2f1f
movq 0x40(%rsp), %rbx
movq %r14, %r8
cmpl %ebx, %r8d
jl 0x30c3
movq 0x5f693dc(%rip), %rax   # 0x5f6c370
movl 0x8(%rax), %esi
movl %r8d, %ecx
notl %ecx
addl %esi, %ecx
movl %r13d, %edx
notl %edx
addl %esi, %edx
movslq %ecx, %rsi
testl %r13d, %r13d
js 0x30cf
movq (%rax), %rcx
movb (%rcx,%rsi), %r9b
movslq %edx, %rdx
cmpb (%rcx,%rdx), %r9b
movq 0x30(%rsp), %rcx
jne 0x30d7
movq %r8, 0x18(%rsp)
movq %r13, %rbp
movq 0x20(%rax), %rdi
callq 0x4a88
movq %rax, %r13
leaq 0x118(%rsp), %r14
movq %r14, %rdi
leaq 0x60dc(%rip), %rsi      # 0x90cc
leaq 0x8(%rsp), %r15
movq %r15, %rdx
callq 0x48da
leaq 0xf8(%rsp), %r12
movq 0x18(%rsp), %rax
subl %r13d, %eax
xorl %edi, %edi
cmpl $-0x1, %eax
setge %dil
movq %r14, %rsi
callq 0x272c
movq %r14, %rdi
callq 0x2378
movq %r12, %rdi
leaq 0x60a8(%rip), %rsi      # 0x90d8
movq %r15, %rdx
callq 0x48da
movl %ebp, %eax
subl %r13d, %eax
xorl %edi, %edi
cmpl $-0x1, %eax
setge %dil
movq %r12, %rsi
callq 0x272c
movq %r12, %rdi
callq 0x2378
movq 0x18(%rsp), %rcx
movl %ecx, %eax
subl %ebx, %eax
incl %eax
cmpl %r13d, %eax
cmovgel %r13d, %eax
subl %eax, %ecx
subl %eax, %ebp
movq %rbp, %rax
shlq $0x20, %rax
orq %rax, %rcx
movl 0x4(%rsp), %eax
movl %eax, 0x8(%rsp)
movq %rcx, 0xc(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %ebp, 0x28(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x7f62
jmp 0x2f1f
movq 0x40(%rsp), %rbx
cmpl %ebx, %r14d
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
movq %r14, %r8
jge 0x2f8d
incl %r13d
movl %r13d, (%rcx,%rax,4)
jmp 0x2f1f
movslq %edx, %rdx
movq 0x30(%rsp), %rcx
movq %rdx, 0x78(%rsp)
movq %rsi, 0x80(%rsp)
movslq %r8d, %rax
movq %rax, 0x68(%rsp)
movl %ecx, %eax
subl 0x4(%rsp), %eax
movslq %eax, %r12
movq %r13, %rax
shlq $0x20, %rax
movq %rax, 0x70(%rsp)
leaq 0x1(%r13), %rax
movq %rax, 0x88(%rsp)
xorl %ebx, %ebx
movq %r13, 0x60(%rsp)
movq %r8, 0x18(%rsp)
movl %r8d, %r15d
addq 0x70(%rsp), %r15
cmpq %r12, %rbx
jg 0x2f1f
movq 0x68(%rsp), %rbp
subq %rbx, %rbp
cmpq 0x58(%rsp), %rbp
jl 0x2f1f
xorl %r14d, %r14d
cmpq %r12, %r14
jg 0x31dd
cmpq $-0x1, %r13
jl 0x31dd
movl %r14d, %eax
orl %ebx, %eax
je 0x31cf
cmpl %ebp, 0x3c(%rsp)
je 0x318e
cmpq %r14, 0x88(%rsp)
je 0x318e
movq 0x5f691ff(%rip), %rax   # 0x5f6c370
movq (%rax), %rax
leaq (%rax,%rbx), %rcx
movq 0x80(%rsp), %rdx
movb (%rdx,%rcx), %cl
addq 0x78(%rsp), %rax
cmpb (%r14,%rax), %cl
jne 0x31cf
cmpl %r14d, %ebx
movl %r14d, %eax
cmoval %ebx, %eax
addl 0x4(%rsp), %eax
movl %eax, 0x8(%rsp)
movq %r15, 0xc(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %r13d, 0x28(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x7cc2
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
incq %r14
addq %rdi, %r15
decq %r13
jmp 0x3140
incq %rbx
movq 0x18(%rsp), %r8
decl %r8d
movq 0x60(%rsp), %r13
jmp 0x3114
movq 0x90(%rsp), %rax
xorl %ecx, %ecx
movq 0x30(%rsp), %rdi
testl %edi, %edi
cmovlel %ecx, %edi
movq 0x50(%rsp), %r14
cmpq %rcx, %rdi
je 0x3230
movl (%rax,%rcx,4), %edx
cmpl $-0x1, %edx
je 0x322b
movl 0x4(%rax,%rcx,4), %esi
cmpl $-0x1, %esi
je 0x3225
cmpl %edx, %esi
jg 0x322b
incl %edx
movl %edx, 0x4(%rax,%rcx,4)
incq %rcx
jmp 0x320b
leaq 0x5f69159(%rip), %rdi   # 0x5f6c390
leaq 0x48(%rsp), %rsi
callq 0x796a
leaq 0x90(%rsp), %rsi
movq %rax, %rdi
callq 0x4ac4
movq %r14, %rdi
movq %rax, %rsi
callq 0x4a0c
leaq 0xa8(%rsp), %rdi
callq 0x7c94
leaq 0x90(%rsp), %rdi
callq 0x66a2
movq %r14, %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x32bb
movq %rax, %rbx
jmp 0x32cb
jmp 0x32bb
jmp 0x32bb
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
jmp 0x32b0
jmp 0x32bb
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x2378
jmp 0x32be
jmp 0x32bb
jmp 0x32bb
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x7c94
leaq 0x90(%rsp), %rdi
callq 0x66a2
movq %rbx, %rdi
callq 0x2310