// File: /workspace/github_c_makefile_star2_O3/oridb[P]mc/mi/match.c
// Function: genmatchcode
void
genmatchcode(Dtree *dt, Node ***out, size_t *nout)
{
	Node *jmp, *eq, *fail;
	Node *next;
	int emit;
	size_t i;

	if (dt->emitted)
		return;
	dt->emitted = 1;

	/* the we jump to the accept label when generating the parent */
	if (dt->accept) {
		jmp = mkexpr(dt->loc, Ojmp, dt->lbl, NULL);
		jmp->expr.type = mktype(dt->loc, Tyvoid);
		lappend(out, nout, jmp);
		return;
	}

	lappend(out, nout, dt->lbl);
	for (i = 0; i < dt->nnext; i++) {
		if (i == dt->nnext - 1 && dt->any) {
			fail = dt->any->lbl;
			emit = 0;
		} else {
			fail = genlbl(dt->loc);
			emit = 1;
		}
		if (dt->next[i]->accept && dt->next[i]->ncap > 0) {
			next = genlbl(dt->next[i]->loc);
		} else {
			next = dt->next[i]->lbl;
		}

		eq = mkexpr(dt->loc, Oeq, dt->load, dt->pat[i], NULL);
		eq->expr.type = mktype(dt->loc, Tybool);
		jmp = mkexpr(dt->loc, Ocjmp, eq, next, fail, NULL);
		jmp->expr.type = mktype(dt->loc, Tyvoid);
		lappend(out, nout, jmp);

		if (dt->next[i]->accept && dt->next[i]->ncap > 0) {
			lappend(out, nout, next);
			lcat(out, nout, dt->next[i]->cap, dt->next[i]->ncap);
			jmp = mkexpr(dt->loc, Ojmp, dt->next[i]->lbl, NULL);
			jmp->expr.type = mktype(dt->loc, Tyvoid);
			lappend(out, nout, jmp);
		}

		genmatchcode(dt->next[i], out, nout);
		if (emit)
			lappend(out, nout, fail);
	}
	if (dt->any) {
		jmp = mkexpr(dt->loc, Ojmp, dt->any->lbl, NULL);
		jmp->expr.type = mktype(dt->loc, Tyvoid);
		lappend(out, nout, jmp);
		genmatchcode(dt->any, out, nout);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, 0x8(%rsp)
cmpb $0x0, 0x29(%rdi)
je 0x2b9f8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
movq %rdi, %r15
movb $0x1, 0x29(%r15)
cmpb $0x0, 0x28(%r15)
jne 0x2bc18
movq 0x10(%r15), %rdx
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x2ceff
movq 0x48(%r15), %rax
testq %rax, %rax
je 0x2bbbb
xorl %ebx, %ebx
decq %rax
cmpq %rax, %rbx
jne 0x2ba4b
movq 0x50(%r15), %rax
testq %rax, %rax
je 0x2ba4b
movq 0x10(%rax), %r12
movb $0x1, %al
movl %eax, 0x14(%rsp)
jmp 0x2ba5f
movq 0x4(%r15), %rdi
callq 0x1de03
movq %rax, %r12
movl $0x0, 0x14(%rsp)
movq 0x40(%r15), %rax
movq (%rax,%rbx,8), %rax
cmpb $0x0, 0x28(%rax)
je 0x2ba82
cmpq $0x0, 0x60(%rax)
je 0x2ba82
movq 0x4(%rax), %rdi
callq 0x1de03
movq %rax, %r13
jmp 0x2ba86
movq 0x10(%rax), %r13
movq 0x4(%r15), %rdi
movq 0x18(%r15), %rdx
movq 0x30(%r15), %rax
movq (%rax,%rbx,8), %rcx
movl $0x17, %esi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %rbp
movq 0x4(%r15), %rdi
movl $0x2, %esi
callq 0x2289d
movq %rax, 0x20(%rbp)
movq 0x4(%r15), %rdi
movl $0x3e, %esi
movq %rbp, %rdx
movq %r13, %rcx
movq %r12, %r8
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %rbp
movq 0x4(%r15), %rdi
movl $0x1, %esi
callq 0x2289d
movq %rax, 0x20(%rbp)
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x2ceff
movq 0x40(%r15), %rax
movq (%rax,%rbx,8), %rdi
cmpb $0x0, 0x28(%rdi)
je 0x2bb87
cmpq $0x0, 0x60(%rdi)
je 0x2bb87
movq %r14, %rdi
movq 0x8(%rsp), %rbp
movq %rbp, %rsi
movq %r13, %rdx
callq 0x2ceff
movq 0x40(%r15), %rax
movq (%rax,%rbx,8), %rax
movq 0x58(%rax), %rdx
movq 0x60(%rax), %rcx
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2d066
movq 0x4(%r15), %rdi
movq 0x40(%r15), %rax
movq (%rax,%rbx,8), %rax
movq 0x10(%rax), %rdx
movl $0x30, %esi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %r13
movq 0x4(%r15), %rdi
movl $0x1, %esi
callq 0x2289d
movq %rax, 0x20(%r13)
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x2ceff
movq 0x40(%r15), %rax
movq (%rax,%rbx,8), %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
callq 0x2b9d0
cmpb $0x0, 0x14(%rsp)
jne 0x2bbab
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0x2ceff
incq %rbx
movq 0x48(%r15), %rax
cmpq %rax, %rbx
jb 0x2ba2e
movq 0x50(%r15), %rax
testq %rax, %rax
je 0x2b9e9
movq 0x10(%rax), %rdx
movq 0x4(%r15), %rdi
movl $0x30, %esi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %r12
movq 0x4(%r15), %rdi
movl $0x1, %esi
callq 0x2289d
movq %rax, 0x20(%r12)
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0x2ceff
movq 0x50(%r15), %r15
cmpb $0x0, 0x29(%r15)
je 0x2b9fe
jmp 0x2b9e9
movq 0x4(%r15), %rdi
movq 0x10(%r15), %rdx
movl $0x30, %esi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %r12
movq 0x4(%r15), %rdi
movl $0x1, %esi
callq 0x2289d
movq %rax, 0x20(%r12)
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2ceff