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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x8(%rsp)
testl %edx, %edx
js 0x284c0
movl %r8d, %r12d
movl %ecx, %ebp
cmpl %r8d, %ecx
jg 0x284df
movl %edx, %r15d
movq %rsi, %r14
movq %rsi, %rdi
callq 0xa27c
cmpl $0x3, %r15d
movl $0x2, %r13d
cmovgel %r15d, %r13d
testl %r12d, %r12d
movl $0x1, %ebx
cmovlel %r12d, %ebx
testb %al, %al
cmovnel %r12d, %ebx
cmovel %r15d, %r13d
cmpl %ebx, %r13d
jle 0x27e55
movq 0x8(%rsp), %rbx
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
movq %rbx, %rdi
addq $0x8, %rdi
leaq 0xc12878(%rip), %rsi    # 0xc3a6c0
callq 0x402a
movq %rbx, %rax
jmp 0x284ae
cmpl %ebp, %r13d
cmovgl %r13d, %ebp
leaq 0xa0(%rsp), %rdi
movq %r14, %rsi
callq 0x12a60
leaq 0xf0(%rsp), %rdi
movq %r14, %rsi
callq 0x431c
movq 0x8(%rsp), %r15
leaq 0x108(%rsp), %rdi
leaq 0x18(%r14), %rsi
callq 0x7e36
movb 0x30(%r14), %al
leaq 0x128(%rsp), %rdi
movb %al, -0x8(%rdi)
leaq 0x38(%r14), %rsi
callq 0x4164
movq 0x50(%r14), %rax
leaq 0xf0(%rsp), %rdi
movq %rax, 0x50(%rdi)
leaq 0xa0(%rsp), %rsi
callq 0x9880
leaq 0xf0(%rsp), %rdi
callq 0x1374a
movl %eax, %r12d
cmpl %r13d, %eax
jl 0x284fe
cmpl %ebp, %r12d
jle 0x27f20
movq 0xa8(%rsp), %rax
subq 0xa0(%rsp), %rax
cmpq $0x8, %rax
ja 0x27f3c
leaq 0x8(%r15), %rdi
cmpl %ebx, %r12d
jle 0x27ff9
movl $0xffffffff, (%r15)     # imm = 0xFFFFFFFF
leaq 0xc127aa(%rip), %rsi    # 0xc3a6c0
callq 0x402a
jmp 0x2843a
movl %r12d, (%r15)
movq %r15, %rdi
addq $0x8, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x402a
jmp 0x2843a
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
movq %r14, %rsi
callq 0x12fba
leaq 0x58(%rsp), %r14
movl -0x8(%r14), %r15d
leaq 0x10(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movaps 0x70(%rsp), %xmm0
movq 0x80(%rsp), %rax
movups (%r14), %xmm1
movaps %xmm1, 0x70(%rsp)
movq 0x10(%r14), %rcx
movq %rcx, 0x80(%rsp)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%r14)
movq $0x0, 0x10(%r14)
callq 0x69a0
movq %r14, %rdi
callq 0x69a0
decl %r15d
cmpl %r15d, %r13d
cmovgl %r13d, %r15d
cmpl %ebx, %r15d
jle 0x28001
movq 0x8(%rsp), %r15
movl $0xffffffff, (%r15)     # imm = 0xFFFFFFFF
movq %r15, %rdi
addq $0x8, %rdi
leaq 0xc126d1(%rip), %rsi    # 0xc3a6c0
callq 0x402a
jmp 0x28430
movl %r12d, (%r15)
jmp 0x27f2a
cmpl %r15d, %ebp
cmovlel %r15d, %ebp
cmpl %ebp, %r12d
jle 0x28081
movq 0x70(%rsp), %rbp
movq 0x78(%rsp), %r14
cmpq %r14, %rbp
je 0x280ad
movq %r14, %r13
subq %rbp, %r13
movq %r13, %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 %rbp, %rdi
movq %r14, %rsi
callq 0x28627
cmpq $0x581, %r13            # imm = 0x581
jl 0x280a2
leaq 0x580(%rbp), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x28e9b
cmpq %r14, %r13
je 0x280ad
movq %r13, %rdi
callq 0x29094
addq $0x58, %r13
jmp 0x2806e
movq 0x8(%rsp), %r15
movl %r12d, (%r15)
movq %r15, %rdi
addq $0x8, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x402a
jmp 0x28430
movq %rbp, %rdi
movq %r14, %rsi
callq 0x28e9b
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl %r15d, 0x50(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x402a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
movq 0x8(%rsp), %r14
je 0x280eb
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
leal -0x1(%r12), %r15d
cmpl %ebx, %r15d
cmovgel %ebx, %r15d
leaq 0x8(%r14), %rax
movq %rax, 0x98(%rsp)
xorl %r14d, %r14d
leaq 0xd8(%rsp), %r13
movl %ebx, 0x94(%rsp)
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, %r14
jge 0x283d3
movl $0x0, 0x10(%rsp)
leaq 0x18(%rsp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
imulq $0x58, %r14, %rbp
incq %r14
addq %rbp, %rsi
cmpl %eax, %r14d
jge 0x2817f
movl 0x50(%rsp), %ecx
leaq 0x30(%rsp), %rdi
xorl %edx, %edx
movl %r15d, %r8d
callq 0x279f8
jmp 0x28192
movl 0x50(%rsp), %ecx
leaq 0x30(%rsp), %rdi
xorl %edx, %edx
movl %r15d, %r8d
callq 0x279f8
movl 0x30(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rsi
movq 0x38(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movups 0x40(%rsp), %xmm0
movups %xmm0, 0x20(%rsp)
movq %rdi, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq %rsi, 0x48(%rsp)
leaq 0x38(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
testq %rdi, %rdi
je 0x281ec
subq %rdi, %rsi
callq 0x2210
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x28203
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %rbp, 0xd0(%rsp)
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rax, %rsi
subq %rcx, %rsi
movq 0xc124a6(%rip), %rdi    # 0xc3a6c8
movq 0xc12497(%rip), %rdx    # 0xc3a6c0
subq %rdx, %rdi
cmpq %rdi, %rsi
jne 0x28278
cmpq %rax, %rcx
sete %bpl
je 0x2827a
movl (%rcx), %esi
xorl %ebp, %ebp
cmpl (%rdx), %esi
jne 0x2827a
movl 0x4(%rdx), %esi
cmpl %esi, 0x4(%rcx)
jne 0x2827a
addq $0x8, %rcx
addq $0xc, %rdx
cmpq %rax, %rcx
sete %bpl
je 0x2827a
movl (%rcx), %esi
xorl %ebp, %ebp
cmpl -0x4(%rdx), %esi
jne 0x2827a
leaq 0x8(%rcx), %rsi
movl (%rdx), %edi
addq $0x8, %rdx
cmpl %edi, 0x4(%rcx)
movq %rsi, %rcx
je 0x28252
jmp 0x2827a
xorl %ebp, %ebp
testb %bpl, %bpl
je 0x282ac
cmpl %ebx, %r12d
jle 0x28394
movq 0x8(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0x98(%rsp), %rdi
leaq 0xc1241e(%rip), %rsi    # 0xc3a6c0
callq 0x402a
jmp 0x283b1
movq %r14, %rbx
movl %r15d, %eax
movq %r13, %r15
movq %r12, %r14
movl %eax, %r12d
movl 0x50(%rsp), %eax
movl 0x10(%rsp), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movl %ecx, 0x50(%rsp)
movq 0x70(%rsp), %r13
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x402a
addq 0xd0(%rsp), %r13
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
movq %r15, %r13
movq %r15, %rdx
callq 0x9f86
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rax
movq %rax, 0x18(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
testq %rdi, %rdi
movl %r12d, %r15d
je 0x28338
subq %rdi, %rsi
callq 0x2210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
movq %r14, %r12
je 0x28352
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
movq %rbx, %r14
je 0x28372
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x60(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
leaq 0x58(%rsp), %rdi
callq 0x8bb4
movl 0x94(%rsp), %ebx
jmp 0x283b1
movq 0x8(%rsp), %rax
movl %r12d, (%rax)
movq 0x98(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x402a
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x283c8
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
testb %bpl, %bpl
je 0x28115
jmp 0x28414
movl 0x50(%rsp), %eax
cmpl %ebx, %eax
jg 0x2851d
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rcx)
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rcx)
movq 0x68(%rsp), %rax
movq %rax, 0x18(%rcx)
xorps %xmm0, %xmm0
leaq 0x58(%rsp), %rax
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x2842b
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x8(%rsp), %r15
leaq 0x70(%rsp), %rdi
callq 0x69a0
leaq 0x128(%rsp), %rdi
callq 0x41fe
leaq 0x108(%rsp), %rdi
callq 0x43b8
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x28471
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x2848e
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x284ab
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %r15, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e77(%rip), %rdi      # 0x2a33e
leaq 0x3e72(%rip), %rsi      # 0x2c340
leaq 0x3fc4(%rip), %rcx      # 0x2c499
movl $0xa3, %edx
callq 0x2140
leaq 0x2365(%rip), %rdi      # 0x2a84b
leaq 0x3e53(%rip), %rsi      # 0x2c340
leaq 0x3fa5(%rip), %rcx      # 0x2c499
movl $0xa4, %edx
callq 0x2140
leaq 0x1d7b(%rip), %rdi      # 0x2a280
leaq 0x3e34(%rip), %rsi      # 0x2c340
leaq 0x3f86(%rip), %rcx      # 0x2c499
movl $0xb4, %edx
callq 0x2140
leaq 0x1ed7(%rip), %rdi      # 0x2a3fb
leaq 0x3e15(%rip), %rsi      # 0x2c340
leaq 0x3f67(%rip), %rcx      # 0x2c499
movl $0xdd, %edx
callq 0x2140
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x28599
movq 0x20(%rsp), %rsi
jmp 0x28591
jmp 0x2855d
jmp 0x2855d
jmp 0x28602
jmp 0x28568
jmp 0x28568
movq %rax, %rbx
jmp 0x28599
jmp 0x28568
jmp 0x28568
jmp 0x28568
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x28582
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x28599
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
leaq 0x70(%rsp), %rdi
callq 0x69a0
jmp 0x28605
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x2856b
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x2856b
jmp 0x28602
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x43b8
jmp 0x285de
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x28612
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x28612
movq %rax, %rbx
jmp 0x28612
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x412c
leaq 0xa0(%rsp), %rdi
callq 0x40a0
movq %rbx, %rdi
callq 0x2310