// File: /workspace/github_c_makefile_star2_O1/macournoyer[P]peg/compile.c
// Function: Node_compile_c_ko
static void Node_compile_c_ko(Node *node, int ko)
{
  assert(node);
  switch (node->type)
    {
    case Rule:
      fprintf(stderr, "\ninternal error #1 (%s)\n", node->rule.name);
      exit(1);
      break;

    case Dot:
      fprintf(output, "  if (!yymatchDot()) goto l%d;", ko);
      break;

    case Name:
      fprintf(output, "  if (!yy_%s()) goto l%d;", node->name.rule->rule.name, ko);
      if (node->name.variable)
	fprintf(output, "  yyDo(yySet, %d, 0);", node->name.variable->variable.offset);
      break;

    case Character:
    case String:
      {
	int len= strlen(node->string.value);
	if (1 == len || (2 == len && '\\' == node->string.value[0]))
	  fprintf(output, "  if (!yymatchChar('%s')) goto l%d;", node->string.value, ko);
	else
	  fprintf(output, "  if (!yymatchString(\"%s\")) goto l%d;", node->string.value, ko);
      }
      break;

    case Class:
      fprintf(output, "  if (!yymatchClass((unsigned char *)\"%s\")) goto l%d;", makeCharClass(node->cclass.value), ko);
      break;

    case Action:
      fprintf(output, "  yyDo(yy%s, yybegin, yyend);", node->action.name);
      break;

    case Predicate:
      fprintf(output, "  yyText(yybegin, yyend);  if (!(%s)) goto l%d;", node->action.text, ko);
      break;

    case Alternate:
      {
	int ok= yyl();
	begin();
	save(ok);
	for (node= node->alternate.first;  node;  node= node->alternate.next)
	  if (node->alternate.next)
	    {
	      int next= yyl();
	      Node_compile_c_ko(node, next);
	      jump(ok);
	      label(next);
	      restore(ok);
	    }
	  else
	    Node_compile_c_ko(node, ko);
	end();
	label(ok);
      }
      break;

    case Sequence:
      for (node= node->sequence.first;  node;  node= node->sequence.next)
	Node_compile_c_ko(node, ko);
      break;

    case PeekFor:
      {
	int ok= yyl();
	begin();
	save(ok);
	Node_compile_c_ko(node->peekFor.element, ko);
	restore(ok);
	end();
      }
      break;

    case PeekNot:
      {
	int ok= yyl();
	begin();
	save(ok);
	Node_compile_c_ko(node->peekFor.element, ok);
	jump(ko);
	label(ok);
	restore(ok);
	end();
      }
      break;

    case Query:
      {
	int qko= yyl(), qok= yyl();
	begin();
	save(qko);
	Node_compile_c_ko(node->query.element, qko);
	jump(qok);
	label(qko);
	restore(qko);
	end();
	label(qok);
      }
      break;

    case Star:
      {
	int again= yyl(), out= yyl();
	label(again);
	begin();
	save(out);
	Node_compile_c_ko(node->star.element, out);
	jump(again);
	label(out);
	restore(out);
	end();
      }
      break;

    case Plus:
      {
	int again= yyl(), out= yyl();
	Node_compile_c_ko(node->plus.element, ko);
	label(again);
	begin();
	save(out);
	Node_compile_c_ko(node->plus.element, out);
	jump(again);
	label(out);
	restore(out);
	end();
      }
      break;

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
testq %rdi, %rdi
je 0x4780
movq %rdi, %r14
movl (%rdi), %edi
leal -0x1(%rdi), %eax
cmpl $0xf, %eax
ja 0x47a7
movl %esi, %ebx
leaq 0x1531(%rip), %rcx      # 0x55d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r14), %r14
movq %r14, %rdi
callq 0x1040
cmpl $0x1, %eax
je 0x40c4
cmpl $0x2, %eax
jne 0x40d7
cmpb $0x5c, (%r14)
jne 0x40d7
leaq 0x60e5(%rip), %rax      # 0xa1b0
movq (%rax), %rdi
leaq 0x2b50(%rip), %rsi      # 0x6c25
jmp 0x40e8
leaq 0x60d2(%rip), %rax      # 0xa1b0
movq (%rax), %rdi
leaq 0x2b61(%rip), %rsi      # 0x6c49
movq %r14, %rdx
jmp 0x4435
movl 0x80ca(%rip), %ebx      # 0xc1c0
leal 0x1(%rbx), %ebp
addl $0x2, %ebx
movl %ebx, 0x80be(%rip)      # 0xc1c0
leaq 0x60a7(%rip), %r12      # 0xa1b0
movq (%r12), %rdi
leaq 0x2c25(%rip), %r15      # 0x6d39
movq %r15, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rcx
leaq 0x2bf8(%rip), %rdi      # 0x6d23
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r12), %rdi
leaq 0x2a24(%rip), %rsi      # 0x6b69
movl %ebx, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %rdi
movl %ebx, %esi
callq 0x406e
movq (%r12), %rdi
leaq 0x2bc2(%rip), %rsi      # 0x6d28
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rdi
movq %r15, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rdi
leaq 0x2bb9(%rip), %rsi      # 0x6d43
movl %ebx, %edx
movl %ebx, %ecx
jmp 0x45ef
movl 0x8027(%rip), %ebp      # 0xc1c0
incl %ebp
movl %ebp, 0x801f(%rip)      # 0xc1c0
movl %ebx, %r15d
leaq 0x6005(%rip), %rbx      # 0xa1b0
movq (%rbx), %rcx
leaq 0x2b6e(%rip), %rdi      # 0x6d23
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%rbx), %rdi
leaq 0x299b(%rip), %rsi      # 0x6b69
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %rdi
movl %ebp, %esi
callq 0x406e
movq (%rbx), %rdi
leaq 0x2b3a(%rip), %rsi      # 0x6d28
movl %r15d, %edx
xorl %eax, %eax
callq 0x10c0
movq (%rbx), %rdi
leaq 0x2b37(%rip), %rsi      # 0x6d39
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
jmp 0x436e
movl 0x7faa(%rip), %ebp      # 0xc1c0
incl %ebp
movl %ebp, 0x7fa2(%rip)      # 0xc1c0
leaq 0x5f8b(%rip), %r12      # 0xa1b0
movq (%r12), %rcx
leaq 0x2af3(%rip), %rdi      # 0x6d23
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r12), %rdi
leaq 0x291f(%rip), %rsi      # 0x6b69
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x42d8
leaq 0x2ade(%rip), %r13      # 0x6d43
cmpq $0x0, 0x8(%r14)
je 0x42c5
movl 0x7f4d(%rip), %r15d     # 0xc1c0
incl %r15d
movl %r15d, 0x7f43(%rip)     # 0xc1c0
movq %r14, %rdi
movl %r15d, %esi
callq 0x406e
movq (%r12), %rdi
leaq 0x2a95(%rip), %rsi      # 0x6d28
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rdi
leaq 0x2a92(%rip), %rsi      # 0x6d39
movl %r15d, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rdi
movq %r13, %rsi
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
jmp 0x42cf
movq %r14, %rdi
movl %ebx, %esi
callq 0x406e
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x4265
movq (%r12), %rcx
leaq 0x2a51(%rip), %rdi      # 0x6d34
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r12), %rdi
leaq 0x2a3c(%rip), %rsi      # 0x6d39
movl %ebp, %edx
jmp 0x44fd
leaq 0x5ea5(%rip), %rax      # 0xa1b0
movq (%rax), %rdi
leaq 0x28c1(%rip), %rsi      # 0x6bd6
movl %ebx, %edx
jmp 0x44fd
movl 0x7e9e(%rip), %ebp      # 0xc1c0
incl %ebp
movl %ebp, 0x7e96(%rip)      # 0xc1c0
movl %ebx, %r15d
leaq 0x5e7c(%rip), %rbx      # 0xa1b0
movq (%rbx), %rcx
leaq 0x29e5(%rip), %rdi      # 0x6d23
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%rbx), %rdi
leaq 0x2812(%rip), %rsi      # 0x6b69
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %rdi
movl %r15d, %esi
callq 0x406e
movq (%rbx), %rdi
leaq 0x29cb(%rip), %rsi      # 0x6d43
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq (%rbx), %rcx
jmp 0x45fa
movl %ebx, 0x4(%rsp)
leaq 0x5e1a(%rip), %rax      # 0xa1b0
movq 0x10(%r14), %rbx
cmpb $0x5e, (%rbx)
jne 0x461e
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x20(%rsp)
movdqa %xmm0, 0x10(%rsp)
incq %rbx
leaq 0x3ef(%rip), %r13       # 0x47ac
jmp 0x4635
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x4771
movq %r14, %rdi
movl %ebx, %esi
callq 0x406e
movq 0x8(%r14), %r14
jmp 0x43c6
movl %ebx, %ecx
leaq 0x5dc8(%rip), %rbx      # 0xa1b0
movq (%rbx), %rdi
movq 0x10(%r14), %rax
movq 0x10(%rax), %rdx
leaq 0x27fb(%rip), %rsi      # 0x6bf5
xorl %eax, %eax
callq 0x10c0
movq 0x18(%r14), %rax
testq %rax, %rax
je 0x4771
movq (%rbx), %rdi
movl 0x20(%rax), %edx
leaq 0x27f4(%rip), %rsi      # 0x6c0f
jmp 0x44fd
leaq 0x5d89(%rip), %rax      # 0xa1b0
movq (%rax), %rdi
movq 0x10(%r14), %rdx
leaq 0x288e(%rip), %rsi      # 0x6cc3
movl %ebx, %ecx
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c0
movl 0x7d6e(%rip), %ebx      # 0xc1c0
leal 0x1(%rbx), %ebp
addl $0x2, %ebx
movl %ebx, 0x7d62(%rip)      # 0xc1c0
leaq 0x5d4b(%rip), %r15      # 0xa1b0
movq (%r15), %rcx
leaq 0x28b4(%rip), %rdi      # 0x6d23
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r15), %rdi
leaq 0x26e1(%rip), %rsi      # 0x6b69
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %rdi
movl %ebp, %esi
callq 0x406e
movq (%r15), %rdi
leaq 0x2880(%rip), %rsi      # 0x6d28
movl %ebx, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r15), %rdi
leaq 0x287e(%rip), %r14      # 0x6d39
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r15), %rdi
leaq 0x2872(%rip), %rsi      # 0x6d43
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq (%r15), %rcx
leaq 0x284e(%rip), %rdi      # 0x6d34
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r15), %rdi
movq %r14, %rsi
movl %ebx, %edx
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c0
leaq 0x5c97(%rip), %rax      # 0xa1b0
movq (%rax), %rdi
movq 0x20(%r14), %rdx
leaq 0x277e(%rip), %rsi      # 0x6ca5
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c0
movl 0x7c7d(%rip), %r15d     # 0xc1c0
leal 0x1(%r15), %ebp
addl $0x2, %r15d
movl %r15d, 0x7c6e(%rip)     # 0xc1c0
movq 0x10(%r14), %rdi
movl %ebx, %esi
callq 0x406e
leaq 0x5c4c(%rip), %r12      # 0xa1b0
movq (%r12), %rdi
leaq 0x27ca(%rip), %rbx      # 0x6d39
movq %rbx, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rcx
leaq 0x279d(%rip), %rdi      # 0x6d23
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r12), %rdi
leaq 0x25c9(%rip), %rsi      # 0x6b69
movl %r15d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %rdi
movl %r15d, %esi
callq 0x406e
movq (%r12), %rdi
leaq 0x2764(%rip), %rsi      # 0x6d28
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rdi
movq %rbx, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rdi
leaq 0x275a(%rip), %rsi      # 0x6d43
movl %r15d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rcx
leaq 0x2733(%rip), %rdi      # 0x6d34
movl $0x4, %esi
movl $0x1, %edx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1180
pxor %xmm0, %xmm0
movdqa %xmm0, 0x20(%rsp)
movdqa %xmm0, 0x10(%rsp)
leaq 0x18f(%rip), %r13       # 0x47c4
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
leaq 0x1(%rbx), %r14
movzbl (%rbx), %eax
cmpl $0x2d, %eax
je 0x4661
cmpl $0x5c, %eax
je 0x468d
testl %eax, %eax
jne 0x46f0
jmp 0x4723
movl %r12d, %ebp
movzbl (%r14), %r15d
testl %r15d, %r15d
sete %cl
testl %r12d, %r12d
sets %dl
orb %cl, %dl
jne 0x4689
addq $0x2, %rbx
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpl %r15d, %ebp
jg 0x4643
jmp 0x4707
cmpb $0x5c, %al
jne 0x46f0
movzbl (%r14), %ecx
testl %ecx, %ecx
je 0x46f0
addq $0x2, %rbx
leal -0x61(%rcx), %eax
cmpl $0x5, %eax
jbe 0x46bf
movl %ecx, %eax
addl $-0x6e, %eax
cmpl $0x8, %eax
ja 0x46df
leaq 0xf76(%rip), %rdx       # 0x5628
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movb $0xa, %al
jmp 0x46ed
leaq 0xf4a(%rip), %rdx       # 0x5610
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movb $0x7, %al
jmp 0x46ed
movb $0xc, %al
jmp 0x46ed
movb $0x1b, %al
jmp 0x46ed
movb $0x8, %al
jmp 0x46ed
movl %ecx, %eax
jmp 0x46ed
movb $0xb, %al
jmp 0x46ed
movb $0x9, %al
jmp 0x46ed
movb $0xd, %al
movq %rbx, %r14
movzbl %al, %r12d
leaq 0x10(%rsp), %rdi
movl %r12d, %esi
callq *%r13
movq %r14, %rbx
jmp 0x4643
incl %r15d
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
callq *%r13
incl %ebp
cmpl %ebp, %r15d
jne 0x470f
jmp 0x463d
leaq 0x7aa6(%rip), %r15      # 0xc1d0
leaq 0x25ec(%rip), %r12      # 0x6d1d
xorl %ebx, %ebx
movzbl 0x10(%rsp,%rbx), %edx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1160
cltq
addq %rax, %r15
incq %rbx
cmpq $0x20, %rbx
jne 0x4733
leaq 0x2515(%rip), %rsi      # 0x6c6f
leaq 0x7a6f(%rip), %rdx      # 0xc1d0
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %ecx
xorl %eax, %eax
callq 0x10c0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbcb(%rip), %rdi       # 0x5352
leaq 0x226c(%rip), %rsi      # 0x69fa
leaq 0x2404(%rip), %rcx      # 0x6b99
movl $0x65, %edx
callq 0x1060
movq %r14, %rdi
callq 0x13c3
callq 0x13eb