// File: /workspace/github_c_makefile_star2_O0/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
subq $0x30, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq 0x6044(%rip), %rdi      # 0xb3db
movb $0x0, %al
callq 0x2070
leaq 0x61f7(%rip), %rdi      # 0xb59c
movb $0x0, %al
callq 0x2070
leaq 0x6037(%rip), %rdi      # 0xb3ea
movb $0x0, %al
callq 0x2070
movl $0x0, -0x8(%rbp)
movl $0x0, -0x4(%rbp)
movq -0x18(%rbp), %rcx
movl -0x4(%rbp), %eax
cmpl (%rcx), %eax
jge 0x542e
movq -0x18(%rbp), %rax
movl -0x4(%rbp), %esi
addl $0x1, %esi
movq 0x8(%rax), %rdx
movslq -0x8(%rbp), %rax
addq %rax, %rdx
leaq 0x6004(%rip), %rdi      # 0xb3f3
movb $0x0, %al
callq 0x2070
movq -0x18(%rbp), %rax
movslq -0x8(%rbp), %rcx
movq %rcx, -0x20(%rbp)
movq 0x8(%rax), %rdi
movslq -0x8(%rbp), %rax
addq %rax, %rdi
callq 0x2060
movq %rax, %rcx
movq -0x20(%rbp), %rax
addq %rcx, %rax
addq $0x1, %rax
movl %eax, -0x8(%rbp)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x53c8
leaq 0x5fc8(%rip), %rdi      # 0xb3fd
movb $0x0, %al
callq 0x2070
movl $0x0, -0x8(%rbp)
movl $0x0, -0x4(%rbp)
movq -0x18(%rbp), %rcx
movl -0x4(%rbp), %eax
cmpl 0x10(%rcx), %eax
jge 0x54b1
movq -0x18(%rbp), %rax
movl -0x4(%rbp), %esi
addl $0x1, %esi
movq 0x18(%rax), %rdx
movslq -0x8(%rbp), %rax
addq %rax, %rdx
leaq 0x5f81(%rip), %rdi      # 0xb3f3
movb $0x0, %al
callq 0x2070
movq -0x18(%rbp), %rax
movslq -0x8(%rbp), %rcx
movq %rcx, -0x28(%rbp)
movq 0x18(%rax), %rdi
movslq -0x8(%rbp), %rax
addq %rax, %rdi
callq 0x2060
movq %rax, %rcx
movq -0x28(%rbp), %rax
addq %rcx, %rax
addq $0x1, %rax
movl %eax, -0x8(%rbp)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x544a
leaq 0x5f4d(%rip), %rdi      # 0xb405
movb $0x0, %al
callq 0x2070
movl $0x0, -0x4(%rbp)
movq -0x18(%rbp), %rcx
movl -0x4(%rbp), %eax
cmpl 0x20(%rcx), %eax
jge 0x55f9
movq -0x18(%rbp), %rax
movl -0x4(%rbp), %esi
addl $0x1, %esi
movq 0x28(%rax), %rax
movslq -0x4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %edx
andl $0xfff, %edx            # imm = 0xFFF
leaq 0x5f0e(%rip), %rdi      # 0xb40c
movb $0x0, %al
callq 0x2070
movq -0x18(%rbp), %rax
movl $0x0, -0x8(%rbp)
movq 0x28(%rax), %rax
movslq -0x4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x55dd
movl -0xc(%rbp), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0x555a
movl -0xc(%rbp), %eax
xorl $0x1000, %eax           # imm = 0x1000
movl %eax, -0xc(%rbp)
leaq 0x5ec8(%rip), %rdi      # 0xb419
movb $0x0, %al
callq 0x2070
jmp 0x559d
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x8(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x559b
movl -0xc(%rbp), %eax
xorl $0x2000, %eax           # imm = 0x2000
movl %eax, -0xc(%rbp)
leaq 0x633e(%rip), %rdi      # 0xb8d2
movb $0x0, %al
callq 0x2070
jmp 0x559d
movl -0xc(%rbp), %esi
leaq 0x5d35(%rip), %rdi      # 0xb2dc
movb $0x0, %al
callq 0x2070
movq -0x18(%rbp), %rax
movl -0x8(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x8(%rbp)
movq 0x28(%rax), %rax
movslq -0x4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x8(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xc(%rbp)
jmp 0x5528
leaq 0x5df5(%rip), %rdi      # 0xb3d9
movb $0x0, %al
callq 0x2070
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x54c6
leaq 0x5dd9(%rip), %rdi      # 0xb3d9
movb $0x0, %al
callq 0x2070
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)