// File: /workspace/github_c_makefile_star2_O1/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 %r8d, %r8d
leaq 0x93cf(%rip), %rdx      # 0xd300
imulq $0x38, %r8, %r11
movq -0x30(%rbp), %rcx
movslq (%rcx,%r11), %r10
decq %r10
movq %r8, -0x38(%rbp)
incq %r8
movl $0x1, %ebx
addq %rcx, %r11
movslq (%r11,%rbx,4), %r14
cmpq $-0x1, %r14
je 0x40d4
cmpl $0x6d, %r14d
je 0x4047
cmpl $0x33, %r14d
jg 0x40b9
leaq -0x1(%r14), %rcx
imulq $0x2c, %rcx, %rcx
leaq (%rdx,%rcx), %r15
leaq (%rcx,%rdx), %r9
addq $0x4, %r9
xorl %r13d, %r13d
cmpl $-0x1, (%r15)
je 0x3fa8
movq %r9, %r12
xorl %ecx, %ecx
addq %rax, %rcx
cmpl $-0x1, (%r12)
leaq 0x4(%r12), %r12
jne 0x3f93
sarq $0x20, %rcx
jmp 0x3faa
xorl %ecx, %ecx
cmpq %rcx, %r13
jge 0x3fdf
movslq (%r15,%r13,4), %rcx
cmpq $0x34, %rcx
setl %r12b
cmpq $0x6d, %rcx
sete %sil
orb %r12b, %sil
jne 0x3fda
imulq $0xe8, %r10, %rsi
addq %rdi, %rsi
movl %r8d, -0xcc(%rsi,%rcx,4)
incq %r13
jmp 0x3f88
imulq $0x2c, %r14, %r14
xorl %ecx, %ecx
leaq (%r14,%rcx,4), %rsi
movl (%rdx,%rsi), %r9d
cmpl $0x6d, %r9d
je 0x4000
leaq 0x1(%rcx), %rsi
cmpq $0xa, %rcx
movq %rsi, %rcx
jne 0x3fe5
cmpl $0x6d, %r9d
jne 0x40d4
xorl %ecx, %ecx
leaq (%r14,%rcx,4), %rsi
movl (%rdx,%rsi), %r9d
cmpl $0x6d, %r9d
je 0x4027
leaq 0x1(%rcx), %rsi
cmpq $0xa, %rcx
movq %rsi, %rcx
jne 0x400c
cmpl $0x6d, %r9d
jne 0x4035
cmpl $-0x1, 0x4(%r11,%rbx,4)
je 0x4047
incq %rbx
cmpq $0xe, %rbx
jne 0x3f4f
jmp 0x40d4
movslq %r10d, %rcx
imulq $0x3c, %rcx, %rsi
leaq 0x9b7b(%rip), %rbx      # 0xdbd0
leaq (%rbx,%rsi), %r9
imulq $0xe8, %rcx, %r10
leaq (%rdi,%r10), %r11
addq %rsi, %rbx
addq $0x4, %rbx
addq %rdi, %r10
xorl %r14d, %r14d
cmpl $-0x1, (%r9)
je 0x408e
movq %rbx, %rsi
xorl %ecx, %ecx
addq %rax, %rcx
cmpl $-0x1, (%rsi)
leaq 0x4(%rsi), %rsi
jne 0x407c
sarq $0x20, %rcx
jmp 0x4090
xorl %ecx, %ecx
cmpq %rcx, %r14
jge 0x40d4
movslq (%r9,%r14,4), %rcx
movq %r11, %rsi
testq %rcx, %rcx
je 0x40b1
cmpl $-0x1, %ecx
je 0x40d4
leaq (%r10,%rcx,4), %rsi
addq $-0xcc, %rsi
movl %r8d, (%rsi)
incq %r14
jmp 0x4071
movslq %r10d, %rcx
addl $-0x33, %r14d
imulq $0xe8, %rcx, %rcx
addq %rdi, %rcx
movq -0x38(%rbp), %rsi
incl %esi
movl %esi, (%rcx,%r14,4)
cmpq $0x5e, %r8
jne 0x3f31
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq