// File: /workspace/github_c_makefile_star2_O2/Gaurang18[P]Compiler-Project-BITS-Pilani/./parser.c
// Function: parsing_table
void parsing_table(int table[][TERMINALS],int G[][14]){ //To make parse table, from grammar and first and follow sets
    int lhead,head;
    int rule,right,termfirst;
    int alpha,foll;
    int b,term;
    int flag;
    table[0][43] = 1;
    table[25][14] = 47;
    for(rule = 0;rule < TOTAL_RULES;rule++){
        flag = 0;
        lhead = G[rule][0];
        head = lhead-1;
        for(right = 1; right < 14; right++){  
            alpha = G[rule][right];
            if(alpha == -1){
                break;
            }
            if(alpha == EPLS){
                flag =1;
                break;
            }
            if(alpha > NON_TERMINALS){
                table[head][alpha - NON_TERMINALS] = rule+1;
                break;
            }
            for(termfirst = 0; termfirst < size_of(first[alpha-1]); termfirst++){

                term = first[alpha-1][termfirst];
                if (term != 109 && term > NON_TERMINALS){
                    table[head][term - NON_TERMINALS] = rule+1;
                }
            }
            if(!epsInFirst(alpha, first))
                break;
            else if(epsInFirst(alpha, first) && G[rule][right+1] == -1){
                flag = 1;
                break;
            }else{

            }
        }

        if(flag == 1){
            for(foll = 0; foll < size_of(follow[head]); foll++){
                    b = follow[head][foll];
                    if(b==-1){
                        break;
                    }
                    if(b==0){
                        table[head][b] = rule+1;
                    }
                    else{
                        table[head][b-NON_TERMINALS] = rule+1;
                    }
                }
        }
    }   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, -0x38(%rbp)
movl $0x1, 0xac(%rdi)
movq %rdi, -0x30(%rbp)
movl $0x2f, 0x16e0(%rdi)
xorl %r13d, %r13d
cmpq $0x5e, %r13
je 0x3dae
imulq $0x38, %r13, %rdx
movq -0x38(%rbp), %rcx
movl (%rcx,%rdx), %eax
decl %eax
incq %r13
cltq
addq %rcx, %rdx
movq %rax, -0x40(%rbp)
imulq $0xe8, %rax, %rbx
addq -0x30(%rbp), %rbx
pushq $0x1
popq %rax
movq %rdx, -0x48(%rbp)
cmpq $0xe, %rax
je 0x3c62
movslq (%rdx,%rax,4), %rcx
cmpq $-0x1, %rcx
je 0x3c62
cmpl $0x6d, %ecx
je 0x3d45
cmpl $0x33, %ecx
jg 0x3d9a
movq %rax, -0x50(%rbp)
movq %r13, %r12
movq %rcx, -0x58(%rbp)
imulq $0x2c, %rcx, %r15
leaq 0x8631(%rip), %rax      # 0xc300
leaq (%r15,%rax), %r13
addq $-0x2c, %r13
addq $-0x2c, %r15
xorl %r14d, %r14d
movq %r13, %rdi
callq 0x2f67
cltq
cmpq %rax, %r14
jge 0x3d17
leaq (%r15,%r14,4), %rax
leaq 0x8608(%rip), %rcx      # 0xc300
movl (%rcx,%rax), %eax
cmpl $0x6d, %eax
sete %cl
cmpl $0x34, %eax
setl %dl
orb %cl, %dl
jne 0x3d12
addl $-0x33, %eax
movl %r12d, (%rbx,%rax,4)
incq %r14
jmp 0x3cde
movq -0x58(%rbp), %rdi
leaq 0x85de(%rip), %rsi      # 0xc300
callq 0x2fe3
testl %eax, %eax
je 0x3da6
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rax
cmpl $-0x1, 0x4(%rdx,%rax,4)
leaq 0x1(%rax), %rax
movq %r12, %r13
jne 0x3c97
imulq $0x3c, -0x40(%rbp), %r15
leaq 0x8e7f(%rip), %rax      # 0xcbd0
leaq (%rax,%r15), %r12
xorl %r14d, %r14d
movq %r12, %rdi
callq 0x2f67
cltq
cmpq %rax, %r14
jge 0x3c62
leaq (%r15,%r14,4), %rax
leaq 0x8e5a(%rip), %rcx      # 0xcbd0
movslq (%rcx,%rax), %rax
testq %rax, %rax
je 0x3d92
cmpl $-0x1, %eax
je 0x3c62
movl %r13d, -0xcc(%rbx,%rax,4)
jmp 0x3d95
movl %r13d, (%rbx)
incq %r14
jmp 0x3d58
addl $-0x33, %ecx
movl %r13d, (%rbx,%rcx,4)
jmp 0x3c62
movq %r12, %r13
jmp 0x3c62
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq