// File: /workspace/github_cpp_makefile_star2_O1/Laakeri[P]Triangulator/src/treewidth.cpp
// Function: TreeWidth::SolveAtom::solveAtom0(Graph&, int, int, int)
pair<int, vector<pair<int, int> > > solveAtom0(Graph& G, int lowerBound, int okWidth, int upperBound) {
	assert(lowerBound >= 0);
	if (lowerBound > upperBound) return {-1, FAILSOLUTION};
	if ((int64_t)G.n*(int64_t)(G.n-1) == (int64_t)G.m*2) {
		if (G.n-1 <= upperBound) {
			return {G.n-1, {}};
		}
		else {
			return {-1, FAILSOLUTION};
		}
	}
	if (G.hasCycle()) {
		lowerBound = max(lowerBound, 2);
	}
	else {
		upperBound = min(upperBound, 1);
	}
	if (lowerBound > upperBound) return {-1, FAILSOLUTION};
	okWidth = max(okWidth, lowerBound);

	if (G.n == 3) {
		if (G.m == 3) {
			return {2, {}};
		}
		else {
			return {1, {}};
		}
	}
	bool hasd2 = false;
	for (int i = 0; i < G.n; i++) {
		assert(G.g[i].size() > 1);
		if (G.g[i].size() == 2) {
			hasd2 = true;
			break;
		}
	}
	if (hasd2) {
		auto sol0 = greedyDegree2(G);
		auto sol = SolveGraph::solveGraph(G, lowerBound, okWidth, upperBound);
		if (sol.S == FAILSOLUTION) return sol;
		sol.S.insert(sol.S.end(), sol0.begin(), sol0.end());
		assert(sol.F <= upperBound);
		return sol;
	}
	auto nbC = nbClique(G);
	if (nbC.F != -1) {
		auto sol0 = nbC;
		G.addEdge(sol0.F, sol0.S);
		auto sol = SolveGraph::solveGraph(G, lowerBound, okWidth, upperBound);
		if (sol.S == FAILSOLUTION) return sol;
		sol.S.push_back(sol0);
		assert(sol.F <= upperBound);
		return sol;
	}
	auto ret = solveAtom1(G, lowerBound, okWidth, upperBound);
	if (ret.S != FAILSOLUTION) assert(ret.F <= upperBound);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testl %edx, %edx
js 0x27d39
movl %r8d, %r13d
movl %edx, %ebp
movq %rdi, %rbx
cmpl %r8d, %edx
jle 0x27a46
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
movq %rbx, %rdi
addq $0x8, %rdi
leaq 0xc12c91(%rip), %rsi    # 0xc3a6c0
callq 0x402a
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ecx, %r14d
movq %rsi, %r15
movslq 0x50(%rsi), %rcx
leaq -0x1(%rcx), %rax
imulq %rax, %rcx
movslq 0x54(%rsi), %rdx
addq %rdx, %rdx
cmpq %rdx, %rcx
jne 0x27aa0
cmpl %r13d, %eax
jg 0x27a1b
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl %eax, (%rbx)
movq %rbx, %rdi
addq $0x8, %rdi
callq 0x402a
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x27a34
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x27a34
movq %r15, %rdi
callq 0xa27c
cmpl $0x3, %ebp
movl $0x2, %r12d
cmovgel %ebp, %r12d
testl %r13d, %r13d
movl $0x1, %ecx
cmovlel %r13d, %ecx
testb %al, %al
cmovnel %r13d, %ecx
cmovel %ebp, %r12d
cmpl %ecx, %r12d
jg 0x27a1b
movl %ecx, %ebp
cmpl %r14d, %r12d
cmovgl %r12d, %r14d
movl 0x50(%r15), %ecx
cmpq $0x3, %rcx
jne 0x27b17
leaq 0x8(%rbx), %rdi
cmpl $0x3, 0x54(%r15)
jne 0x27c0e
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl $0x2, (%rbx)
callq 0x402a
jmp 0x27a88
testl %ecx, %ecx
jle 0x27b4f
movq 0x38(%r15), %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
movq 0x8(%rax,%rdx), %rsi
subq (%rax,%rdx), %rsi
cmpq $0x4, %rsi
jbe 0x27d58
cmpq $0x8, %rsi
je 0x27c2f
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0x27b29
movq %r15, %rdi
callq 0x27870
cmpl $-0x1, %eax
je 0x27ca5
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, (%rsp)
movl %edx, 0x4(%rsp)
movq %r15, %rdi
movl %eax, %esi
callq 0x9512
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x27dcc
movq 0x8(%rbx), %rcx
movq 0x10(%rbx), %rax
movq %rax, %rsi
subq %rcx, %rsi
movq 0xc12b27(%rip), %rdi    # 0xc3a6c8
movq 0xc12b18(%rip), %rdx    # 0xc3a6c0
subq %rdx, %rdi
cmpq %rdi, %rsi
jne 0x27d03
cmpq %rax, %rcx
sete %sil
je 0x27cfa
movl (%rcx), %esi
cmpl (%rdx), %esi
jne 0x27d03
movl 0x4(%rdx), %esi
cmpl %esi, 0x4(%rcx)
jne 0x27d03
addq $0x8, %rcx
addq $0xc, %rdx
cmpq %rax, %rcx
sete %sil
je 0x27cfa
movl (%rcx), %esi
cmpl -0x4(%rdx), %esi
jne 0x27d03
leaq 0x8(%rcx), %rsi
movl (%rdx), %edi
addq $0x8, %rdx
cmpl %edi, 0x4(%rcx)
movq %rsi, %rcx
je 0x27bdf
jmp 0x27d03
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl $0x1, (%rbx)
callq 0x402a
jmp 0x27a88
movq %rsp, %rdi
movq %r15, %rsi
callq 0x2767d
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x27dcc
leaq 0x8(%rbx), %r15
leaq 0xc12a67(%rip), %rsi    # 0xc3a6c0
movq %r15, %rdi
callq 0x1a9e2
testb %al, %al
jne 0x27a88
movq 0x10(%rbx), %rsi
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
movq %r15, %rdi
callq 0x8bb4
cmpl %ebp, (%rbx)
jle 0x27a88
leaq 0x276e(%rip), %rdi      # 0x2a3fb
leaq 0x46ac(%rip), %rsi      # 0x2c340
leaq 0x478f(%rip), %rcx      # 0x2c42a
movl $0x8b, %edx
callq 0x2140
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x27174
leaq 0x8(%rbx), %r15
leaq 0xc129fc(%rip), %rsi    # 0xc3a6c0
movq %r15, %rdi
callq 0x1a7fa
cmpl %ebp, (%rbx)
setg %cl
andb %cl, %al
cmpb $0x1, %al
jne 0x27a34
leaq 0x47a3(%rip), %rdi      # 0x2c485
leaq 0x4657(%rip), %rsi      # 0x2c340
leaq 0x473a(%rip), %rcx      # 0x2c42a
movl $0x99, %edx
callq 0x2140
testb %sil, %sil
jne 0x27a34
leaq 0x8(%rbx), %r15
movq %rsp, %rsi
movq %r15, %rdi
callq 0x1a976
cmpl %ebp, (%rbx)
jle 0x27a34
leaq 0x26da(%rip), %rdi      # 0x2a3fb
leaq 0x4618(%rip), %rsi      # 0x2c340
leaq 0x46fb(%rip), %rcx      # 0x2c42a
movl $0x95, %edx
callq 0x2140
leaq 0x25fe(%rip), %rdi      # 0x2a33e
leaq 0x45f9(%rip), %rsi      # 0x2c340
leaq 0x46dc(%rip), %rcx      # 0x2c42a
movl $0x63, %edx
callq 0x2140
leaq 0x3714(%rip), %rdi      # 0x2b473
leaq 0x45da(%rip), %rsi      # 0x2c340
leaq 0x46bd(%rip), %rcx      # 0x2c42a
movl $0x80, %edx
callq 0x2140
jmp 0x27d7b
jmp 0x27d96
movq %rax, %r14
movq (%r15), %rdi
testq %rdi, %rdi
je 0x27dae
movq 0x18(%rbx), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x27dae
jmp 0x27dab
movq %rax, %r14
movq (%r15), %rdi
testq %rdi, %rdi
je 0x27dc4
movq 0x18(%rbx), %rsi
jmp 0x27dbc
jmp 0x27dab
jmp 0x27dab
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x27dc4
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %r14, %rdi
callq 0x2310