// File: /workspace/github_cpp_makefile_star2_O1/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 $0x128, %rsp            # imm = 0x128
movl %ecx, 0x14(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movq %rdx, 0xb0(%rsp)
movq %rdx, %rdi
movl $0x24, %esi
callq 0x2170
leaq 0xd8(%rsp), %rdi
movq %r15, %rsi
callq 0x4710
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
callq 0x4658
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq %rbx, 0x38(%rsp)
movq $0x0, 0x10(%rbx)
leaq 0x60(%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 0x675e
leaq 0x100(%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 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0x47d0
movq 0x48(%rsp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x5297
xorl %r14d, %r14d
leaq 0xf8(%rsp), %rbx
xorl %r12d, %r12d
movq (%rax,%r14), %rsi
movq %rbx, %rdi
callq 0x590a
movl %r12d, (%rax)
incq %r12
movq 0x48(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %r14
cmpq %r12, %rcx
ja 0x5269
leaq 0x18(%rsp), %rsi
movl $0x0, (%rsi)
leaq 0x60(%rsp), %rdi
callq 0x6afa
leaq 0x18(%rsp), %r13
xorl %ebp, %ebp
movq 0x90(%rsp), %rax
cmpq 0x98(%rsp), %rax
jne 0x52d9
movq 0xa8(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movslq -0x4(%rax), %rax
leaq (%rax,%rax,2), %r14
shlq $0x3, %r14
addq 0x48(%rsp), %r14
movslq %ebp, %rsi
movq 0xb0(%rsp), %rax
addq (%rax), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x590a
movslq (%rax), %r12
shlq $0x5, %r12
movq 0x18(%r14), %rdi
addq %r12, %rdi
leaq 0xadb9(%rip), %rsi      # 0x100d3
callq 0x2090
movl %eax, %ebx
testl %eax, %eax
je 0x53b4
movq 0x18(%r14), %rax
movq 0x8(%rax,%r12), %rcx
testq %rcx, %rcx
je 0x5670
addq %r12, %rax
movq (%rax), %rdx
cmpb $0x72, (%rdx)
jne 0x53d0
addq 0x18(%r14), %r12
movl $0x1, %edx
movq %r13, %rdi
movq %r12, %rsi
movq $-0x1, %rcx
callq 0x21d0
movq %r13, %rdi
callq 0x28e4
movl %eax, %r12d
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x538c
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
movl %r12d, 0xc(%rsp)
movq 0x38(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x545d
movl %r12d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x5467
cmpb $0x0, 0x14(%rsp)
jne 0x55ee
leaq 0xad8f(%rip), %rdi      # 0x10155
callq 0x2260
jmp 0x55ee
testq %rcx, %rcx
je 0x5670
movq (%rax), %rax
cmpb $0x73, (%rax)
jne 0x5670
addq 0x18(%r14), %r12
movl $0x1, %edx
movq %r13, %rdi
movq %r12, %rsi
movq $-0x1, %rcx
callq 0x21d0
movq %r13, %rdi
callq 0x28e4
movl %eax, %r12d
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x5427
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
movl %r12d, 0xc(%rsp)
movq 0x90(%rsp), %rax
movq 0xa0(%rsp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x55c4
movl %r12d, (%rax)
addq $0x4, %rax
movq %rax, 0x90(%rsp)
jmp 0x55d3
leaq 0xc(%rsp), %rdx
callq 0x6d56
movslq 0xc(%rsp), %rcx
movq 0x20(%r15), %rax
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
cmpq $0x0, 0x10(%rax,%rcx)
je 0x5504
xorl %r14d, %r14d
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rdi
cmpq %rdi, %rax
je 0x54a2
addq $-0x4, %rax
jmp 0x54e1
movl $0x200, %esi            # imm = 0x200
callq 0x21b0
movq 0xa8(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0xa8(%rsp)
movq -0x8(%rax), %rax
movq %rax, 0x98(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0xa0(%rsp)
addq $0x1fc, %rax            # imm = 0x1FC
movq %rax, 0x90(%rsp)
incq %r14
movslq 0xc(%rsp), %rcx
movq 0x20(%r15), %rax
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
cmpq %r14, 0x10(%rax,%rcx)
ja 0x5487
addq %rcx, %rax
movb (%rax), %al
movb %al, 0x13(%rsp)
movq 0x90(%rsp), %rax
cmpq 0x98(%rsp), %rax
jne 0x5533
movq 0xa8(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movslq -0x4(%rax), %r12
movq 0x48(%rsp), %r14
leaq 0xf8(%rsp), %rdi
leaq 0x13(%rsp), %rsi
callq 0x590a
leaq (%r12,%r12,2), %rcx
movslq (%rax), %rsi
shlq $0x5, %rsi
addq 0x18(%r14,%rcx,8), %rsi
movl $0x1, %edx
movq %r13, %rdi
movq $-0x1, %rcx
callq 0x21d0
movq %r13, %rdi
callq 0x28e4
movl %eax, 0x44(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x44(%rsp), %rsi
callq 0x6afa
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x55a9
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
cmpb $0x0, 0x14(%rsp)
jne 0x55ee
movl 0xc(%rsp), %esi
leaq 0xab37(%rip), %rdi      # 0x100f2
xorl %eax, %eax
callq 0x2040
jmp 0x55ee
leaq 0x60(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x6e76
cmpb $0x0, 0x14(%rsp)
jne 0x55ec
movl 0xc(%rsp), %esi
leaq 0xab18(%rip), %rdi      # 0x100fd
xorl %eax, %eax
callq 0x2040
incl %ebp
testl %ebx, %ebx
jne 0x52b3
leaq 0x48(%rsp), %rdi
callq 0x58c8
leaq 0xf8(%rsp), %rdi
callq 0x596e
leaq 0x60(%rsp), %rdi
callq 0x59be
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5638
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5659
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x38(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
movq %rax, (%rdi)
leaq 0xaa76(%rip), %rsi      # 0x10107
leaq 0xaa8c(%rip), %rdx      # 0x10124
callq 0x299a
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x27bc
xorl %ebp, %ebp
leaq 0x106f2(%rip), %rsi     # 0x15da8
leaq -0x2eb7(%rip), %rdx     # 0x2806
movq %r14, %rdi
callq 0x22e0
jmp 0x574b
movq %rax, %rbx
jmp 0x5758
movq %rax, %rbx
jmp 0x576f
movq %rax, %rbx
jmp 0x57a9
jmp 0x574b
jmp 0x574b
jmp 0x5728
jmp 0x574b
jmp 0x5728
jmp 0x574b
jmp 0x574b
jmp 0x574b
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x5719
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x5719
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x574e
movq %r14, %rdi
callq 0x2140
jmp 0x574e
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x574e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x574e
jmp 0x574b
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x58c8
leaq 0xf8(%rsp), %rdi
callq 0x596e
leaq 0x60(%rsp), %rdi
callq 0x59be
movq 0x38(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x5788
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x57a9
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x57ca
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x22f0