// File: /workspace/github_c_makefile_star2_O2/theovosse[P]llgen/regexp.c
// Function: MinimizeDFA
void MinimizeDFA(RegExp dfa) {
	RegExp state;
	ESet partition = NULL, nPartition;
	ESet element, element2;
	ESet nSet1, nSet2;
	Boolean changes;
	Transition tr;

	currentAutomaton = dfa;
	push_localadm();
	/* Partitioning: one class for each type final state, plus one for the rest */
	for (state = dfa; state != NULL; state = state->next) {
		for (element = partition; element != NULL; element = element->next) {
			ESet stateSet = element->element;
			if ((singleAnswer? FirstAnswerIdentical(state->info, ((RegExp) (stateSet->element))->info):
							   SetEqual(state->info, ((RegExp) (stateSet->element))->info))) {
				element->element = AddElement(state, element->element);
				state->state.set = element;
				break;
			}
		}
		if (element == NULL) {
			ESet stateSet = AddElement(state, NULL);
			partition = AddElement(stateSet, partition);
			state->state.set = partition;
		}
	}
	/* Refine partitioning */
	do {
		changes = false;
		nPartition = NULL;
		for (element = partition; element != NULL; element = element->next) {
			element2 = element->element;
			nSet1 = AddElement(element2->element, NULL);
			nSet2 = NULL;
			element2 = element2->next;
			/* Check if all other members of this partition have the same destinations as the first element */
			while (element2 != NULL) {
				if (AllDestinationsEqual(nSet1->element, element2->element)) {
					nSet1 = AddElement(element2->element, nSet1);
				} else {
					nSet2 = AddElement(element2->element, nSet2);
				}
				element2 = element2->next;
			}
			nPartition = AddElement(nSet1, nPartition);
			for (element2 = nSet1; element2 != NULL; element2 = element2->next) {
				((RegExp) (element2->element))->state.set = nPartition;
			}
			if (nSet2 != NULL) {
				nPartition = AddElement(nSet2, nPartition);
				changes = true;
				for (element2 = nSet2; element2 != NULL; element2 = element2->next) {
					((RegExp) (element2->element))->state.set = nPartition;
				}
			}
		}
		RemoveSet(partition);
		partition = nPartition;
	}
	while (changes);
	/* Ensure that the first state stays the same when mapping... */
	for (element = partition; element != NULL; element = element->next) {
		if (SetMember(dfa, element->element)) {
			element->element = AddElement(dfa, element->element);
			break;
		}
	}
	/* Map states and transitions: pick first element of each partition */
	for (state = dfa; state != NULL; state = state->next) {
		for (tr = state->transitions; tr != NULL; tr = tr->next) {
			tr->destination = ((ESet) (tr->destination->state.set->element))->element;
		}
	}
	/* Clean up adm */
	pop_localadm();
	/* Remove unreachable states */
	lastVisit++;
	MarkDFA(dfa);
	RemoveUnreachableStates(dfa);
	RenumberDFA(dfa);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movq %rdi, %r14
movq %rdi, 0xde67(%rip)      # 0x1ace0
callq 0xbb78
xorl %ebp, %ebp
movq %r14, %r15
testq %r15, %r15
je 0xcf45
movzwl 0xde45(%rip), %ebx      # 0x1acd8
movq %rbp, %r12
testq %r12, %r12
je 0xcf0c
movq (%r12), %r13
movq 0x10(%r15), %rdi
movq (%r13), %rax
movq 0x10(%rax), %rsi
testw %bx, %bx
je 0xced4
testq %rdi, %rdi
je 0xcee0
testq %rsi, %rsi
je 0xcee0
movq (%rdi), %rax
movl (%rax), %eax
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0xcee7
movq (%rdi), %rcx
movl (%rcx), %ecx
cmpl %eax, %ecx
cmovll %ecx, %eax
jmp 0xcebf
callq 0xbfd5
testw %ax, %ax
je 0xcf05
jmp 0xcf29
cmpq %rsi, %rdi
jne 0xcf05
jmp 0xcf29
movq (%rsi), %rcx
movl (%rcx), %ecx
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0xcf01
movq (%rsi), %rdx
movl (%rdx), %edx
cmpl %ecx, %edx
cmovll %edx, %ecx
jmp 0xceec
cmpl %ecx, %eax
je 0xcf29
movq 0x8(%r12), %r12
jmp 0xce96
movq %r15, %rdi
xorl %esi, %esi
callq 0xbec0
movq %rax, %rdi
movq %rbp, %rsi
callq 0xbec0
movq %rax, %r12
movq %rax, %rbp
jmp 0xcf38
movq %r15, %rdi
movq %r13, %rsi
callq 0xbec0
movq %rax, (%r12)
movq %r12, 0x28(%r15)
movq 0x18(%r15), %r15
jmp 0xce83
movq %r14, (%rsp)
xorl %r15d, %r15d
movq %rbp, 0x8(%rsp)
xorl %ebx, %ebx
testq %rbp, %rbp
je 0xd077
movq (%rbp), %r14
movq (%r14), %rdi
xorl %esi, %esi
callq 0xbec0
movq %rax, %r13
xorl %r12d, %r12d
movq 0x8(%r14), %r14
testq %r14, %r14
je 0xd022
movq (%r13), %rcx
movq (%r14), %rdi
movl 0xb2d2(%rip), %eax      # 0x1825c
xorl %edx, %edx
cmpq %rdx, %rax
je 0xcfbc
andq $0x0, 0x10(%rsp,%rdx,8)
andq $0x0, 0x810(%rsp,%rdx,8)
incq %rdx
jmp 0xcf8c
movq 0x8(%rcx), %rdx
movq 0x28(%rdx), %rdx
movslq (%rcx), %rsi
movq %rdx, 0x810(%rsp,%rsi,8)
addq $0x10, %rcx
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0xcfa5
movq %rdi, %rcx
movq (%rcx), %rcx
testq %rcx, %rcx
je 0xcfe5
movq 0x8(%rcx), %rdx
movq 0x28(%rdx), %rdx
movslq (%rcx), %rsi
movq %rdx, 0x10(%rsp,%rsi,8)
addq $0x10, %rcx
jmp 0xcfc7
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xd012
movq 0x810(%rsp,%rcx,8), %rdx
leaq 0x1(%rcx), %rsi
cmpq 0x10(%rsp,%rcx,8), %rdx
movq %rsi, %rcx
je 0xcfe7
movq %r12, %rsi
callq 0xbec0
movq %rax, %r12
jmp 0xcf70
movq %r13, %rsi
callq 0xbec0
movq %rax, %r13
jmp 0xcf70
movq %r13, %rdi
movq %r15, %rsi
callq 0xbec0
movq %rax, %r15
testq %r13, %r13
je 0xd043
movq (%r13), %rax
movq %r15, 0x28(%rax)
movq 0x8(%r13), %r13
jmp 0xd030
testq %r12, %r12
je 0xd06e
movq %r12, %rdi
movq %r15, %rsi
callq 0xbec0
movq %rax, %r15
testq %r12, %r12
je 0xd06a
movq (%r12), %rax
movq %r15, 0x28(%rax)
movq 0x8(%r12), %r12
jmp 0xd056
movw $0xffff, %bx            # imm = 0xFFFF
movq 0x8(%rbp), %rbp
jmp 0xcf53
movq 0x8(%rsp), %rdi
callq 0xbf31
movq %r15, %rbp
testw %bx, %bx
jne 0xcf49
movq (%rsp), %r13
testq %r15, %r15
je 0xd0bd
movq (%r15), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0xbf94
testw %ax, %ax
jne 0xd0af
movq 0x8(%r15), %r15
jmp 0xd091
movq %r13, %rdi
movq %r14, %rsi
callq 0xbec0
movq %rax, (%r15)
movq %r13, %rax
testq %rax, %rax
je 0xd0ee
movq %rax, %rcx
movq (%rcx), %rcx
testq %rcx, %rcx
je 0xd0e8
movq 0x8(%rcx), %rdx
movq 0x28(%rdx), %rdx
movq (%rdx), %rdx
movq (%rdx), %rdx
movq %rdx, 0x8(%rcx)
addq $0x10, %rcx
jmp 0xd0c8
movq 0x18(%rax), %rax
jmp 0xd0c0
callq 0xbccf
incq 0xdbee(%rip)            # 0x1ace8
movq %r13, %rdi
callq 0xd169
movq 0x18(%r13), %r15
movq %r13, %rbx
movq %r15, %r14
testq %r15, %r15
je 0xd14b
movq 0x18(%r14), %r15
movq 0x20(%r14), %rax
cmpq 0xdbc8(%rip), %rax      # 0x1ace8
je 0xd142
movq (%r14), %rdi
testq %rdi, %rdi
je 0xd138
movq 0x10(%rdi), %r12
callq 0xcaf3
movq %r12, %rdi
jmp 0xd125
movq %r14, %rdi
callq 0xcb15
jmp 0xd109
movq %r14, 0x18(%rbx)
movq %r14, %rbx
jmp 0xd109
andq $0x0, 0x18(%rbx)
movq %r13, %rdi
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xcdb8