// File: /workspace/github_cpp_makefile_star2_O3/davidsun[P]TinyCompiler/LRAnalytics.cpp
// Function: LRAnalytics::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool) const
vector <int> LRAnalytics::parse(string str, bool quiet) const{
    str += INPUT_END_LETTER;
    string terminals = getTerminals();
    string nonTerminals = getNonTerminals();
    vector <int> ret;
    stack <int> sStates;
    map <char, int> translation;
    vector <vector <string> > table = genTable();
    for (int i = 0; i < table[0].size(); i ++) translation[table[0][i][0]] = i;
    int strPos = 0;
    sStates.push(0);
    while (1){
        int curState = sStates.top();
        const vector <string> &row = table[curState + 1];
        int curId = translation[str[strPos]];
        if (row[curId] == "acc"){
            if (!quiet) printf("Accept\n");
            break;
        }  else if (row[curId].size() > 0 && row[curId][0] == 'r'){
            int m = Utils::toInt(row[curId].substr(1));
            ret.push_back(m);
            for (int i = 0; i < _rules[m].right_side.size(); i ++) sStates.pop();
            char nt = _rules[m].left_side;
            curState = sStates.top();
            const vector <string> &newRow = table[curState + 1];
            curId = translation[nt];
            sStates.push(Utils::toInt(newRow[curId].substr(1)));
            if (!quiet) printf("Reduct %d\n", m);
        }  else if (row[curId].size() > 0 && row[curId][0] == 's'){
            int m = Utils::toInt(row[curId].substr(1));
            sStates.push(m);
            strPos ++;
            if (!quiet) printf("Shift %d\n", m);
        }  else {
            throw Exception("ERROR: unrecognizable input!\n");
        }
    }
    return ret; 
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movl %ecx, 0xc(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movq %rdx, 0xa0(%rsp)
movq %rdx, %rdi
movl $0x24, %esi
callq 0x2170
leaq 0xc8(%rsp), %rdi
movq %r15, %rsi
callq 0x46c0
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
callq 0x4608
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
leaq 0x50(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x6730
leaq 0xf0(%rsp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x4780
movq 0x38(%rsp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x5242
xorl %r14d, %r14d
leaq 0xe8(%rsp), %r12
xorl %r13d, %r13d
movq (%rax,%r14), %rsi
movq %r12, %rdi
callq 0x587a
movl %r13d, (%rax)
incq %r13
movq 0x38(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %r14
cmpq %r13, %rcx
ja 0x5214
leaq 0x10(%rsp), %rsi
movl $0x0, (%rsi)
leaq 0x50(%rsp), %rdi
callq 0x6aca
leaq 0x10(%rsp), %r13
xorl %r14d, %r14d
movl %r14d, %r14d
movq 0x80(%rsp), %rax
cmpq 0x88(%rsp), %rax
jne 0x5288
movq 0x98(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movslq -0x4(%rax), %rax
leaq (%rax,%rax,2), %rbp
shlq $0x3, %rbp
addq 0x38(%rsp), %rbp
movq 0xa0(%rsp), %rax
movq (%rax), %rsi
addq %r14, %rsi
leaq 0xe8(%rsp), %rdi
callq 0x587a
movslq (%rax), %r12
shlq $0x5, %r12
movq 0x18(%rbp), %rdi
addq %r12, %rdi
leaq 0xae0a(%rip), %rsi      # 0x100d3
callq 0x2090
testl %eax, %eax
je 0x5555
movq 0x18(%rbp), %rsi
cmpq $0x0, 0x8(%rsi,%r12)
je 0x55e0
addq %r12, %rsi
movq (%rsi), %rax
movzbl (%rax), %eax
cmpl $0x72, %eax
jne 0x54b5
movl $0x1, %edx
movq %r13, %rdi
movq $-0x1, %rcx
callq 0x21d0
movq %r13, %rdi
callq 0x27dc
movl %eax, %ebp
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x5332
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
movl %ebp, 0x4(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x534c
movl %ebp, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x5359
movq %rbx, %rdi
leaq 0x4(%rsp), %rdx
callq 0x6d26
movslq 0x4(%rsp), %rdx
movq 0x20(%r15), %rcx
leaq (%rdx,%rdx,2), %rsi
shlq $0x4, %rsi
cmpq $0x0, 0x10(%rcx,%rsi)
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rdi
je 0x53f4
xorl %ebp, %ebp
cmpq %rdi, %rax
je 0x538f
addq $-0x4, %rax
jmp 0x53d7
movl $0x200, %esi            # imm = 0x200
callq 0x21b0
movq 0x98(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x98(%rsp)
movq -0x8(%rax), %rdi
movq %rdi, 0x88(%rsp)
leaq 0x200(%rdi), %rax
movq %rax, 0x90(%rsp)
leaq 0x1fc(%rdi), %rax
movl 0x4(%rsp), %edx
movq 0x20(%r15), %rcx
movq %rax, 0x80(%rsp)
incq %rbp
movslq %edx, %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x4, %rsi
cmpq %rbp, 0x10(%rcx,%rsi)
ja 0x5384
addq %rsi, %rcx
movb (%rcx), %cl
movb %cl, 0xb(%rsp)
cmpq %rdi, %rax
jne 0x5416
movq 0x98(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movslq -0x4(%rax), %rbp
movq 0x38(%rsp), %r12
leaq 0xe8(%rsp), %rdi
leaq 0xb(%rsp), %rsi
callq 0x587a
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
movslq (%rax), %rsi
shlq $0x5, %rsi
addq 0x18(%r12,%rcx,8), %rsi
movl $0x1, %edx
movq %r13, %rdi
movq $-0x1, %rcx
callq 0x21d0
movq %r13, %rdi
callq 0x27dc
movl %eax, 0x34(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x34(%rsp), %rsi
callq 0x6aca
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x5493
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
cmpb $0x0, 0xc(%rsp)
jne 0x5262
movl 0x4(%rsp), %esi
leaq 0xac49(%rip), %rdi      # 0x100f2
xorl %eax, %eax
callq 0x2040
jmp 0x5262
cmpl $0x73, %eax
jne 0x55e0
movl $0x1, %edx
movq %r13, %rdi
movq $-0x1, %rcx
callq 0x21d0
movq %r13, %rdi
callq 0x27dc
movl %eax, %ebp
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x54f8
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
movl %ebp, 0x4(%rsp)
movq 0x80(%rsp), %rax
movq 0x90(%rsp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x5525
movl %ebp, (%rax)
addq $0x4, %rax
movq %rax, 0x80(%rsp)
jmp 0x5534
leaq 0x50(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x6e46
cmpb $0x0, 0xc(%rsp)
jne 0x554d
movl 0x4(%rsp), %esi
leaq 0xabb7(%rip), %rdi      # 0x100fd
xorl %eax, %eax
callq 0x2040
incl %r14d
jmp 0x525f
cmpb $0x0, 0xc(%rsp)
jne 0x5568
leaq 0xabf2(%rip), %rdi      # 0x10155
callq 0x2260
leaq 0x38(%rsp), %rdi
callq 0x5832
leaq 0xe8(%rsp), %rdi
callq 0x58e0
leaq 0x50(%rsp), %rdi
callq 0x5930
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x55aa
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x55cb
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x20e0
movq %rax, %r15
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
movq %rax, (%rdi)
leaq 0xab06(%rip), %rsi      # 0x10107
leaq 0xab1c(%rip), %rdx      # 0x10124
callq 0x2892
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x26ac
xorl %ebp, %ebp
leaq 0x10782(%rip), %rsi     # 0x15da8
leaq -0x2f37(%rip), %rdx     # 0x26f6
movq %r15, %rdi
callq 0x22e0
jmp 0x5691
jmp 0x5696
jmp 0x5691
jmp 0x5691
movq %rax, %r12
jmp 0x56bf
movq %rax, %r12
jmp 0x56d6
movq %rax, %r12
jmp 0x570b
jmp 0x5691
jmp 0x5691
jmp 0x5691
jmp 0x5691
jmp 0x5696
jmp 0x5691
movq %rax, %r12
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x567d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
testb %bpl, %bpl
jne 0x5687
jmp 0x56b5
movq %rax, %r12
movq %r15, %rdi
callq 0x2140
jmp 0x56b5
movq %rax, %r12
jmp 0x56b5
movq %rax, %r12
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x56b5
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0x38(%rsp), %rdi
callq 0x5832
leaq 0xe8(%rsp), %rdi
callq 0x58e0
leaq 0x50(%rsp), %rdi
callq 0x5930
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x56ea
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x570b
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x572c
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %r12, %rdi
callq 0x22f0