// File: /workspace/github_c_makefile_star2_O0/sharmaeklavya2[P]cerplag/parser.c
// Function: read_grammar
int read_grammar(FILE* fp)
// returns the number of rules read
{
    int i, j;
    for(i=0; i<NUM_NONTERMS; ++i)
    {
        rule_begin[i] = 10000;
        rule_end[i] = 0;
    }
    for(i=0; i<NUM_RULES; ++i)
    {
        rules[i].lhs = NUM_GS;
        rules[i].head = NULL;
        rules[i].tail = NULL;
    }
    i=0;
    bool lhs = true;
    char str[100];
    while(fscanf(fp, "%s", str) != EOF)
    {
        if(str[0] == '.')
        {
            i++;
            lhs = true;
            continue;
        }
        gsymb_t sid = get_gsymb_id(str);
        if(lhs)
        {
            rules[i].lhs = sid;
            rules[i].head = NULL;
            rules[i].tail = NULL;
            lhs = false;

            int ntsid = get_nt_id(sid);
            if(i < rule_begin[ntsid])
                rule_begin[ntsid] = i;
            if(i+1 > rule_end[ntsid])
                rule_end[ntsid] = i+1;
        }
        else
        {
            RuleNode* n = getRuleNode(sid);
            if(rules[i].head == NULL)
                rules[i].head = n;
            else
                rules[i].tail->next = n;
            rules[i].tail = n;
        }
    }
    for(j=0; j<NUM_NONTERMS; ++j)
    {
        if(rule_begin[j] > NUM_GS)
            fprintf(stderr, "rule_begin[%s, %d] = %d\n", GS_STRS[j + NUM_TOKENS], j, rule_begin[j]);
        if(rule_end[j] <= 0)
            fprintf(stderr, "rule_end[%s, %d] = %d\n", GS_STRS[j + NUM_TOKENS], j, rule_end[j]);
    }
    return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x36, -0xc(%rbp)
jge 0x73eb
movslq -0xc(%rbp), %rcx
leaq 0x14929(%rip), %rax     # 0x1bcf0
movl $0x2710, (%rax,%rcx,4)  # imm = 0x2710
movslq -0xc(%rbp), %rcx
leaq 0x149f7(%rip), %rax     # 0x1bdd0
movl $0x0, (%rax,%rcx,4)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x73b6
movl $0x0, -0xc(%rbp)
cmpl $0x64, -0xc(%rbp)
jge 0x744f
movslq -0xc(%rbp), %rcx
leaq 0x14b8d(%rip), %rax     # 0x1bf90
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x70, (%rax)
movslq -0xc(%rbp), %rcx
leaq 0x14b75(%rip), %rax     # 0x1bf90
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movslq -0xc(%rbp), %rcx
leaq 0x14b5b(%rip), %rax     # 0x1bf90
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x10(%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x73f2
movl $0x0, -0xc(%rbp)
movb $0x1, -0x11(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq 0xe82f(%rip), %rsi      # 0x15c98
movb $0x0, %al
callq 0x3060
cmpl $-0x1, %eax
je 0x75f8
movsbl -0x80(%rbp), %eax
cmpl $0x2e, %eax
jne 0x7491
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movb $0x1, -0x11(%rbp)
jmp 0x745a
leaq -0x80(%rbp), %rdi
callq 0x72f0
movl %eax, -0x84(%rbp)
testb $0x1, -0x11(%rbp)
je 0x756c
movl -0x84(%rbp), %ecx
movslq -0xc(%rbp), %rdx
leaq 0x14ad5(%rip), %rax     # 0x1bf90
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movslq -0xc(%rbp), %rcx
leaq 0x14ac1(%rip), %rax     # 0x1bf90
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movslq -0xc(%rbp), %rcx
leaq 0x14aa7(%rip), %rax     # 0x1bf90
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x10(%rax)
movb $0x0, -0x11(%rbp)
movl -0x84(%rbp), %edi
callq 0x6480
movl %eax, -0x88(%rbp)
movl -0xc(%rbp), %eax
movslq -0x88(%rbp), %rdx
leaq 0x147d2(%rip), %rcx     # 0x1bcf0
cmpl (%rcx,%rdx,4), %eax
jge 0x7537
movl -0xc(%rbp), %edx
movslq -0x88(%rbp), %rcx
leaq 0x147bc(%rip), %rax     # 0x1bcf0
movl %edx, (%rax,%rcx,4)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movslq -0x88(%rbp), %rdx
leaq 0x14885(%rip), %rcx     # 0x1bdd0
cmpl (%rcx,%rdx,4), %eax
jle 0x7567
movl -0xc(%rbp), %edx
addl $0x1, %edx
movslq -0x88(%rbp), %rcx
leaq 0x1486c(%rip), %rax     # 0x1bdd0
movl %edx, (%rax,%rcx,4)
jmp 0x75f3
movl -0x84(%rbp), %edi
callq 0x7350
movq %rax, -0x90(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x14a07(%rip), %rax     # 0x1bf90
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
jne 0x75b6
movq -0x90(%rbp), %rcx
movslq -0xc(%rbp), %rdx
leaq 0x149e7(%rip), %rax     # 0x1bf90
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x75d6
movq -0x90(%rbp), %rcx
movslq -0xc(%rbp), %rdx
leaq 0x149c8(%rip), %rax     # 0x1bf90
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq 0x10(%rax), %rax
movq %rcx, (%rax)
movq -0x90(%rbp), %rcx
movslq -0xc(%rbp), %rdx
leaq 0x149a8(%rip), %rax     # 0x1bf90
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
jmp 0x745a
movl $0x0, -0x10(%rbp)
cmpl $0x36, -0x10(%rbp)
jge 0x76b7
movslq -0x10(%rbp), %rcx
leaq 0x146dc(%rip), %rax     # 0x1bcf0
cmpl $0x70, (%rax,%rcx,4)
jle 0x7658
movq 0x129d7(%rip), %rax     # 0x19ff8
movq (%rax), %rdi
movl -0x10(%rbp), %eax
addl $0x3a, %eax
movslq %eax, %rcx
leaq 0x1313c(%rip), %rax     # 0x1a770
movq (%rax,%rcx,8), %rdx
movl -0x10(%rbp), %ecx
movslq -0x10(%rbp), %rsi
leaq 0x146aa(%rip), %rax     # 0x1bcf0
movl (%rax,%rsi,4), %r8d
leaq 0xd386(%rip), %rsi      # 0x149d7
movb $0x0, %al
callq 0x3120
movslq -0x10(%rbp), %rcx
leaq 0x1476d(%rip), %rax     # 0x1bdd0
cmpl $0x0, (%rax,%rcx,4)
jg 0x76a7
movq 0x12988(%rip), %rax     # 0x19ff8
movq (%rax), %rdi
movl -0x10(%rbp), %eax
addl $0x3a, %eax
movslq %eax, %rcx
leaq 0x130ed(%rip), %rax     # 0x1a770
movq (%rax,%rcx,8), %rdx
movl -0x10(%rbp), %ecx
movslq -0x10(%rbp), %rsi
leaq 0x1473b(%rip), %rax     # 0x1bdd0
movl (%rax,%rsi,4), %r8d
leaq 0xd350(%rip), %rsi      # 0x149f0
movb $0x0, %al
callq 0x3120
jmp 0x76a9
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x75ff
movl -0xc(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)