// File: /workspace/github_c_makefile_star2_O0/macournoyer[P]peg/compile.c
// Function: consumesInput
int consumesInput(Node *node)
{
  if (!node) return 0;

  switch (node->type)
    {
    case Rule:
      {
	int result= 0;
	if (RuleReached & node->rule.flags)
	  fprintf(stderr, "possible infinite left recursion in rule '%s'\n", node->rule.name);
	else
	  {
	    node->rule.flags |= RuleReached;
	    result= consumesInput(node->rule.expression);
	    node->rule.flags &= ~RuleReached;
	  }
	return result;
      }
      break;

    case Dot:		return 1;
    case Name:		return consumesInput(node->name.rule);
    case Character:
    case String:	return strlen(node->string.value) > 0;
    case Class:		return 1;
    case Action:	return 0;
    case Predicate:	return 0;

    case Alternate:
      {
	Node *n;
	for (n= node->alternate.first;  n;  n= n->alternate.next)
	  if (!consumesInput(n))
	    return 0;
      }
      return 1;

    case Sequence:
      {
	Node *n;
	for (n= node->alternate.first;  n;  n= n->alternate.next)
	  if (consumesInput(n))
	    return 1;
      }
      return 0;

    case PeekFor:	return 0;
    case PeekNot:	return 0;
    case Query:		return 0;
    case Star:		return 0;
    case Plus:		return consumesInput(node->plus.element);

    default:
      fprintf(stderr, "\nconsumesInput: illegal node type %d\n", node->type);
      exit(1);
    }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x527f
movl $0x0, -0x4(%rbp)
jmp 0x5467
movq -0x10(%rbp), %rax
movl (%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0xf, %eax
ja 0x543f
movq -0x30(%rbp), %rax
leaq 0x2367(%rip), %rcx      # 0x7608
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x52e2
movq 0x6d31(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x245b(%rip), %rsi      # 0x7734
movb $0x0, %al
callq 0x10c0
jmp 0x530c
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x2c(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x5260
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %ecx
andl $-0x3, %ecx
movl %ecx, 0x2c(%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5467
movl $0x1, -0x4(%rbp)
jmp 0x5467
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x5260
movl %eax, -0x4(%rbp)
jmp 0x5467
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1040
cmpq $0x0, %rax
seta %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x5467
movl $0x1, -0x4(%rbp)
jmp 0x5467
movl $0x0, -0x4(%rbp)
jmp 0x5467
movl $0x0, -0x4(%rbp)
jmp 0x5467
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x53ba
movq -0x20(%rbp), %rdi
callq 0x5260
cmpl $0x0, %eax
jne 0x53aa
movl $0x0, -0x4(%rbp)
jmp 0x5467
jmp 0x53ac
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x5389
movl $0x1, -0x4(%rbp)
jmp 0x5467
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x5400
movq -0x28(%rbp), %rdi
callq 0x5260
cmpl $0x0, %eax
je 0x53f0
movl $0x1, -0x4(%rbp)
jmp 0x5467
jmp 0x53f2
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x53d2
movl $0x0, -0x4(%rbp)
jmp 0x5467
movl $0x0, -0x4(%rbp)
jmp 0x5467
movl $0x0, -0x4(%rbp)
jmp 0x5467
movl $0x0, -0x4(%rbp)
jmp 0x5467
movl $0x0, -0x4(%rbp)
jmp 0x5467
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x5260
movl %eax, -0x4(%rbp)
jmp 0x5467
movq 0x6bb2(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0x230d(%rip), %rsi      # 0x7763
movb $0x0, %al
callq 0x10c0
movl $0x1, %edi
callq 0x1170
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq