// File: /workspace/github_cpp_makefile_star2_O3/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, 0x3c(%rsp)
testl %edx, %edx
js 0x16a98
movl %ecx, %ebp
movl %edx, %r14d
movq %rdi, %rbx
cmpl %ecx, %edx
jle 0x165c7
leaq 0x4b2a96(%rip), %rsi    # 0x4c9050
movq %rbx, %rdi
callq 0x3f7c
jmp 0x1666d
movq %rsi, %r12
leaq 0xa0(%rsp), %r13
movq %r13, %rdi
callq 0x12cbc
movq 0x8(%r13), %rax
subq (%r13), %rax
sarq $0x3, %rax
cmpq $0x2, %rax
setae %cl
cmpl %r14d, %eax
setg %dl
testb %dl, %cl
je 0x16612
cmpl $0x1, %r14d
adcl $0x0, %r14d
cmpl %ebp, %eax
cmovbl %eax, %ebp
cmpl %ebp, %r14d
jbe 0x16682
leaq 0x4b2a40(%rip), %r13    # 0x4c9050
jmp 0x16628
cmpl %r14d, %eax
jl 0x16ab7
cmpl %ebp, %eax
leaq 0x4b2a2c(%rip), %rax    # 0x4c9050
cmovaq %rax, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3f7c
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x16650
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x1666d
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 %r12, %rsi
callq 0x42ce
leaq 0xe8(%rsp), %rdi
leaq 0x18(%r12), %rsi
callq 0x815a
movb 0x30(%r12), %al
leaq 0x108(%rsp), %rdi
movb %al, -0x8(%rdi)
leaq 0x38(%r12), %rsi
callq 0x4110
movq 0x50(%r12), %rax
leaq 0xd0(%rsp), %rdi
movq %rax, 0x50(%rdi)
leaq 0xa0(%rsp), %rsi
callq 0x9bd8
leaq 0x40(%rsp), %rdi
leaq 0xd0(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
movq %r12, %rsi
callq 0x13217
movq %rbx, 0x68(%rsp)
leaq 0x48(%rsp), %rdi
movupd (%rdi), %xmm0
movapd %xmm0, 0x70(%rsp)
movq 0x10(%rdi), %rax
movq %rax, 0x80(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x6b12
movq 0x70(%rsp), %r13
movq 0x78(%rsp), %r12
cmpq %r12, %r13
je 0x167a9
movq %r12, %r15
subq %r13, %r15
movq %r15, %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 %r13, %rdi
movq %r12, %rsi
callq 0x19b8e
cmpq $0x581, %r15            # imm = 0x581
jl 0x1679e
leaq 0x580(%r13), %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x1a59c
cmpq %r12, %r15
je 0x167a9
movq %r15, %rdi
callq 0x1a763
addq $0x58, %r15
jmp 0x1678b
movq %r13, %rdi
movq %r12, %rsi
callq 0x1a59c
leaq 0x40(%rsp), %rax
xorpd %xmm0, %xmm0
movapd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x88(%rsp), %rbx
xorl %r12d, %r12d
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 0x16a14
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
imulq $0x58, %r12, %r13
incq %r12
addq %r13, %rsi
cmpl %eax, %r12d
jge 0x1683a
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 0x3c(%rsp), %r8d
callq 0x190f9
jmp 0x1686a
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
shrq $0x3, %rax
movl %r14d, %edx
subl %eax, %edx
testl %edx, %edx
movl $0x0, %ecx
cmovlel %ecx, %edx
movl %ebp, %ecx
subl %eax, %ecx
leaq 0x20(%rsp), %rdi
movl 0x3c(%rsp), %r8d
callq 0x190f9
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movapd 0x20(%rsp), %xmm0
movapd %xmm0, (%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testq %rdi, %rdi
je 0x168bf
subq %rdi, %rsi
callq 0x2210
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x168bf
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, %rsi
subq %rax, %rsi
movq 0x4b2783(%rip), %rdi    # 0x4c9058
movq 0x4b2774(%rip), %rdx    # 0x4c9050
subq %rdx, %rdi
cmpq %rdi, %rsi
jne 0x16911
cmpq %rcx, %rax
je 0x169c3
movq (%rax), %xmm0
movq (%rdx), %xmm1
pcmpeqd %xmm0, %xmm1
pshufd $0x50, %xmm1, %xmm0     # xmm0 = xmm1[0,0,1,1]
movmskpd %xmm0, %esi
cmpl $0x3, %esi
jne 0x16911
addq $0x8, %rax
addq $0x8, %rdx
jmp 0x168e4
movq 0x70(%rsp), %r15
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x3f7c
addq %r13, %r15
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xa2d6
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movapd 0x20(%rsp), %xmm0
movapd %xmm0, (%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testq %rdi, %rdi
je 0x16989
subq %rdi, %rsi
callq 0x2210
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x16989
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x169a6
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 0x8ecc
xorl %r15d, %r15d
jmp 0x169d7
movb $0x1, %r15b
movq 0x68(%rsp), %rdi
leaq 0x4b267e(%rip), %rsi    # 0x4c9050
callq 0x3f7c
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x169ed
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
testb %r15b, %r15b
je 0x167c9
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
movq 0x68(%rsp), %rbx
je 0x16a4e
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x16a4e
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rax, %rdx
subq %rcx, %rdx
shrq $0x3, %rdx
cmpl %edx, %r14d
movq 0x68(%rsp), %rbx
jg 0x16ad6
cmpl %edx, %ebp
jl 0x16af5
movq %rcx, (%rbx)
movq %rax, 0x8(%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rbx)
leaq 0x70(%rsp), %rdi
callq 0x6b12
leaq 0x108(%rsp), %rdi
callq 0x41aa
leaq 0xe8(%rsp), %rdi
callq 0x436a
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x16633
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x16633
leaq 0x128af(%rip), %rdi     # 0x2934e
leaq 0x13672(%rip), %rsi     # 0x2a118
leaq 0x13b3a(%rip), %rcx     # 0x2a5e7
movl $0x232, %edx            # imm = 0x232
callq 0x2140
leaq 0x137f1(%rip), %rdi     # 0x2a2af
leaq 0x13653(%rip), %rsi     # 0x2a118
leaq 0x13b1b(%rip), %rcx     # 0x2a5e7
movl $0x236, %edx            # imm = 0x236
callq 0x2140
leaq 0x13b5f(%rip), %rdi     # 0x2a63c
leaq 0x13634(%rip), %rsi     # 0x2a118
leaq 0x13afc(%rip), %rcx     # 0x2a5e7
movl $0x252, %edx            # imm = 0x252
callq 0x2140
leaq 0x13ac2(%rip), %rdi     # 0x2a5be
leaq 0x13615(%rip), %rsi     # 0x2a118
leaq 0x13add(%rip), %rcx     # 0x2a5e7
movl $0x253, %edx            # imm = 0x253
callq 0x2140
jmp 0x16b16
movq %rax, %rbx
jmp 0x16bc1
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x436a
jmp 0x16b33
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x16bce
movq 0xe0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x16bce
jmp 0x16b58
movq %rax, %rbx
jmp 0x16bce
jmp 0x16b87
jmp 0x16b87
jmp 0x16b87
jmp 0x16b87
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x16b8a
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x16b8a
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x16ba0
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x16bb7
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
leaq 0x70(%rsp), %rdi
callq 0x6b12
leaq 0xd0(%rsp), %rdi
callq 0x40d8
leaq 0xa0(%rsp), %rdi
callq 0x3ff2
movq %rbx, %rdi
callq 0x2310