// File: /workspace/github_c_makefile_star2_O3/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 0x44b1
movq %rdi, %r14
movl (%rdi), %edi
leal -0x1(%rdi), %eax
cmpl $0xf, %eax
ja 0x44d8
movl %esi, %ebx
leaq 0x17e6(%rip), %rcx      # 0x55b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r14), %r14
movq %r14, %rdi
callq 0x1040
cmpl $0x1, %eax
je 0x3df7
cmpl $0x2, %eax
jne 0x3e0a
cmpb $0x5c, (%r14)
jne 0x3e0a
leaq 0x63b2(%rip), %rax      # 0xa1b0
movq (%rax), %rdi
leaq 0x2e05(%rip), %rsi      # 0x6c0d
jmp 0x3e1b
leaq 0x639f(%rip), %rax      # 0xa1b0
movq (%rax), %rdi
leaq 0x2e16(%rip), %rsi      # 0x6c31
movq %r14, %rdx
jmp 0x4168
movl 0x8397(%rip), %ebx      # 0xc1c0
leal 0x1(%rbx), %ebp
addl $0x2, %ebx
movl %ebx, 0x838b(%rip)      # 0xc1c0
leaq 0x6374(%rip), %r12      # 0xa1b0
movq (%r12), %rdi
leaq 0x2eda(%rip), %r15      # 0x6d21
movq %r15, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rcx
leaq 0x2ead(%rip), %rdi      # 0x6d0b
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r12), %rdi
leaq 0x2cd9(%rip), %rsi      # 0x6b51
movl %ebx, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %rdi
movl %ebx, %esi
callq 0x3da1
movq (%r12), %rdi
leaq 0x2e77(%rip), %rsi      # 0x6d10
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 0x2e6e(%rip), %rsi      # 0x6d2b
movl %ebx, %edx
movl %ebx, %ecx
jmp 0x4322
movl 0x82f4(%rip), %ebp      # 0xc1c0
incl %ebp
movl %ebp, 0x82ec(%rip)      # 0xc1c0
movl %ebx, %r15d
leaq 0x62d2(%rip), %rbx      # 0xa1b0
movq (%rbx), %rcx
leaq 0x2e23(%rip), %rdi      # 0x6d0b
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%rbx), %rdi
leaq 0x2c50(%rip), %rsi      # 0x6b51
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %rdi
movl %ebp, %esi
callq 0x3da1
movq (%rbx), %rdi
leaq 0x2def(%rip), %rsi      # 0x6d10
movl %r15d, %edx
xorl %eax, %eax
callq 0x10c0
movq (%rbx), %rdi
leaq 0x2dec(%rip), %rsi      # 0x6d21
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
jmp 0x40a1
movl 0x8277(%rip), %ebp      # 0xc1c0
incl %ebp
movl %ebp, 0x826f(%rip)      # 0xc1c0
leaq 0x6258(%rip), %r12      # 0xa1b0
movq (%r12), %rcx
leaq 0x2da8(%rip), %rdi      # 0x6d0b
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r12), %rdi
leaq 0x2bd4(%rip), %rsi      # 0x6b51
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x400b
leaq 0x2d93(%rip), %r13      # 0x6d2b
cmpq $0x0, 0x8(%r14)
je 0x3ff8
movl 0x821a(%rip), %r15d     # 0xc1c0
incl %r15d
movl %r15d, 0x8210(%rip)     # 0xc1c0
movq %r14, %rdi
movl %r15d, %esi
callq 0x3da1
movq (%r12), %rdi
leaq 0x2d4a(%rip), %rsi      # 0x6d10
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rdi
leaq 0x2d47(%rip), %rsi      # 0x6d21
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 0x4002
movq %r14, %rdi
movl %ebx, %esi
callq 0x3da1
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x3f98
movq (%r12), %rcx
leaq 0x2d06(%rip), %rdi      # 0x6d1c
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r12), %rdi
leaq 0x2cf1(%rip), %rsi      # 0x6d21
movl %ebp, %edx
jmp 0x4230
leaq 0x6172(%rip), %rax      # 0xa1b0
movq (%rax), %rdi
leaq 0x2b76(%rip), %rsi      # 0x6bbe
movl %ebx, %edx
jmp 0x4230
movl 0x816b(%rip), %ebp      # 0xc1c0
incl %ebp
movl %ebp, 0x8163(%rip)      # 0xc1c0
movl %ebx, %r15d
leaq 0x6149(%rip), %rbx      # 0xa1b0
movq (%rbx), %rcx
leaq 0x2c9a(%rip), %rdi      # 0x6d0b
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%rbx), %rdi
leaq 0x2ac7(%rip), %rsi      # 0x6b51
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %rdi
movl %r15d, %esi
callq 0x3da1
movq (%rbx), %rdi
leaq 0x2c80(%rip), %rsi      # 0x6d2b
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq (%rbx), %rcx
jmp 0x432d
movl %ebx, 0x4(%rsp)
leaq 0x60e7(%rip), %rax      # 0xa1b0
movq 0x10(%r14), %rbx
cmpb $0x5e, (%rbx)
jne 0x4351
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x20(%rsp)
movdqa %xmm0, 0x10(%rsp)
incq %rbx
leaq 0x3ed(%rip), %r13       # 0x44dd
jmp 0x4368
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x44a2
movq %r14, %rdi
movl %ebx, %esi
callq 0x3da1
movq 0x8(%r14), %r14
jmp 0x40f9
movl %ebx, %ecx
leaq 0x6095(%rip), %rbx      # 0xa1b0
movq (%rbx), %rdi
movq 0x10(%r14), %rax
movq 0x10(%rax), %rdx
leaq 0x2ab0(%rip), %rsi      # 0x6bdd
xorl %eax, %eax
callq 0x10c0
movq 0x18(%r14), %rax
testq %rax, %rax
je 0x44a2
movq (%rbx), %rdi
movl 0x20(%rax), %edx
leaq 0x2aa9(%rip), %rsi      # 0x6bf7
jmp 0x4230
leaq 0x6056(%rip), %rax      # 0xa1b0
movq (%rax), %rdi
movq 0x10(%r14), %rdx
leaq 0x2b43(%rip), %rsi      # 0x6cab
movl %ebx, %ecx
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c0
movl 0x803b(%rip), %ebx      # 0xc1c0
leal 0x1(%rbx), %ebp
addl $0x2, %ebx
movl %ebx, 0x802f(%rip)      # 0xc1c0
leaq 0x6018(%rip), %r15      # 0xa1b0
movq (%r15), %rcx
leaq 0x2b69(%rip), %rdi      # 0x6d0b
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r15), %rdi
leaq 0x2996(%rip), %rsi      # 0x6b51
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %rdi
movl %ebp, %esi
callq 0x3da1
movq (%r15), %rdi
leaq 0x2b35(%rip), %rsi      # 0x6d10
movl %ebx, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r15), %rdi
leaq 0x2b33(%rip), %r14      # 0x6d21
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r15), %rdi
leaq 0x2b27(%rip), %rsi      # 0x6d2b
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10c0
movq (%r15), %rcx
leaq 0x2b03(%rip), %rdi      # 0x6d1c
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 0x5f64(%rip), %rax      # 0xa1b0
movq (%rax), %rdi
movq 0x20(%r14), %rdx
leaq 0x2a33(%rip), %rsi      # 0x6c8d
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c0
movl 0x7f4a(%rip), %r15d     # 0xc1c0
leal 0x1(%r15), %ebp
addl $0x2, %r15d
movl %r15d, 0x7f3b(%rip)     # 0xc1c0
movq 0x10(%r14), %rdi
movl %ebx, %esi
callq 0x3da1
leaq 0x5f19(%rip), %r12      # 0xa1b0
movq (%r12), %rdi
leaq 0x2a7f(%rip), %rbx      # 0x6d21
movq %rbx, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rcx
leaq 0x2a52(%rip), %rdi      # 0x6d0b
movl $0x4, %esi
movl $0x1, %edx
callq 0x1180
movq (%r12), %rdi
leaq 0x287e(%rip), %rsi      # 0x6b51
movl %r15d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x10c0
movq 0x10(%r14), %rdi
movl %r15d, %esi
callq 0x3da1
movq (%r12), %rdi
leaq 0x2a19(%rip), %rsi      # 0x6d10
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 0x2a0f(%rip), %rsi      # 0x6d2b
movl %r15d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x10c0
movq (%r12), %rcx
leaq 0x29e8(%rip), %rdi      # 0x6d1c
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 0x18d(%rip), %r13       # 0x44f5
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
leaq 0x1(%rbx), %r14
movzbl (%rbx), %eax
cmpl $0x2d, %eax
je 0x43c6
cmpl $0x5c, %eax
je 0x4394
testl %eax, %eax
jne 0x4421
jmp 0x4454
movzbl (%r14), %eax
testl %eax, %eax
je 0x43f0
addq $0x2, %rbx
leal -0x61(%rax), %ecx
cmpl $0x5, %ecx
jbe 0x43f4
movl %eax, %ecx
addl $-0x6e, %ecx
cmpl $0x8, %ecx
ja 0x441e
leaq 0x1257(%rip), %rdx      # 0x5610
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movb $0xa, %al
jmp 0x441e
movl %r12d, %ebp
movzbl (%r14), %r15d
testl %r15d, %r15d
sete %cl
testl %r12d, %r12d
sets %dl
movb $0x2d, %al
orb %cl, %dl
jne 0x4421
addq $0x2, %rbx
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpl %r15d, %ebp
ja 0x4376
jmp 0x4438
movb $0x5c, %al
jmp 0x4421
leaq 0x11fd(%rip), %rdx      # 0x55f8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movb $0x7, %al
jmp 0x441e
movb $0xc, %al
jmp 0x441e
movb $0x1b, %al
jmp 0x441e
movb $0x8, %al
jmp 0x441e
movb $0xb, %al
jmp 0x441e
movb $0x9, %al
jmp 0x441e
movb $0xd, %al
movq %rbx, %r14
movzbl %al, %r12d
leaq 0x10(%rsp), %rdi
movl %r12d, %esi
callq *%r13
movq %r14, %rbx
jmp 0x4376
incl %r15d
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
callq *%r13
incl %ebp
cmpl %ebp, %r15d
jne 0x4440
jmp 0x4370
leaq 0x7d75(%rip), %r15      # 0xc1d0
leaq 0x28a3(%rip), %r12      # 0x6d05
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 0x4464
leaq 0x27cc(%rip), %rsi      # 0x6c57
leaq 0x7d3e(%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 0xe82(%rip), %rdi       # 0x533a
leaq 0x2523(%rip), %rsi      # 0x69e2
leaq 0x26bb(%rip), %rcx      # 0x6b81
movl $0x65, %edx
callq 0x1060
movq %r14, %rdi
callq 0x13a4
callq 0x13cc