// File: /workspace/github_c_makefile_star2_O1/theovosse[P]llgen/regexp.c
// Function: CompileDFA
int CompileDFA(RegExp dfa, int prevLen, unsigned char *code, Boolean generate) {
	RegExp state;
	Transition tr;
	int mCount = charSetSize, count;
	RegExp mState = NULL;
	ESet elt;
	int i, j;
	RegExp cSet[256];
	int nrBytes = 0;
	int tmpJump;

	/* MOVE.L A0,A1
	   MOVE.W #$FFFF,D0
	   CLR.W D1 */
	if (generate) {
		*code++ = 0x22;
		*code++ = 0x48;
		*code++ = 0x30;
		*code++ = 0x3C;
		*code++ = 0xFF;
		*code++ = 0xFF;
		*code++ = 0x42;
		*code++ = 0x41;
	}
	nrBytes += 8;
	for (state = dfa; state != NULL; state = state->next) {
		for (i = 0; i != charSetSize; i++) cSet[i] = NULL;
		for (tr = state->transitions; tr != NULL; tr = tr->next) {
			cSet[tr->transitionChar] = tr->destination;
		}
		mCount = -1; mState = NULL;
		for (i = 0; i != charSetSize; i++) {
			if (cSet[i] != mState) /* not the most efficient check, but ok */ {
				for (count = 0, j = i; j != charSetSize; j++)
					if (cSet[j] == cSet[i] && (j == i || cSet[j] != cSet[j - 1]))
						count++;
				if (count > mCount) {
					mCount = count;
					mState = cSet[i];
				}
			}
		}
		/* mCount is max. nr. of transitions to the same state, mState is that state */
		state->state.number = nrBytes;
		if (state->info != NULL) {
			Answer first;
			for (elt = state->info, first = elt->element; elt != NULL; elt = elt->next) {
				if (first->number > ((Answer) elt->element)->number) {
					first = elt->element;
				}
			}
			/* MOVEA.L #first->info,A0 */
			if (generate) {
				*code++ = 0x20;
				*code++ = 0x7C;
				*code++ = ((long int) first->info) >> 24;
				*code++ = (((long int) first->info) >> 16) & 0xFF;
				*code++ = (((long int) first->info) >> 8) & 0xFF;
				*code++ = ((long int) first->info) & 0xFF;
			}
			nrBytes += 6;
			/* MOVE.W D1,D0 */
			if (generate) {
				*code++ = 0x30;
				*code++ = 0x01;
			}
			nrBytes += 2;
		}
		/* MOVE.B (A1)+,D2
		   ADDQ.W #1,D1 */
		if (generate) {
			*code++ = 0x14;
			*code++ = 0x19;
			*code++ = 0x52;
			*code++ = 0x41;
		}
		nrBytes += 4;
		i = 0;
		while (i != charSetSize) {
			if (cSet[i] != mState) {
				if (i < charSetSize - 2 && cSet[i] == cSet[i + 1] && cSet[i] == cSet[i + 2]) {
					if (i == 0) {
						tmpJump = -1;
					} else {
						/* CMP.B  #i,D2 */
						if (generate) {
							*code++ = 0x0C;
							*code++ = 0x02;
							*code++ = 0x00;
							*code++ = i & 0xFF;
						}
						nrBytes += 4;
						/* BLT    tempLabel */
						if (generate) {
							*code++ = 0x6D;
							*code++ = 0x08;
						}
						nrBytes += 2;
						tmpJump = nrBytes; /* wijzig code[tmpJump - nrBytes - 1] */
					}
					do {
						i++;
					}
					while (i != charSetSize && cSet[i] == cSet[i - 1]);
					i--;
					if (i == charSetSize - 1) {
						/* JMP */
						if (generate) {
							*code++ = 0x4E;
							*code++ = 0xFA;
						}
						nrBytes += 2;
						if (cSet[i] == NULL) {
							/* JMP    FAIL */
							if (generate) {
								*code++ = ((prevLen - nrBytes) >> 8) & 0xFF;
								*code++ = (prevLen - nrBytes) & 0xFF;
							}
							nrBytes += 2;
						} else if (cSet[i] == state && state->info != NULL) {
							/* JMP @cSet[i]->state.number + 6 */
							if (generate) {
								*code++ = ((cSet[i]->state.number + 6 - nrBytes) >> 8) & 0xFF;
								*code++ = (cSet[i]->state.number + 6 - nrBytes) & 0xFF;
							}
							nrBytes += 2;
						} else {
							/* JMP @cSet[i]->state.number */
							if (generate) {
								*code++ = ((cSet[i]->state.number - nrBytes) >> 8) & 0xFF;
								*code++ = (cSet[i]->state.number - nrBytes) & 0xFF;
							}
							nrBytes += 2;
						}
					} else {
						/* CMP.B  #$i,D2 */
						if (generate) {
							*code++ = 0x0C;
							*code++ = 0x02;
							*code++ = 0x00;
							*code++ = i & 0xFF;
						}
						nrBytes += 4;
						/* BLE */
						if (generate) {
							*code++ = 0x6F;
							*code++ = 0x00;
						}
						nrBytes += 2;
						if (cSet[i] == NULL) {
							/* BLE    FAIL */
							if (generate) {
								*code++ = ((prevLen - nrBytes) >> 8) & 0xFF;
								*code++ = (prevLen - nrBytes) & 0xFF;
							}
							nrBytes += 2;
						} else if (cSet[i] == state && state->info != NULL) {
							/* BLE    @cSet[i]->state.number + 6 */
							if (generate) {
								*code++ = ((cSet[i]->state.number + 6 - nrBytes) >> 8) & 0xFF;
								*code++ = (cSet[i]->state.number + 6 - nrBytes) & 0xFF;
							}
							nrBytes += 2;
						} else {
							/* BLE    @cSet[i]->state.number */
							if (generate) {
								*code++ = ((cSet[i]->state.number - nrBytes) >> 8) & 0xFF;
								*code++ = (cSet[i]->state.number - nrBytes) & 0xFF;
							}
							nrBytes += 2;
						}
					}
					/* tempLabel */
					if (generate && tmpJump != -1) {
						code[tmpJump - nrBytes - 1] = nrBytes - tmpJump;
					}
				} else {
					if (i == 0) {
						/* TST.B  D2 */
						if (generate) {
							*code++ = 0x4A;
							*code++ = 0x02;
						}
						nrBytes += 2;
					} else {
						/* CMP.B  #i,D2 */
						if (generate) {
							*code++ = 0x0C;
							*code++ = 0x02;
							*code++ = 0x00;
							*code++ = i & 0xFF;
						}
						nrBytes += 4;
					}
					/* BEQ */
					if (generate) {
						*code++ = 0x67;
						*code++ = 0x00;
					}
					nrBytes += 2;
					if (cSet[i] == NULL) {
						/* BEQ    FAIL */
						if (generate) {
							*code++ = ((prevLen - nrBytes) >> 8) & 0xFF;
							*code++ = (prevLen - nrBytes) & 0xFF;
						}
						nrBytes += 2;
					} else if (cSet[i] == state && state->info != NULL) {
						/* BEQ    @cSet[i]->state.number + 6 */
						if (generate) {
							*code++ = ((cSet[i]->state.number + 6 - nrBytes) >> 8) & 0xFF;
							*code++ = (cSet[i]->state.number + 6 - nrBytes) & 0xFF;
						}
						nrBytes += 2;
					} else {
						/* BEQ    @cSet[i]->state.number */
						if (generate) {
							*code++ = ((cSet[i]->state.number - nrBytes) >> 8) & 0xFF;
							*code++ = (cSet[i]->state.number - nrBytes) & 0xFF;
						}
						nrBytes += 2;
					}
				}
			}
			i++;
		}
		if (mState == NULL) {
			if (state->next != NULL) {
				/* JMP    FAIL */
				if (generate) {
					*code++ = 0x4E;
					*code++ = 0xFA;
					*code++ = ((prevLen - (nrBytes + 2)) >> 8) & 0xFF;
					*code++ = (prevLen - (nrBytes + 2)) & 0xFF;
				}
				nrBytes += 4;
			}
		} else {
			if (mState == state && state->info != NULL) {
				/* JMP    @mState->state.number + 6 */
				if (generate) {
					*code++ = 0x4E;
					*code++ = 0xFA;
					*code++ = ((mState->state.number + 6 - (nrBytes + 2)) >> 8) & 0xFF;
					*code++ = (mState->state.number + 6 - (nrBytes + 2)) & 0xFF;
				}
				nrBytes += 4;
			} else {
				/* JMP    @mState->state.number */
				if (generate) {
					*code++ = 0x4E;
					*code++ = 0xFA;
					*code++ = ((mState->state.number - (nrBytes + 2)) >> 8) & 0xFF;
					*code++ = (mState->state.number - (nrBytes + 2)) & 0xFF;
				}
				nrBytes += 4;
			}
		}
	}
	/* RTS
	 */
 /* if (generate) {
		RenumberDFA(dfa);
	} */
	return (nrBytes);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x818, %rsp            # imm = 0x818
movl %ecx, %r14d
movq %rdx, %rbp
movl %esi, %r13d
movq %rdi, %r15
testw %r14w, %r14w
je 0xea67
movabsq $0x4142ffff3c304822, %rax # imm = 0x4142FFFF3C304822
movq %rax, (%rbp)
addq $0x8, %rbp
testq %r15, %r15
je 0xef27
leal -0x2(%r13), %eax
movl %eax, 0xc(%rsp)
movl $0x8, %r12d
movq %r13, %rbx
movl 0xa7d4(%rip), %r13d     # 0x1925c
testq %r13, %r13
je 0xeaa1
leaq (,%r13,8), %rdx
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x3120
movq (%r15), %rax
testq %rax, %rax
je 0xeabb
movq 0x8(%rax), %rcx
movslq (%rax), %rdx
movq %rcx, 0x10(%rsp,%rdx,8)
movq 0x10(%rax), %rax
jmp 0xeaa4
testq %r13, %r13
je 0xeb1d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %r13, %rdx
leaq 0x10(%rsp), %rsi
xorl %edi, %edi
xorl %eax, %eax
movq 0x10(%rsp,%rdi,8), %r8
cmpq %rax, %r8
je 0xeb0c
xorl %r10d, %r10d
xorl %r9d, %r9d
movq (%rsi,%r10,8), %r11
cmpq %r8, %r11
jne 0xeaf9
testq %r10, %r10
je 0xeaf6
cmpq -0x8(%rsi,%r10,8), %r11
je 0xeaf9
incl %r9d
incq %r10
cmpq %r10, %rdx
jne 0xeae1
cmpl %ecx, %r9d
cmovgl %r9d, %ecx
cmovgq %r8, %rax
incq %rdi
addq $0x8, %rsi
decq %rdx
cmpq %r13, %rdi
jne 0xead1
jmp 0xeb1f
xorl %eax, %eax
movslq %r12d, %rcx
movq %rcx, 0x28(%r15)
movq 0x10(%r15), %rcx
testq %rcx, %rcx
je 0xeb8b
movq (%rcx), %rsi
movq %rbx, %r13
movl (%rsi), %edi
movq (%rcx), %rdx
cmpl (%rdx), %edi
jg 0xeb41
movq %rsi, %rdx
movq 0x8(%rcx), %rcx
movq %rdx, %rsi
testq %rcx, %rcx
jne 0xeb35
testw %r14w, %r14w
je 0xeb75
movw $0x7c20, (%rbp)         # imm = 0x7C20
movb 0xb(%rdx), %cl
movb %cl, 0x2(%rbp)
movb 0xa(%rdx), %cl
movb %cl, 0x3(%rbp)
movb 0x9(%rdx), %cl
movb %cl, 0x4(%rbp)
movb 0x8(%rdx), %cl
movb %cl, 0x5(%rbp)
addq $0x6, %rbp
testw %r14w, %r14w
je 0xeb85
movw $0x130, (%rbp)          # imm = 0x130
addq $0x2, %rbp
addl $0x8, %r12d
jmp 0xeb8e
movq %rbx, %r13
testw %r14w, %r14w
je 0xeb9f
movl $0x41521914, (%rbp)     # imm = 0x41521914
addq $0x4, %rbp
addl $0x4, %r12d
movl 0xa6b3(%rip), %edx      # 0x1925c
testl %edx, %edx
je 0xee9b
xorl %ecx, %ecx
movslq %ecx, %rsi
movq 0x10(%rsp,%rsi,8), %rdi
cmpq %rax, %rdi
je 0xec9e
addl $-0x2, %edx
cmpl %edx, %ecx
jge 0xebdd
cmpq 0x18(%rsp,%rsi,8), %rdi
jne 0xebdd
cmpq 0x20(%rsp,%rsi,8), %rdi
je 0xecb3
testl %ecx, %ecx
je 0xebff
movl $0x4, %edx
testw %r14w, %r14w
je 0xec14
movw $0x20c, (%rbp)          # imm = 0x20C
movb $0x0, 0x2(%rbp)
movb %cl, 0x3(%rbp)
addq $0x4, %rbp
jmp 0xec14
movl $0x2, %edx
testw %r14w, %r14w
je 0xec14
movw $0x24a, (%rbp)          # imm = 0x24A
addq $0x2, %rbp
testw %r14w, %r14w
je 0xec24
movw $0x67, (%rbp)
addq $0x2, %rbp
addl %edx, %r12d
leal 0x2(%r12), %edx
movq 0x10(%rsp,%rsi,8), %rdi
testq %rdi, %rdi
je 0xec59
cmpq %r15, %rdi
je 0xec6e
testw %r14w, %r14w
je 0xec9a
movl 0x28(%rdi), %ebx
subl %edx, %ebx
movb %bh, (%rbp)
movq 0x10(%rsp,%rsi,8), %rsi
movl 0x28(%rsi), %esi
subl %edx, %esi
movb %sil, 0x1(%rbp)
jmp 0xec96
testw %r14w, %r14w
je 0xec9a
movl %r13d, %esi
subl %edx, %esi
rolw $0x8, %si
movw %si, (%rbp)
jmp 0xec96
cmpq $0x0, 0x10(%r15)
je 0xec3b
testw %r14w, %r14w
je 0xec9a
movl $0x4, %edx
subl %r12d, %edx
movl 0x28(%rdi), %ebx
addl %edx, %ebx
movb %bh, (%rbp)
movq 0x10(%rsp,%rsi,8), %rsi
addl 0x28(%rsi), %edx
movb %dl, 0x1(%rbp)
addq $0x2, %rbp
addl $0x4, %r12d
incl %ecx
movl 0xa5b6(%rip), %edx      # 0x1925c
cmpl %edx, %ecx
jne 0xebb3
jmp 0xee9b
testl %ecx, %ecx
je 0xece7
testw %r14w, %r14w
je 0xecce
movw $0x20c, (%rbp)          # imm = 0x20C
movb $0x0, 0x2(%rbp)
movb %cl, 0x3(%rbp)
addq $0x4, %rbp
testw %r14w, %r14w
je 0xecde
movw $0x86d, (%rbp)          # imm = 0x86D
addq $0x2, %rbp
addl $0x6, %r12d
movl %r12d, %r11d
jmp 0xeced
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movl 0xa568(%rip), %r8d      # 0x1925c
decl %ecx
leaq 0x18(%rsp), %rdx
leaq (%rdx,%rsi,8), %rsi
movl $0x1, %edi
subl %r8d, %edi
decl %r8d
leal (%rdi,%rcx), %r9d
cmpl $-0x1, %r9d
je 0xed28
movq (%rsi), %r9
incl %ecx
leaq 0x8(%rsi), %r10
cmpq -0x8(%rsi), %r9
movq %r10, %rsi
je 0xed0a
jmp 0xed2b
movl %r8d, %ecx
movslq %ecx, %rdi
cmpl %r8d, %ecx
jne 0xed62
testw %r14w, %r14w
je 0xed43
movw $0xfa4e, (%rbp)         # imm = 0xFA4E
addq $0x2, %rbp
leal 0x2(%r12), %r8d
movq 0x10(%rsp,%rdi,8), %r9
testq %r9, %r9
je 0xedca
cmpq %r15, %r9
je 0xee00
movl $0x4, %esi
jmp 0xeda6
testw %r14w, %r14w
je 0xed79
movw $0x20c, (%rbp)          # imm = 0x20C
movb $0x0, 0x2(%rbp)
movb %cl, 0x3(%rbp)
addq $0x4, %rbp
testw %r14w, %r14w
je 0xed89
movw $0x6f, (%rbp)
addq $0x2, %rbp
leal 0x6(%r12), %r8d
movq 0x10(%rsp,%rdi,8), %r9
testq %r9, %r9
je 0xede5
cmpq %r15, %r9
je 0xee6b
movl $0x8, %esi
testw %r14w, %r14w
je 0xee3a
movl 0x28(%r9), %edx
subl %r8d, %edx
movb %dh, (%rbp)
movq 0x10(%rsp,%rdi,8), %rdx
movl 0x28(%rdx), %edx
subl %r8d, %edx
movb %dl, 0x1(%rbp)
jmp 0xee36
movl $0x4, %esi
testw %r14w, %r14w
je 0xee3a
movl %r13d, %edi
subl %r8d, %edi
rolw $0x8, %di
movw %di, (%rbp)
jmp 0xee36
movl $0x8, %esi
testw %r14w, %r14w
je 0xee3a
movl %r13d, %edx
subl %r8d, %edx
rolw $0x8, %dx
movw %dx, (%rbp)
jmp 0xee36
cmpq $0x0, 0x10(%r15)
je 0xed5b
movl $0x4, %esi
testw %r14w, %r14w
je 0xee3a
movl $0x4, %r8d
subl %r12d, %r8d
movl 0x28(%r9), %edx
addl %r8d, %edx
movb %dh, (%rbp)
movq 0x10(%rsp,%rdi,8), %rdx
addl 0x28(%rdx), %r8d
movb %r8b, 0x1(%rbp)
addq $0x2, %rbp
addl %esi, %r12d
testw %r14w, %r14w
je 0xec9e
cmpl $-0x1, %r11d
je 0xec9e
movl %r12d, %edx
subl %r11d, %edx
movl %r12d, %esi
notl %esi
addl %r11d, %esi
movslq %esi, %rsi
movb %dl, (%rbp,%rsi)
jmp 0xec9e
cmpq $0x0, 0x10(%r15)
je 0xeda1
movl $0x8, %esi
testw %r14w, %r14w
je 0xee3a
movl 0x28(%r9), %edx
subl %r12d, %edx
movb %dh, (%rbp)
movq 0x10(%rsp,%rdi,8), %rdx
movl 0x28(%rdx), %edx
subl %r12d, %edx
jmp 0xedc5
testq %rax, %rax
je 0xeec5
cmpq %r15, %rax
je 0xeefc
testw %r14w, %r14w
je 0xeee9
movw $0xfa4e, (%rbp)         # imm = 0xFA4E
movl 0x28(%rax), %ecx
leal 0x2(%r12), %edx
subl %edx, %ecx
movb %ch, 0x2(%rbp)
movl 0x28(%rax), %eax
subl %edx, %eax
jmp 0xeee2
cmpq $0x0, 0x18(%r15)
je 0xeeed
testw %r14w, %r14w
je 0xeee9
movw $0xfa4e, (%rbp)         # imm = 0xFA4E
movl 0xc(%rsp), %eax
subl %r12d, %eax
movb %ah, 0x2(%rbp)
movb %al, 0x3(%rbp)
addq $0x4, %rbp
addl $0x4, %r12d
movq 0x18(%r15), %r15
testq %r15, %r15
jne 0xea7e
jmp 0xef2d
cmpq $0x0, 0x10(%r15)
je 0xeea5
testw %r14w, %r14w
je 0xeee9
movw $0xfa4e, (%rbp)         # imm = 0xFA4E
movl $0x4, %ecx
subl %r12d, %ecx
movl 0x28(%rax), %edx
addl %ecx, %edx
movb %dh, 0x2(%rbp)
addl 0x28(%rax), %ecx
movb %cl, 0x3(%rbp)
jmp 0xeee5
movl $0x8, %r12d
movl %r12d, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq