// File: /workspace/github_c_makefile_star2_O3/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
movq %rsi, -0x30(%rbp)
movabsq $0x100000000, %rax      # imm = 0x100000000
movl $0x1, 0xac(%rdi)
movl $0x2f, 0x16e0(%rdi)
xorl %ecx, %ecx
leaq 0x944c(%rip), %r8       # 0xd300
imulq $0x38, %rcx, %r10
movq -0x30(%rbp), %r11
movl (%r11,%r10), %edx
decl %edx
incq %rcx
movslq %edx, %r9
movl $0x1, %esi
addq %r11, %r10
movslq (%r10,%rsi,4), %rbx
cmpq $-0x1, %rbx
je 0x4026
cmpl $0x6d, %ebx
je 0x3fad
cmpl $0x33, %ebx
jg 0x4016
leaq -0x1(%rbx), %rdx
imulq $0x2c, %rdx, %rdx
leaq (%r8,%rdx), %r14
addq %r8, %rdx
addq $0x4, %rdx
xorl %r12d, %r12d
cmpl $-0x1, (%r14)
je 0x3f25
movq %rdx, %r15
xorl %r13d, %r13d
addq %rax, %r13
cmpl $-0x1, (%r15)
leaq 0x4(%r15), %r15
jne 0x3f12
sarq $0x20, %r13
jmp 0x3f28
xorl %r13d, %r13d
cmpq %r13, %r12
jge 0x3f5d
movl (%r14,%r12,4), %r13d
cmpl $0x6d, %r13d
sete %r15b
cmpl $0x34, %r13d
setl %r11b
orb %r15b, %r11b
jne 0x3f58
addl $-0x33, %r13d
imulq $0xe8, %r9, %r11
addq %rdi, %r11
movl %ecx, (%r11,%r13,4)
incq %r12
jmp 0x3f06
imulq $0x2c, %rbx, %rbx
xorl %r14d, %r14d
leaq (%rbx,%r14,4), %rdx
cmpl $0x6d, (%r8,%rdx)
je 0x3f7d
incq %r14
cmpq $0xb, %r14
jne 0x3f64
jmp 0x4026
xorl %r14d, %r14d
leaq (%rbx,%r14,4), %rdx
cmpl $0x6d, (%r8,%rdx)
je 0x3f96
incq %r14
cmpq $0xb, %r14
jne 0x3f80
jmp 0x3f9e
cmpl $-0x1, 0x4(%r10,%rsi,4)
je 0x3fad
incq %rsi
cmpq $0xe, %rsi
jne 0x3ed0
jmp 0x4026
imulq $0x3c, %r9, %rdx
leaq 0x9c18(%rip), %rsi      # 0xdbd0
leaq (%rsi,%rdx), %r10
imulq $0xe8, %r9, %r9
addq %rdi, %r9
leaq (%rdx,%rsi), %r11
addq $0x4, %r11
xorl %ebx, %ebx
cmpl $-0x1, (%r10)
je 0x3fee
movq %r11, %rdx
xorl %r14d, %r14d
addq %rax, %r14
cmpl $-0x1, (%rdx)
leaq 0x4(%rdx), %rdx
jne 0x3fdc
sarq $0x20, %r14
jmp 0x3ff1
xorl %r14d, %r14d
cmpq %r14, %rbx
jge 0x4026
movslq (%r10,%rbx,4), %rdx
testq %rdx, %rdx
je 0x400e
cmpl $-0x1, %edx
je 0x4026
movl %ecx, -0xcc(%r9,%rdx,4)
jmp 0x4011
movl %ecx, (%r9)
incq %rbx
jmp 0x3fd0
addl $-0x33, %ebx
imulq $0xe8, %r9, %rdx
addq %rdi, %rdx
movl %ecx, (%rdx,%rbx,4)
cmpq $0x5e, %rcx
jne 0x3eb4
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq