// File: /workspace/github_c_makefile_star2_O3/theovosse[P]llgen/regexp.c
// Function: PrintDFA
void PrintDFA(RegExp dfa) {
	RegExp state;
	Transition tr, tr2;
	ESet transitions;
	int mCount = charSetSize, count;
	RegExp mState = NULL;
	ESet elt;
	int i, tCount;
	Boolean cSet[256];

	printf("int PMatch(char *str)\n{\n    int pos = 0, lLen = -1;\n\n");
	for (state = dfa; state != NULL; state = state->next) {
		tCount = charSetSize;
		for (i = 0; i != charSetSize; i++) cSet[i] = false;
		for (tr = state->transitions; tr != NULL; tr = tr->next) {
			cSet[tr->transitionChar] = true;
			mCount--;
			tCount--;
		}
		/* mCount is nr. of fails, mState == NULL, the fail state */
		for (tr = state->transitions; tr != NULL; tr = tr->next) {
			if (tr->destination != mState) /* not the most efficient check, but ok */ {
				for (count = 0, tr2 = tr; tr2 != NULL; tr2 = tr2->next)
					if (tr2->destination == tr->destination) count++;
				if (count > mCount) {
					mCount = count;
					mState = tr->destination;
				}
			}
		}
		/* mCount is max. nr. of transitions to the same state, mState is that state */
		printf("  l%ld:\n", state->state.number);
		if (state->info != NULL) {
			Answer first;
			printf("    lLen = pos;\n");
			for (elt = state->info, first = elt->element; elt != NULL; elt = elt->next) {
				if (singleAnswer) {
					if (first->number > ((Answer) elt->element)->number) {
						first = elt->element;
					}
				} else {
					printf("    Accept(%d, \"%s\");\n", ((Answer) elt->element)->number, (const char*) ((Answer) elt->element)->info);
				}
			}
			if (singleAnswer) {
				printf("    Accept(\"%s\");\n", (const char*) first->info);
			}
		}
		if (state->transitions == NULL) {
			printf("    goto fail;\n");
		} else {
			printf("    if (*str == '\\0') goto fail;\n");
			printf("    pos++;\n    switch (*str++)\n    {\n");
			transitions = NULL;
			for (tr = state->transitions; tr != NULL; tr = tr->next) {
				if (tr->destination != mState && !SetMember(tr->destination, transitions)) {
					transitions = AddElement(tr->destination, transitions);
					for (tr2 = tr; tr2 != NULL; tr2 = tr2->next) {
						if (tr2->destination == tr->destination) {
							printf("        case ");
							if (tr2->transitionChar < ' ' || tr2->transitionChar > '~') {
								printf("\\%03x:\n", tr2->transitionChar);
							} else {
								printf("'%c':\n", tr2->transitionChar);
							}
						}
					}
					printf("            goto l%ld;\n", tr->destination->state.number);
				}
			}
			if (mState == NULL) {
				printf("        default:\n            goto fail;\n");
			} else {
				if (tCount != 0) {
					for (i = 0; i != charSetSize; i++) {
						if (!cSet[i]) {
							printf("        case ");
							if (i < ' ' || i > '~') {
								printf("\\%03x:\n", i);
							} else {
								printf("'%c':\n", i);
							}
						}
					}
					printf("            goto fail;\n");
				}
				printf("        default:\n            goto l%ld;\n", mState->state.number);
			}
			RemoveSet(transitions);
			printf("    }\n");
		}
	}
	printf("  fail:\n    return (lLen);\n}\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdi, %r12
movl 0xb306(%rip), %ebp      # 0x1925c
leaq 0x51f7(%rip), %rdi      # 0x13154
callq 0x3090
testq %r12, %r12
je 0xe240
xorl %ebx, %ebx
movl 0xb2e8(%rip), %r14d     # 0x1925c
testq %r14, %r14
je 0xdf89
leaq (%r14,%r14), %rdx
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x3120
movq (%r12), %rax
movq %rax, %rcx
testq %rax, %rax
je 0xdfe7
movslq (%rcx), %rdx
movw $0xffff, 0x10(%rsp,%rdx,2) # imm = 0xFFFF
decl %ebp
decl %r14d
movq 0x10(%rcx), %rcx
testq %rcx, %rcx
jne 0xdf95
jmp 0xdfe2
movq 0x8(%rax), %rcx
cmpq %rbx, %rcx
je 0xdfde
xorl %edx, %edx
movq %rax, %rsi
xorl %edi, %edi
cmpq %rcx, 0x8(%rsi)
movq 0x10(%rsi), %r8
sete %dil
addl %edi, %edx
movq %r8, %rsi
testq %r8, %r8
jne 0xdfbd
cmpl %ebp, %edx
cmovgl %edx, %ebp
cmovgq %rcx, %rbx
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0xdfaf
movq 0x28(%r12), %rsi
leaq 0x4f24(%rip), %rdi      # 0x12f17
xorl %eax, %eax
callq 0x30f0
cmpq $0x0, 0x10(%r12)
je 0xe071
leaq 0x519d(%rip), %rdi      # 0x131a6
callq 0x3090
movq 0x10(%r12), %r13
movq (%r13), %r15
movzwl 0xdcba(%rip), %eax      # 0x1bcd8
testw %ax, %ax
je 0xe032
movl (%r15), %ecx
movq (%r13), %rdx
cmpl (%rdx), %ecx
cmovgq %rdx, %r15
jmp 0xe051
movq (%r13), %rax
movl (%rax), %esi
movq 0x8(%rax), %rdx
leaq 0x4edd(%rip), %rdi      # 0x12f20
xorl %eax, %eax
callq 0x30f0
movzwl 0xdc87(%rip), %eax      # 0x1bcd8
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0xe01e
testw %ax, %ax
je 0xe071
movq 0x8(%r15), %rsi
leaq 0x4ecd(%rip), %rdi      # 0x12f37
xorl %eax, %eax
callq 0x30f0
cmpq $0x0, (%r12)
leaq 0x5198(%rip), %rdi      # 0x13215
je 0xe22d
leaq 0x512c(%rip), %rdi      # 0x131b6
callq 0x3090
leaq 0x5141(%rip), %rdi      # 0x131d7
callq 0x3090
movq %r12, 0x8(%rsp)
movq (%r12), %r12
xorl %r15d, %r15d
testq %r12, %r12
je 0xe142
movq 0x8(%r12), %rdi
cmpq %rbx, %rdi
je 0xe138
testq %r15, %r15
je 0xe0d0
movq %r15, %rax
cmpq %rdi, (%rax)
je 0xe138
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0xe0c2
movq %r15, %rsi
callq 0xc874
movq %rax, %r15
movq %r12, %r13
movq 0x8(%r13), %rax
cmpq 0x8(%r12), %rax
jne 0xe118
leaq 0x4e5a(%rip), %rdi      # 0x12f4a
xorl %eax, %eax
callq 0x30f0
movl (%r13), %esi
leal -0x7f(%rsi), %eax
leaq 0x4e53(%rip), %rdi      # 0x12f58
cmpl $-0x5f, %eax
jb 0xe111
leaq 0x4e4f(%rip), %rdi      # 0x12f60
xorl %eax, %eax
callq 0x30f0
movq 0x10(%r13), %r13
testq %r13, %r13
jne 0xe0de
movq 0x8(%r12), %rax
movq 0x28(%rax), %rsi
leaq 0x4e47(%rip), %rdi      # 0x12f78
xorl %eax, %eax
callq 0x30f0
movq 0x10(%r12), %r12
jmp 0xe0a7
testq %rbx, %rbx
je 0xe1c5
testl %r14d, %r14d
movq 0x8(%rsp), %r12
je 0xe1b1
cmpl $0x0, 0xb104(%rip)      # 0x1925c
je 0xe1a5
xorl %r14d, %r14d
cmpw $0x0, 0x10(%rsp,%r14,2)
jne 0xe197
leaq 0x4ddd(%rip), %rdi      # 0x12f4a
xorl %eax, %eax
callq 0x30f0
leal -0x7f(%r14), %eax
cmpl $-0x5f, %eax
leaq 0x4dde(%rip), %rdi      # 0x12f60
leaq 0x4dcf(%rip), %rax      # 0x12f58
cmovbq %rax, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x30f0
incq %r14
movl 0xb0bc(%rip), %eax      # 0x1925c
cmpq %rax, %r14
jne 0xe15d
leaq 0x5061(%rip), %rdi      # 0x1320d
callq 0x3090
movq 0x28(%rbx), %rsi
leaq 0x4dab(%rip), %rdi      # 0x12f67
xorl %eax, %eax
callq 0x30f0
jmp 0xe1d6
leaq 0x5030(%rip), %rdi      # 0x131fc
callq 0x3090
movq 0x8(%rsp), %r12
leaq 0x5047(%rip), %rdi      # 0x13224
testq %r15, %r15
je 0xe22d
movq 0xdaaf(%rip), %rax      # 0x1bc98
movq 0xdab8(%rip), %rcx      # 0x1bca8
movq 0xdad1(%rip), %rdx      # 0x1bcc8
movq %rdx, %rsi
movq %r15, %rdx
movq 0x8(%r15), %r15
movq %rsi, 0x8(%rdx)
incq %rcx
addq $0x10, %rax
testq %r15, %r15
jne 0xe1f7
movq %rdx, 0xdab0(%rip)      # 0x1bcc8
movq %rcx, 0xda89(%rip)      # 0x1bca8
movq %rax, 0xda72(%rip)      # 0x1bc98
leaq 0x4ff7(%rip), %rdi      # 0x13224
callq 0x3090
movq 0x18(%r12), %r12
testq %r12, %r12
jne 0xdf6d
leaq 0x4f42(%rip), %rdi      # 0x13189
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3090