// File: ronakshah725[P]SLR1Parser_C/parser1.cpp
// Function: slr(char (*) [16])
int slr(char x[row][col]){
    
    
    int accepted = 0;
    int token = getToken();
    int state = 1;
    s.push(to_string(state));
    int method = getAction(state, token, x);
    int val = getValueFromMatrix(state, token);
    string action = "";
    method = getAction(state, token, x);
    action = x[val];
    int i = 0;
    
    
    while(action!="0" || action!="9999"){
    
        if (method==shift){
            s.push(string(1,tokens[token]));
            
            s.push(action);
            token = getToken();
            
        }
        else if (method == reduce){
            
            string al = x[val];
            char first = al[2];
            char nt = al[0];
            while(s.top()[0]!=first){
                s.pop();
            }
            s.pop();
            int gotostate = stoi(s.top());
            int sy = getSym(nt);
            int gotoval = getValueFromMatrix(gotostate, sy);
            s.push(string(1,nt));
            s.push(x[gotoval]);
        }
        
        
        
        state = stoi(s.top());
        method = getAction(state, token, x);
        val = getValueFromMatrix(state, token);
        action = x[val];
        i++;
        if(action=="9999"){
            break;
        }
        
    }
    
    if(action=="0")
        accepted =-1;
    else if(action=="9999")
        accepted = 1;
    
   

    
    
    
    return accepted;

    
    

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
callq 0x27d0
movl %eax, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %esi
leaq -0x38(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x3310
movq -0x128(%rbp), %rsi
leaq 0x8992(%rip), %rdi      # 0xb208
callq 0x32e0
jmp 0x287d
leaq -0x38(%rbp), %rdi
callq 0x2140
movl -0x14(%rbp), %edi
movl -0x10(%rbp), %esi
movq -0x8(%rbp), %rdx
callq 0x2640
movl %eax, -0x48(%rbp)
movl -0x14(%rbp), %edi
movl -0x10(%rbp), %esi
callq 0x25e0
movl %eax, -0x4c(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x2350
movq -0x130(%rbp), %rdx
leaq 0x47c5(%rip), %rsi      # 0x7089
leaq -0x70(%rbp), %rdi
callq 0x2240
jmp 0x28cf
leaq -0x71(%rbp), %rdi
callq 0x21d0
movl -0x14(%rbp), %edi
movl -0x10(%rbp), %esi
movq -0x8(%rbp), %rdx
callq 0x2640
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rsi
movslq -0x4c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x2230
jmp 0x2904
movl $0x0, -0x78(%rbp)
leaq 0x4769(%rip), %rsi      # 0x707b
leaq -0x70(%rbp), %rdi
callq 0x3430
movb %al, -0x131(%rbp)
jmp 0x2923
movb -0x131(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x132(%rbp)
jne 0x295e
jmp 0x2938
leaq 0x473e(%rip), %rsi      # 0x707d
leaq -0x70(%rbp), %rdi
callq 0x3430
movb %al, -0x133(%rbp)
jmp 0x2950
movb -0x133(%rbp), %al
movb %al, -0x132(%rbp)
jmp 0x295e
movb -0x132(%rbp), %al
testb $0x1, %al
jne 0x296d
jmp 0x2e48
cmpl $0x37, -0x48(%rbp)
jne 0x2a95
movslq -0x10(%rbp), %rax
leaq 0x8856(%rip), %rcx      # 0xb1d8
movsbl (%rax,%rcx), %eax
movl %eax, -0x144(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x2350
movl -0x144(%rbp), %edx
movq -0x140(%rbp), %rcx
leaq -0x98(%rbp), %rdi
movl $0x1, %esi
callq 0x2150
jmp 0x29bf
leaq 0x8842(%rip), %rdi      # 0xb208
leaq -0x98(%rbp), %rsi
callq 0x32e0
jmp 0x29d4
leaq -0x98(%rbp), %rdi
callq 0x2140
leaq -0x99(%rbp), %rdi
callq 0x21d0
leaq 0x8815(%rip), %rdi      # 0xb208
leaq -0x70(%rbp), %rsi
callq 0x3460
jmp 0x29fe
callq 0x27d0
movl %eax, -0x148(%rbp)
jmp 0x2a0b
movl -0x148(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x2da0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2140
jmp 0x2ecc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x21d0
jmp 0x2ecc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2ec3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2a84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x2140
leaq -0x99(%rbp), %rdi
callq 0x21d0
jmp 0x2ec3
cmpl $0x4d, -0x48(%rbp)
jne 0x2d9e
movq -0x8(%rbp), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x158(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x2350
movq -0x158(%rbp), %rsi
movq -0x150(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
callq 0x2240
jmp 0x2ae4
leaq -0xc1(%rbp), %rdi
callq 0x21d0
leaq -0xc0(%rbp), %rdi
movl $0x2, %esi
callq 0x2380
movq %rax, -0x160(%rbp)
jmp 0x2b0a
movq -0x160(%rbp), %rax
movb (%rax), %al
movb %al, -0xc2(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0xc0(%rbp), %rdi
callq 0x2380
movq %rax, -0x168(%rbp)
jmp 0x2b32
movq -0x168(%rbp), %rax
movb (%rax), %al
movb %al, -0xc3(%rbp)
leaq 0x86c0(%rip), %rdi      # 0xb208
callq 0x3490
movq %rax, -0x170(%rbp)
jmp 0x2b56
movq -0x170(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2380
movq %rax, -0x178(%rbp)
jmp 0x2b6f
movq -0x178(%rbp), %rax
movsbl (%rax), %eax
movsbl -0xc2(%rbp), %ecx
cmpl %ecx, %eax
je 0x2bc2
leaq 0x867d(%rip), %rdi      # 0xb208
callq 0x34b0
jmp 0x2b92
jmp 0x2b41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xc1(%rbp), %rdi
callq 0x21d0
jmp 0x2ec3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2d8d
leaq 0x863f(%rip), %rdi      # 0xb208
callq 0x34b0
jmp 0x2bd0
leaq 0x8631(%rip), %rdi      # 0xb208
callq 0x3490
movq %rax, -0x180(%rbp)
jmp 0x2be5
movq -0x180(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x34d0
movl %eax, -0x184(%rbp)
jmp 0x2c02
movl -0x184(%rbp), %eax
movl %eax, -0xc8(%rbp)
movsbl -0xc3(%rbp), %edi
callq 0x27e0
movl %eax, -0xcc(%rbp)
movl -0xc8(%rbp), %edi
movl -0xcc(%rbp), %esi
callq 0x25e0
movl %eax, -0xd0(%rbp)
movsbl -0xc3(%rbp), %eax
movl %eax, -0x194(%rbp)
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x2350
movl -0x194(%rbp), %edx
movq -0x190(%rbp), %rcx
leaq -0xf0(%rbp), %rdi
movl $0x1, %esi
callq 0x2150
jmp 0x2c77
leaq 0x858a(%rip), %rdi      # 0xb208
leaq -0xf0(%rbp), %rsi
callq 0x32e0
jmp 0x2c8c
leaq -0xf0(%rbp), %rdi
callq 0x2140
leaq -0xf1(%rbp), %rdi
callq 0x21d0
movq -0x8(%rbp), %rax
movslq -0xd0(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x1a8(%rbp)
leaq -0x119(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x2350
movq -0x1a8(%rbp), %rsi
movq -0x1a0(%rbp), %rdx
leaq -0x118(%rbp), %rdi
callq 0x2240
jmp 0x2cec
leaq 0x8515(%rip), %rdi      # 0xb208
leaq -0x118(%rbp), %rsi
callq 0x32e0
jmp 0x2d01
leaq -0x118(%rbp), %rdi
callq 0x2140
leaq -0x119(%rbp), %rdi
callq 0x21d0
leaq -0xc0(%rbp), %rdi
callq 0x2140
jmp 0x2d9e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2d4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x2140
leaq -0xf1(%rbp), %rdi
callq 0x21d0
jmp 0x2d8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2d81
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x2140
leaq -0x119(%rbp), %rdi
callq 0x21d0
leaq -0xc0(%rbp), %rdi
callq 0x2140
jmp 0x2ec3
jmp 0x2da0
leaq 0x8461(%rip), %rdi      # 0xb208
callq 0x3490
movq %rax, -0x1b0(%rbp)
jmp 0x2db5
movq -0x1b0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x34d0
movl %eax, -0x1b4(%rbp)
jmp 0x2dd2
movl -0x1b4(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %edi
movl -0x10(%rbp), %esi
movq -0x8(%rbp), %rdx
callq 0x2640
movl %eax, -0x48(%rbp)
movl -0x14(%rbp), %edi
movl -0x10(%rbp), %esi
callq 0x25e0
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rsi
movslq -0x4c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x2230
jmp 0x2e15
movl -0x78(%rbp), %eax
incl %eax
movl %eax, -0x78(%rbp)
leaq 0x4259(%rip), %rsi      # 0x707d
leaq -0x70(%rbp), %rdi
callq 0x3510
movb %al, -0x1b5(%rbp)
jmp 0x2e35
movb -0x1b5(%rbp), %al
testb $0x1, %al
jne 0x2e41
jmp 0x2e43
jmp 0x2e48
jmp 0x290b
leaq 0x422c(%rip), %rsi      # 0x707b
leaq -0x70(%rbp), %rdi
callq 0x3510
movb %al, -0x1b6(%rbp)
jmp 0x2e60
movb -0x1b6(%rbp), %al
testb $0x1, %al
jne 0x2e6c
jmp 0x2e75
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ea2
leaq 0x4201(%rip), %rsi      # 0x707d
leaq -0x70(%rbp), %rdi
callq 0x3510
movb %al, -0x1b7(%rbp)
jmp 0x2e8d
movb -0x1b7(%rbp), %al
testb $0x1, %al
jne 0x2e99
jmp 0x2ea0
movl $0x1, -0xc(%rbp)
jmp 0x2ea2
movl -0xc(%rbp), %eax
movl %eax, -0x1bc(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x2140
movl -0x1bc(%rbp), %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x70(%rbp), %rdi
callq 0x2140
movq -0x40(%rbp), %rdi
callq 0x2340
nopw %cs:(%rax,%rax)