// File: /workspace/github_c_makefile_star2_O3/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 0x4a93(%rip), %rdi      # 0x83ef
callq 0x2050
leaq 0x4c3d(%rip), %rdi      # 0x85a5
callq 0x2050
leaq 0x4a89(%rip), %rdi      # 0x83fd
callq 0x2050
movl (%rbx), %r13d
testl %r13d, %r13d
jle 0x39d0
leaq 0x10(%rbp), %rax
movq 0x8(%rax), %r12
negl %r13d
movl $0x1, %r14d
xorl %eax, %eax
movslq %eax, %rbx
leaq (%r12,%rbx), %r15
leaq 0x49d9(%rip), %rdi      # 0x837b
movl %r14d, %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2090
movq %r15, %rdi
callq 0x2080
addq %rbx, %rax
incq %rax
leal (%r14,%r13), %ecx
incl %ecx
movl %r14d, %edx
incl %edx
movl %edx, %r14d
cmpl $0x1, %ecx
jne 0x3994
leaq 0x4a2e(%rip), %rdi      # 0x8405
callq 0x2050
leaq 0x10(%rbp), %rax
movl 0x10(%rax), %r13d
testl %r13d, %r13d
jle 0x3a34
movq 0x18(%rax), %r12
negl %r13d
movl $0x1, %r14d
xorl %eax, %eax
movslq %eax, %rbx
leaq (%r12,%rbx), %r15
leaq 0x4975(%rip), %rdi      # 0x837b
movl %r14d, %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2090
movq %r15, %rdi
callq 0x2080
addq %rbx, %rax
incq %rax
leal (%r14,%r13), %ecx
incl %ecx
movl %r14d, %edx
incl %edx
movl %edx, %r14d
cmpl $0x1, %ecx
jne 0x39f8
leaq 0x49d1(%rip), %rdi      # 0x840c
callq 0x2050
leaq 0x10(%rbp), %rax
movslq 0x20(%rax), %rcx
movq %rcx, -0x38(%rbp)
testq %rcx, %rcx
jle 0x3b0d
movq 0x28(%rax), %rax
movq %rax, -0x30(%rbp)
leaq 0x483b(%rip), %r14      # 0x829f
xorl %r15d, %r15d
movq %r15, %rbx
incq %r15
shlq $0x4, %rbx
movq -0x30(%rbp), %r12
movl (%r12,%rbx), %edx
movl $0xfff, %eax            # imm = 0xFFF
andl %eax, %edx
leaq 0x48fe(%rip), %rdi      # 0x8385
movl %r15d, %esi
xorl %eax, %eax
callq 0x2090
movq 0x8(%r12,%rbx), %rax
movl (%rax), %r12d
testl %r12d, %r12d
je 0x3af9
movq -0x30(%rbp), %rax
leaq (%rax,%rbx), %r13
addq $0x8, %r13
movl $0x4, %ebx
btl $0xc, %r12d
jb 0x3ac9
btl $0xd, %r12d
jae 0x3adb
movl $0x54, %edi
movl $0xffffcfff, %eax       # imm = 0xFFFFCFFF
jmp 0x3ad3
movl $0x53, %edi
movl $0xffffefff, %eax       # imm = 0xFFFFEFFF
andl %eax, %r12d
callq 0x2040
movq %r14, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x2090
movq (%r13), %rax
movl (%rax,%rbx), %r12d
addq $0x4, %rbx
testl %r12d, %r12d
jne 0x3aaf
movl $0xa, %edi
callq 0x2040
cmpq -0x38(%rbp), %r15
jne 0x3a67
movl $0xa, %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2040
nopl (%rax)