// File: /workspace/github_cpp_makefile_star2_O2/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
movl %r8d, 0xc(%rsp)
testl %edx, %edx
js 0x11449
movl %ecx, %ebp
movl %edx, %r14d
movq %rdi, %rbx
cmpl %ecx, %edx
jle 0x110f5
leaq 0x4b2f78(%rip), %rsi    # 0x4c4060
movq %rbx, %rdi
callq 0x35f2
jmp 0x11434
movq %rsi, %r15
leaq 0x70(%rsp), %r12
movq %r12, %rdi
callq 0xe30c
movq 0x8(%r12), %rax
subq (%r12), %rax
sarq $0x3, %rax
cmpq $0x2, %rax
setae %cl
cmpl %r14d, %eax
setg %dl
testb %dl, %cl
je 0x1113e
cmpl $0x1, %r14d
adcl $0x0, %r14d
cmpl %ebp, %eax
cmovbl %eax, %ebp
cmpl %ebp, %r14d
jbe 0x11164
leaq 0x4b2f24(%rip), %r12    # 0x4c4060
jmp 0x11154
cmpl %r14d, %eax
jl 0x11468
cmpl %ebp, %eax
leaq 0x4b2f10(%rip), %rax    # 0x4c4060
cmovaq %rax, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x35f2
jmp 0x1142a
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
callq 0x5152
leaq 0xb8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x7cf8
movl %r14d, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
leaq 0x70(%rsp), %rcx
movq %r15, %rsi
callq 0xe775
leaq 0x18(%rsp), %rdi
movups (%rdi), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x10(%rdi), %rax
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
callq 0x52ce
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %r15
cmpq %r15, %r12
je 0x11246
movq %rbx, %r14
movq %r15, %rbx
subq %r12, %rbx
movq %rbx, %rax
cqto
pushq $0x58
popq %rcx
idivq %rcx
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x13c0d
cmpq $0x581, %rbx            # imm = 0x581
jl 0x11238
leaq 0x580(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x14007
movq %r14, %rbx
cmpq %r15, %r13
je 0x11246
movq %r13, %rdi
callq 0x1409d
addq $0x58, %r13
jmp 0x11225
movq %r12, %rdi
movq %r15, %rsi
callq 0x14007
movq %r14, %rbx
movl %ebp, 0x4(%rsp)
leaq 0x10(%rsp), %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
leaq 0x110(%rsp), %r13
leaq 0x50(%rsp), %r12
xorl %ebp, %ebp
xorl %r14d, %r14d
movq %rbx, 0x68(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
subq %rsi, %rax
cqto
pushq $0x58
popq %rcx
idivq %rcx
movslq %eax, %rcx
cmpq %rcx, %r14
jge 0x113c3
andq $0x0, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
leal 0x1(%r14), %ecx
addq %rbp, %rsi
cmpl %eax, %ecx
jge 0x112d0
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
shrq $0x3, %rax
movl 0x4(%rsp), %ecx
subl %eax, %ecx
movq %r13, %rdi
xorl %edx, %edx
movl 0xc(%rsp), %r8d
callq 0x13386
jmp 0x11301
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
shrq $0x3, %rax
movl 0x8(%rsp), %edx
subl %eax, %edx
testl %edx, %edx
movl $0x0, %ecx
cmovlel %ecx, %edx
movl 0x4(%rsp), %ecx
subl %eax, %ecx
movq %r13, %rdi
movl 0xc(%rsp), %r8d
callq 0x13386
movq %r12, %rdi
movq %r13, %rsi
callq 0x3d74
movq %r13, %rdi
callq 0x3bfe
movq %r12, %rdi
leaq 0x4b2d42(%rip), %rsi    # 0x4c4060
callq 0x35c8
movl %eax, %r15d
testb %al, %al
je 0x1133b
movq %rbx, %rdi
leaq 0x4b2d2c(%rip), %rsi    # 0x4c4060
callq 0x35f2
jmp 0x113a9
movq %rbp, 0x48(%rsp)
movq %r12, %rsi
movq 0x30(%rsp), %rbx
leaq 0xa0(%rsp), %rbp
movq %rbp, %rdi
callq 0x35f2
addq 0x48(%rsp), %rbx
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x82b2
movq %r12, %rdi
movq %r13, %rsi
callq 0x3d74
movq %r13, %rdi
callq 0x3bfe
movq %rbp, %rdi
callq 0x3bfe
movq 0x18(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
leaq 0x10(%rsp), %rdi
callq 0x52ae
movq 0x68(%rsp), %rbx
movq 0x48(%rsp), %rbp
movq %r12, %rdi
callq 0x3bfe
addq $0x58, %rbp
incq %r14
testb %r15b, %r15b
je 0x11271
jmp 0x11409
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rax, %rdx
subq %rcx, %rdx
shrq $0x3, %rdx
cmpl %edx, 0x8(%rsp)
jg 0x11487
cmpl %edx, 0x4(%rsp)
jl 0x114a6
movq %rcx, (%rbx)
movq %rax, 0x8(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x3bfe
leaq 0x30(%rsp), %rdi
callq 0x52ce
leaq 0xb8(%rsp), %rdi
callq 0x36d2
leaq 0x70(%rsp), %rdi
callq 0x3642
movq %rbx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xeefe(%rip), %rdi      # 0x2034e
leaq 0xfcc1(%rip), %rsi      # 0x21118
leaq 0x10189(%rip), %rcx     # 0x215e7
movl $0x232, %edx            # imm = 0x232
callq 0x2150
leaq 0xfe40(%rip), %rdi      # 0x212af
leaq 0xfca2(%rip), %rsi      # 0x21118
leaq 0x1016a(%rip), %rcx     # 0x215e7
movl $0x236, %edx            # imm = 0x236
callq 0x2150
leaq 0x101ae(%rip), %rdi     # 0x2163c
leaq 0xfc83(%rip), %rsi      # 0x21118
leaq 0x1014b(%rip), %rcx     # 0x215e7
movl $0x252, %edx            # imm = 0x252
callq 0x2150
leaq 0x10111(%rip), %rdi     # 0x215be
leaq 0xfc64(%rip), %rsi      # 0x21118
leaq 0x1012c(%rip), %rcx     # 0x215e7
movl $0x253, %edx            # imm = 0x253
callq 0x2150
movq %rax, %rbx
jmp 0x11509
jmp 0x114cc
movq %rax, %rbx
jmp 0x11513
jmp 0x114d3
movq %rax, %rbx
jmp 0x11520
jmp 0x114f2
jmp 0x114f2
jmp 0x114f2
jmp 0x114f2
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x3bfe
jmp 0x114f5
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3bfe
leaq 0x10(%rsp), %rdi
callq 0x3bfe
leaq 0x30(%rsp), %rdi
callq 0x52ce
leaq 0xb8(%rsp), %rdi
callq 0x36d2
leaq 0x70(%rsp), %rdi
callq 0x3642
movq %rbx, %rdi
callq 0x2340