// File: /workspace/github_c_makefile_star2_O2/gregtour[P]minimal-compiler/grammar.c
// Function: PrintGrammar
void PrintGrammar(GRAMMAR_TABLE table)
{
    int i, j, token;
    printf("Grammar Table\n");
    printf("-------------\n");

    // symbols
    printf("SYMBOLS\n");
    j = 0;
    for (i = 0; i < table.numSymbols; i++)
    {
        printf("%i. '%s'\n", i+1, &table.symbols[j]);
        j = j + strlen(&table.symbols[j]) + 1;
    }

    // tokens
    printf("TOKENS\n");
    j = 0;
    for (i = 0; i < table.numTokens; i++)
    {
        printf("%i. '%s'\n", i+1, &table.tokens[j]);
        j = j + strlen(&table.tokens[j]) + 1;
    }

    // rules
    printf("RULES\n");
    for (i = 0; i < table.numRules; i++)
    {
        printf("%i. S%i ::= ", i+1, table.rules[i].lhs & K_VALUE);
        j = 0;
        token = table.rules[i].rhs[0];
        while (token != 0)
        {
            if (token & K_SYMBOL)
            {
                token ^= K_SYMBOL;
                printf("S");
            }
            else if (table.rules[i].rhs[j] & K_TOKEN)
            {
                token ^= K_TOKEN;
                printf("T");
            }
            printf("%i ", token);
            j++;
            token = table.rules[i].rhs[j];
        }
        printf("\n");
    }
    printf("\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x10(%rbp), %rbx
leaq 0x3bbf(%rip), %rdi      # 0x73ef
callq 0x2050
leaq 0x3d69(%rip), %rdi      # 0x75a5
callq 0x2050
leaq 0x3bb5(%rip), %rdi      # 0x73fd
callq 0x2050
movl (%rbx), %r13d
movq 0x8(%rbx), %r12
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
negl %r13d
pushq $0x1
popq %rbx
xorl %eax, %eax
leal (%rbx,%r13), %ecx
cmpl $0x1, %ecx
je 0x389a
movslq %eax, %r14
leaq (%r12,%r14), %r15
leaq 0x3aff(%rip), %rdi      # 0x737b
movl %ebx, %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2090
movq %r15, %rdi
callq 0x2080
addq %r14, %rax
incq %rax
incl %ebx
jmp 0x3865
leaq 0x3b64(%rip), %rdi      # 0x7405
callq 0x2050
leaq 0x10(%rbp), %rax
movl 0x10(%rax), %r13d
movq 0x18(%rax), %r12
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
negl %r13d
pushq $0x1
popq %rbx
xorl %eax, %eax
leal (%rbx,%r13), %ecx
cmpl $0x1, %ecx
je 0x38f8
movslq %eax, %r14
leaq (%r12,%r14), %r15
leaq 0x3aa1(%rip), %rdi      # 0x737b
movl %ebx, %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2090
movq %r15, %rdi
callq 0x2080
addq %r14, %rax
incq %rax
incl %ebx
jmp 0x38c3
leaq 0x3b0d(%rip), %rdi      # 0x740c
callq 0x2050
leaq 0x10(%rbp), %rax
movl 0x20(%rax), %ecx
movq 0x28(%rax), %rax
movq %rax, -0x30(%rbp)
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
movq %rcx, -0x38(%rbp)
leaq 0x397a(%rip), %r15      # 0x729f
pushq $0x53
popq %rbx
xorl %eax, %eax
cmpq -0x38(%rbp), %rax
je 0x39ce
leaq 0x1(%rax), %rsi
shlq $0x4, %rax
movq -0x30(%rbp), %rcx
leaq (%rcx,%rax), %r12
addq $0x8, %r12
movl -0x8(%r12), %edx
movl $0xfff, %eax            # imm = 0xFFF
andl %eax, %edx
leaq 0x3a2a(%rip), %rdi      # 0x7385
movq %rsi, -0x40(%rbp)
xorl %eax, %eax
callq 0x2090
movq (%r12), %rax
pushq $0x4
popq %r14
movq %rax, %rcx
movl (%rcx), %r13d
testl %r13d, %r13d
je 0x39bd
btl $0xc, %r13d
jb 0x3994
testb $0x20, -0x3(%rax,%r14)
je 0x39a2
xorl $0x2000, %r13d          # imm = 0x2000
pushq $0x54
popq %rdi
jmp 0x399d
andl $0xffffefff, %r13d      # imm = 0xFFFFEFFF
movl %ebx, %edi
callq 0x2040
movq %r15, %rdi
movl %r13d, %esi
xorl %eax, %eax
callq 0x2090
movq (%r12), %rax
leaq (%rax,%r14), %rcx
addq $0x4, %r14
jmp 0x3971
pushq $0xa
popq %rdi
callq 0x2040
movq -0x40(%rbp), %rax
jmp 0x392a
pushq $0xa
popq %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2040