// File: /workspace/github_c_makefile_star2_O1/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 0x4ae1(%rip), %rdi      # 0x83ef
callq 0x2050
leaq 0x4c8b(%rip), %rdi      # 0x85a5
callq 0x2050
leaq 0x4ad7(%rip), %rdi      # 0x83fd
callq 0x2050
movl (%rbx), %r13d
testl %r13d, %r13d
jle 0x3982
leaq 0x10(%rbp), %rax
movq 0x8(%rax), %r12
negl %r13d
movl $0x1, %r14d
xorl %eax, %eax
movslq %eax, %rbx
leaq (%r12,%rbx), %r15
leaq 0x4a27(%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 0x3946
leaq 0x4a7c(%rip), %rdi      # 0x8405
callq 0x2050
leaq 0x10(%rbp), %rax
movl 0x10(%rax), %r13d
testl %r13d, %r13d
jle 0x39e6
movq 0x18(%rax), %r12
negl %r13d
movl $0x1, %r14d
xorl %eax, %eax
movslq %eax, %rbx
leaq (%r12,%rbx), %r15
leaq 0x49c3(%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 0x39aa
leaq 0x4a1f(%rip), %rdi      # 0x840c
callq 0x2050
leaq 0x10(%rbp), %rax
movslq 0x20(%rax), %rcx
movq %rcx, -0x38(%rbp)
testq %rcx, %rcx
jle 0x3ac2
movq 0x28(%rax), %rax
movq %rax, -0x30(%rbp)
leaq 0x4889(%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 0x494c(%rip), %rdi      # 0x8385
movl %r15d, %esi
xorl %eax, %eax
callq 0x2090
movq 0x8(%r12,%rbx), %rax
movl (%rax), %r12d
testl %r12d, %r12d
je 0x3aae
movq -0x30(%rbp), %rax
leaq (%rax,%rbx), %r13
addq $0x8, %r13
xorl %ebx, %ebx
btl $0xc, %r12d
jb 0x3a7e
movq (%r13), %rax
testb $0x20, 0x1(%rax,%rbx)
je 0x3a8f
xorl $0x2000, %r12d          # imm = 0x2000
movl $0x54, %edi
jmp 0x3a8a
andl $0xffffefff, %r12d      # imm = 0xFFFFEFFF
movl $0x53, %edi
callq 0x2040
movq %r14, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x2090
movq (%r13), %rax
movl 0x4(%rax,%rbx), %r12d
addq $0x4, %rbx
testl %r12d, %r12d
jne 0x3a5e
movl $0xa, %edi
callq 0x2040
cmpq -0x38(%rbp), %r15
jne 0x3a19
movl $0xa, %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2040
nop