// File: /workspace/github_cpp_makefile_star2_O3/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 0x274dd
movl %r8d, %r13d
movl %edx, %ebp
movq %rdi, %rbx
cmpl %r8d, %edx
jle 0x2721a
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
movq %rbx, %rdi
addq $0x8, %rdi
leaq 0xc124bd(%rip), %rsi    # 0xc396c0
callq 0x3f7c
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 0x27276
cmpl %r13d, %eax
jg 0x271ef
xorpd %xmm0, %xmm0
movq %rsp, %rsi
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl %eax, (%rbx)
movq %rbx, %rdi
addq $0x8, %rdi
callq 0x3f7c
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x27208
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x27208
movq %r15, %rdi
callq 0xa5b2
cmpl $0x3, %ebp
movl $0x2, %r12d
cmovael %ebp, %r12d
xorl %ecx, %ecx
testl %r13d, %r13d
setne %cl
testb %al, %al
cmovnel %r13d, %ecx
cmovel %ebp, %r12d
cmpl %ecx, %r12d
ja 0x271ef
movl %ecx, %ebp
cmpl %r14d, %r12d
cmovgl %r12d, %r14d
movl 0x50(%r15), %ecx
cmpq $0x3, %rcx
jne 0x272eb
leaq 0x8(%rbx), %rdi
cmpl $0x3, 0x54(%r15)
jne 0x273b9
xorpd %xmm0, %xmm0
movq %rsp, %rsi
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl $0x2, (%rbx)
callq 0x3f7c
jmp 0x2725e
testl %ecx, %ecx
jle 0x27323
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 0x274fc
cmpq $0x8, %rsi
je 0x273dc
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0x272fd
movq %r15, %rdi
callq 0x27066
cmpl $-0x1, %eax
je 0x27488
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, (%rsp)
movl %edx, 0x4(%rsp)
movq %r15, %rdi
movl %eax, %esi
callq 0x9836
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x27570
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
movq %rcx, %rsi
subq %rax, %rsi
movq 0xc12353(%rip), %rdi    # 0xc396c8
movq 0xc12344(%rip), %rdx    # 0xc396c0
subq %rdx, %rdi
cmpq %rdi, %rsi
jne 0x27452
cmpq %rcx, %rax
je 0x27208
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 0x27452
addq $0x8, %rax
addq $0x8, %rdx
jmp 0x27388
xorpd %xmm0, %xmm0
movq %rsp, %rsi
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl $0x1, (%rbx)
callq 0x3f7c
jmp 0x2725e
movq %rsp, %rdi
movq %r15, %rsi
callq 0x26e73
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x27570
leaq 0x8(%rbx), %r15
leaq 0xc122ba(%rip), %rsi    # 0xc396c0
movq %r15, %rdi
callq 0x1ab70
testb %al, %al
jne 0x2725e
movq 0x10(%rbx), %rsi
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
movq %r15, %rdi
callq 0x8ecc
cmpl %ebp, (%rbx)
jle 0x2725e
leaq 0x1fd1(%rip), %rdi      # 0x2940b
leaq 0x3f0f(%rip), %rsi      # 0x2b350
leaq 0x3ff2(%rip), %rcx      # 0x2b43a
movl $0x8b, %edx
callq 0x2140
leaq 0x8(%rbx), %r15
movq %rsp, %rsi
movq %r15, %rdi
callq 0x1aafe
cmpl %ebp, (%rbx)
jle 0x27208
leaq 0x1f9b(%rip), %rdi      # 0x2940b
leaq 0x3ed9(%rip), %rsi      # 0x2b350
leaq 0x3fbc(%rip), %rcx      # 0x2b43a
movl $0x95, %edx
callq 0x2140
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x26984
leaq 0x8(%rbx), %r15
leaq 0xc12219(%rip), %rsi    # 0xc396c0
movq %r15, %rdi
callq 0x1a9a2
cmpl %ebp, (%rbx)
setg %cl
andb %cl, %al
cmpb $0x1, %al
jne 0x27208
leaq 0x3fd0(%rip), %rdi      # 0x2b495
leaq 0x3e84(%rip), %rsi      # 0x2b350
leaq 0x3f67(%rip), %rcx      # 0x2b43a
movl $0x99, %edx
callq 0x2140
leaq 0x1e6a(%rip), %rdi      # 0x2934e
leaq 0x3e65(%rip), %rsi      # 0x2b350
leaq 0x3f48(%rip), %rcx      # 0x2b43a
movl $0x63, %edx
callq 0x2140
leaq 0x2f80(%rip), %rdi      # 0x2a483
leaq 0x3e46(%rip), %rsi      # 0x2b350
leaq 0x3f29(%rip), %rcx      # 0x2b43a
movl $0x80, %edx
callq 0x2140
jmp 0x27530
jmp 0x2751f
movq %rax, %r14
movq (%r15), %rdi
testq %rdi, %rdi
je 0x27568
movq 0x18(%rbx), %rsi
jmp 0x27560
movq %rax, %r14
movq (%r15), %rdi
testq %rdi, %rdi
je 0x27552
movq 0x18(%rbx), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x27552
jmp 0x2754f
jmp 0x2754f
jmp 0x2754f
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x27568
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %r14, %rdi
callq 0x2310