// File: /workspace/github_cpp_makefile_star2_O1/Laakeri[P]Triangulator/src/minfill.cpp
// Function: MinFill::SolveGraph::solveGraph(Graph const&, int, int, int)
vector<pair<int, int> > solveGraph(const Graph& G, int lowerBound, int upperBound, int depth) {
	assert(lowerBound >= 0);
	if (lowerBound > upperBound) return FAILSOLUTION;
	auto fill = MCS::MCS_MP(G);
	if (fill.F.size() <= 1 || (int)fill.F.size() <= lowerBound) {
		assert((int)fill.F.size() >= lowerBound);
		if ((int)fill.F.size() > upperBound) return FAILSOLUTION;
		return fill.F;
	}
	lowerBound = max(lowerBound, 1);
	upperBound = min(upperBound, (int)fill.F.size());
	if (lowerBound > upperBound) return FAILSOLUTION;
	
	Graph gFill = G;
	gFill.addEdges(fill.F);
	vector<Graph> atoms = MCS::getAtoms(G, gFill, fill).S;
	auto cmp = [](const Graph& a, const Graph& b) {
		return a.n < b.n;
	};
	sort(atoms.begin(), atoms.end(), cmp);
	vector<pair<int, int> > sol;
	for (int i = 0; i < (int)atoms.size(); i++) {
		vector<pair<int, int> > tSol;
		if (i+1 < (int)atoms.size()) {
			tSol = SolveAtom::solveAtom0(atoms[i], 0, upperBound - (int)sol.size(), depth);
		}
		else {
			tSol = SolveAtom::solveAtom0(atoms[i], max(0, lowerBound - (int)sol.size()), upperBound - (int)sol.size(), depth);
		}
		if (tSol == FAILSOLUTION) return FAILSOLUTION;
		tSol = atoms[i].mapBack(tSol);
		sol.insert(sol.end(), tSol.begin(), tSol.end());
	}
	assert((int)sol.size() >= lowerBound);
	assert((int)sol.size() <= upperBound);
	return sol;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
testl %edx, %edx
js 0x16939
movl %ecx, %ebp
movl %edx, %r12d
movq %rdi, %rbx
cmpl %ecx, %edx
jle 0x1643e
leaq 0x4b3c1f(%rip), %rsi    # 0x4ca050
movq %rbx, %rdi
callq 0x402a
jmp 0x164eb
movq %rsi, %r15
movl %r8d, 0x3c(%rsp)
leaq 0xa0(%rsp), %r13
movq %r13, %rdi
callq 0x12a60
movq 0x8(%r13), %rax
subq (%r13), %rax
sarq $0x3, %rax
cmpq $0x2, %rax
jb 0x16490
cmpl %r12d, %eax
jle 0x16490
cmpl $0x2, %r12d
movl $0x1, %ecx
cmovgel %r12d, %ecx
cmpl %ebp, %eax
cmovll %eax, %ebp
movl %ecx, 0x38(%rsp)
cmpl %ebp, %ecx
jle 0x16500
leaq 0x4b3bc2(%rip), %r13    # 0x4ca050
jmp 0x164a6
cmpl %r12d, %eax
jl 0x16958
cmpl %ebp, %eax
leaq 0x4b3bae(%rip), %rax    # 0x4ca050
cmovgq %rax, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x402a
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x164ce
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x164eb
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %rbx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd0(%rsp), %rdi
movq %r15, %rsi
callq 0x431c
leaq 0xe8(%rsp), %r14
leaq 0x18(%r15), %rsi
movq %r14, %rdi
callq 0x7e36
movb 0x30(%r15), %al
leaq 0x108(%rsp), %rdi
movb %al, -0x8(%rdi)
leaq 0x38(%r15), %rsi
callq 0x4164
movq 0x50(%r15), %rax
leaq 0xd0(%rsp), %rdi
movq %rax, 0x50(%rdi)
leaq 0xa0(%rsp), %rsi
callq 0x9880
leaq 0x40(%rsp), %rdi
leaq 0xd0(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
movq %r15, %rsi
callq 0x12fba
movq %rbx, 0x68(%rsp)
leaq 0x48(%rsp), %rdi
movq (%rdi), %rax
movq %rax, 0x70(%rsp)
movups 0x8(%rdi), %xmm0
movups %xmm0, 0x78(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x69a0
movq 0x70(%rsp), %r12
movq 0x78(%rsp), %r15
cmpq %r15, %r12
je 0x16620
movq %r15, %r14
subq %r12, %r14
movq %r14, %rax
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x19b95
cmpq $0x581, %r14            # imm = 0x581
jl 0x16615
leaq 0x580(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x1a409
cmpq %r15, %r13
je 0x16620
movq %r13, %rdi
callq 0x1a602
addq $0x58, %r13
jmp 0x16602
movq %r12, %rdi
movq %r15, %rsi
callq 0x1a409
leaq 0x40(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x88(%rsp), %rbx
xorl %r12d, %r12d
movl 0x3c(%rsp), %r13d
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rax
subq %rsi, %rax
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
movslq %eax, %rcx
cmpq %rcx, %r12
jge 0x1688b
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
imulq $0x58, %r12, %r15
incq %r12
addq %r15, %rsi
cmpl %eax, %r12d
jge 0x166b0
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
shrq $0x3, %rax
movl %ebp, %ecx
subl %eax, %ecx
leaq 0x20(%rsp), %rdi
xorl %edx, %edx
movl %r13d, %r8d
callq 0x19098
jmp 0x166df
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
shrq $0x3, %rax
movl 0x38(%rsp), %edx
subl %eax, %edx
testl %edx, %edx
movl $0x0, %ecx
cmovlel %ecx, %edx
movl %ebp, %ecx
subl %eax, %ecx
leaq 0x20(%rsp), %rdi
movl %r13d, %r8d
callq 0x19098
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
movups 0x28(%rsp), %xmm0
movups %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testq %rdi, %rdi
je 0x16719
subq %rdi, %rsi
callq 0x2210
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x16730
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq (%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rax, %rsi
subq %rcx, %rsi
movq 0x4b3912(%rip), %rdi    # 0x4ca058
movq 0x4b3903(%rip), %rdx    # 0x4ca050
subq %rdx, %rdi
cmpq %rdi, %rsi
jne 0x1679e
cmpq %rax, %rcx
sete %r14b
je 0x167a1
movl (%rcx), %esi
xorl %r14d, %r14d
cmpl (%rdx), %esi
jne 0x167a1
movl 0x4(%rdx), %esi
cmpl %esi, 0x4(%rcx)
jne 0x167a1
addq $0x8, %rcx
addq $0xc, %rdx
cmpq %rax, %rcx
sete %r14b
je 0x167a1
movl (%rcx), %esi
xorl %r14d, %r14d
cmpl -0x4(%rdx), %esi
jne 0x167a1
leaq 0x8(%rcx), %rsi
movl (%rdx), %edi
addq $0x8, %rdx
cmpl %edi, 0x4(%rcx)
movq %rsi, %rcx
je 0x16777
jmp 0x167a1
xorl %r14d, %r14d
testb %r14b, %r14b
je 0x167bc
movq 0x68(%rsp), %rdi
leaq 0x4b389e(%rip), %rsi    # 0x4ca050
callq 0x402a
jmp 0x1686a
movq 0x70(%rsp), %r13
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x402a
addq %r15, %r13
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x9f86
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
movups 0x28(%rsp), %xmm0
movups %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testq %rdi, %rdi
movl 0x3c(%rsp), %r13d
je 0x1681e
subq %rdi, %rsi
callq 0x2210
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x16835
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x16852
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x48(%rsp), %rsi
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
leaq 0x40(%rsp), %rdi
callq 0x8bb4
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x16880
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
testb %r14b, %r14b
je 0x16643
jmp 0x168d7
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rax, %rdx
subq %rcx, %rdx
shrq $0x3, %rdx
cmpl %edx, 0x38(%rsp)
jg 0x16977
cmpl %edx, %ebp
movq 0x68(%rsp), %rdx
jl 0x16996
movq %rcx, (%rdx)
movq %rax, 0x8(%rdx)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rdx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x168ee
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
leaq 0x70(%rsp), %rdi
callq 0x69a0
leaq 0x108(%rsp), %rdi
callq 0x41fe
leaq 0xe8(%rsp), %rdi
callq 0x43b8
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x1692f
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x68(%rsp), %rbx
jmp 0x164b1
leaq 0x139fe(%rip), %rdi     # 0x2a33e
leaq 0x147c1(%rip), %rsi     # 0x2b108
leaq 0x14c89(%rip), %rcx     # 0x2b5d7
movl $0x232, %edx            # imm = 0x232
callq 0x2140
leaq 0x14940(%rip), %rdi     # 0x2b29f
leaq 0x147a2(%rip), %rsi     # 0x2b108
leaq 0x14c6a(%rip), %rcx     # 0x2b5d7
movl $0x236, %edx            # imm = 0x236
callq 0x2140
leaq 0x14cae(%rip), %rdi     # 0x2b62c
leaq 0x14783(%rip), %rsi     # 0x2b108
leaq 0x14c4b(%rip), %rcx     # 0x2b5d7
movl $0x252, %edx            # imm = 0x252
callq 0x2140
leaq 0x14c11(%rip), %rdi     # 0x2b5ae
leaq 0x14764(%rip), %rsi     # 0x2b108
leaq 0x14c2c(%rip), %rcx     # 0x2b5d7
movl $0x253, %edx            # imm = 0x253
callq 0x2140
jmp 0x169b7
movq %rax, %rbx
jmp 0x16a5d
movq %rax, %rbx
movq %r14, %rdi
callq 0x43b8
jmp 0x169cf
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x16a6a
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x16a6a
jmp 0x169f4
movq %rax, %rbx
jmp 0x16a6a
jmp 0x16a23
jmp 0x16a23
jmp 0x16a23
jmp 0x16a23
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x16a26
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x16a26
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x16a3c
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x16a53
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
leaq 0x70(%rsp), %rdi
callq 0x69a0
leaq 0xd0(%rsp), %rdi
callq 0x412c
leaq 0xa0(%rsp), %rdi
callq 0x40a0
movq %rbx, %rdi
callq 0x2310