// File: 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
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x118(%rbp)
movq %rdi, %rax
movq %rax, -0x110(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x565a6
jmp 0x565c5
leaq 0x2d75(%rip), %rdi      # 0x59322
leaq 0x4d4c(%rip), %rsi      # 0x5b300
movl $0x63, %edx
leaq 0x4e2a(%rip), %rcx      # 0x5b3ea
callq 0x31a0
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x565f0
movq -0x118(%rbp), %rdi
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
leaq -0x20(%rbp), %rsi
leaq 0xc281ba(%rip), %rdx    # 0xc7e7a0
callq 0x23c40
jmp 0x56c88
movq -0x10(%rbp), %rax
movslq 0x50(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x50(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq %rcx, %rax
movq -0x10(%rbp), %rcx
movslq 0x54(%rcx), %rcx
shlq %rcx
cmpq %rcx, %rax
jne 0x566bb
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
subl $0x1, %eax
cmpl -0x1c(%rbp), %eax
jg 0x56698
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
decl %eax
movl %eax, -0x24(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0xbd50
movq -0x118(%rbp), %rdi
movq -0x120(%rbp), %rdx
leaq -0x24(%rbp), %rsi
callq 0x23c40
jmp 0x56670
leaq -0x40(%rbp), %rdi
callq 0x5470
jmp 0x56c88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5470
jmp 0x56c98
movq -0x118(%rbp), %rdi
movl $0xffffffff, -0x50(%rbp) # imm = 0xFFFFFFFF
leaq -0x50(%rbp), %rsi
leaq 0xc280ef(%rip), %rdx    # 0xc7e7a0
callq 0x23c40
jmp 0x56c88
movq -0x10(%rbp), %rdi
callq 0x16f10
testb $0x1, %al
jne 0x566ca
jmp 0x566e5
movl $0x2, -0x54(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x23c80
movl (%rax), %eax
movl %eax, -0x14(%rbp)
jmp 0x566fe
movl $0x1, -0x58(%rbp)
leaq -0x1c(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x23e40
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x56729
movq -0x118(%rbp), %rdi
movl $0xffffffff, -0x5c(%rbp) # imm = 0xFFFFFFFF
leaq -0x5c(%rbp), %rsi
leaq 0xc28081(%rip), %rdx    # 0xc7e7a0
callq 0x23c40
jmp 0x56c88
leaq -0x18(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x23c80
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3, 0x50(%rax)
jne 0x56836
movq -0x10(%rbp), %rax
cmpl $0x3, 0x54(%rax)
jne 0x567ba
movl $0x2, -0x60(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0xbd50
movq -0x118(%rbp), %rdi
movq -0x128(%rbp), %rdx
leaq -0x60(%rbp), %rsi
callq 0x23c40
jmp 0x56792
leaq -0x80(%rbp), %rdi
callq 0x5470
jmp 0x56c88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5470
jmp 0x56c98
movl $0x1, -0x84(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movq $0x0, -0x90(%rbp)
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0xbd50
movq -0x118(%rbp), %rdi
movq -0x130(%rbp), %rdx
leaq -0x84(%rbp), %rsi
callq 0x23c40
jmp 0x56808
leaq -0xa0(%rbp), %rdi
callq 0x5470
jmp 0x56c88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x5470
jmp 0x56c98
movb $0x0, -0xa1(%rbp)
movl $0x0, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x568de
movq -0x10(%rbp), %rdi
addq $0x38, %rdi
movslq -0xa8(%rbp), %rsi
callq 0x178a0
movq %rax, %rdi
callq 0x59a0
cmpq $0x1, %rax
jbe 0x5687e
jmp 0x5689d
leaq 0x3bce(%rip), %rdi      # 0x5a453
leaq 0x4a74(%rip), %rsi      # 0x5b300
movl $0x80, %edx
leaq 0x4b52(%rip), %rcx      # 0x5b3ea
callq 0x31a0
movq -0x10(%rbp), %rdi
addq $0x38, %rdi
movslq -0xa8(%rbp), %rsi
callq 0x178a0
movq %rax, %rdi
callq 0x59a0
cmpq $0x2, %rax
jne 0x568c8
movb $0x1, -0xa1(%rbp)
jmp 0x568de
jmp 0x568ca
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x56847
testb $0x1, -0xa1(%rbp)
je 0x56a9a
movq -0x10(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x560b0
movq -0x118(%rbp), %rdi
movb $0x0, -0xc1(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
callq 0x56cb0
jmp 0x5691e
movq -0x118(%rbp), %rdi
addq $0x8, %rdi
leaq 0xc27e70(%rip), %rsi    # 0xc7e7a0
callq 0x5600
movb %al, -0x131(%rbp)
jmp 0x5693d
movb -0x131(%rbp), %al
testb $0x1, %al
jne 0x56949
jmp 0x5698d
movb $0x1, -0xc1(%rbp)
movl $0x1, -0xc8(%rbp)
jmp 0x56a63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x56a89
movq -0x118(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x5a20
jmp 0x56a89
movq -0x118(%rbp), %rdi
addq $0x8, %rdi
movq %rdi, -0x148(%rbp)
callq 0xc040
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xc070
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0xc0b0
movq -0x150(%rbp), %rdi
movq %rax, -0xe0(%rbp)
callq 0xc040
movq -0x148(%rbp), %rdi
movq %rax, -0xe8(%rbp)
movq -0xd0(%rbp), %rsi
movq -0xe0(%rbp), %rdx
movq -0xe8(%rbp), %rcx
callq 0xbf90
movq %rax, -0x140(%rbp)
jmp 0x56a15
movq -0x118(%rbp), %rax
movq -0x140(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jg 0x56a33
jmp 0x56a52
leaq 0x29a5(%rip), %rdi      # 0x593df
leaq 0x48bf(%rip), %rsi      # 0x5b300
movl $0x8b, %edx
leaq 0x499d(%rip), %rcx      # 0x5b3ea
callq 0x31a0
movb $0x1, -0xc1(%rbp)
movl $0x1, -0xc8(%rbp)
testb $0x1, -0xc1(%rbp)
jne 0x56a78
movq -0x118(%rbp), %rdi
callq 0x5a20
leaq -0xc0(%rbp), %rdi
callq 0x5470
jmp 0x56c88
leaq -0xc0(%rbp), %rdi
callq 0x5470
jmp 0x56c98
movq -0x10(%rbp), %rdi
callq 0x56320
movq %rax, -0xf8(%rbp)
cmpl $-0x1, -0xf8(%rbp)
je 0x56bc9
movq -0xf8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x10(%rbp), %rdi
movl -0x100(%rbp), %esi
movl -0xfc(%rbp), %edx
callq 0x15830
movq -0x118(%rbp), %rdi
movb $0x0, -0x101(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
callq 0x56cb0
movq -0x118(%rbp), %rdi
addq $0x8, %rdi
leaq 0xc27c93(%rip), %rsi    # 0xc7e7a0
callq 0x5600
movb %al, -0x151(%rbp)
jmp 0x56b1a
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x56b26
jmp 0x56b56
movb $0x1, -0x101(%rbp)
movl $0x1, -0xc8(%rbp)
jmp 0x56baf
movq -0x118(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x5a20
jmp 0x56c98
movq -0x118(%rbp), %rdi
addq $0x8, %rdi
leaq -0x100(%rbp), %rsi
callq 0x37250
jmp 0x56b6f
movq -0x118(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jg 0x56b7f
jmp 0x56b9e
leaq 0x2859(%rip), %rdi      # 0x593df
leaq 0x4773(%rip), %rsi      # 0x5b300
movl $0x95, %edx
leaq 0x4851(%rip), %rcx      # 0x5b3ea
callq 0x31a0
movb $0x1, -0x101(%rbp)
movl $0x1, -0xc8(%rbp)
testb $0x1, -0x101(%rbp)
jne 0x56bc4
movq -0x118(%rbp), %rdi
callq 0x5a20
jmp 0x56c88
movq -0x118(%rbp), %rdi
movb $0x0, -0x102(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
callq 0x55c40
movq -0x118(%rbp), %rdi
addq $0x8, %rdi
leaq 0xc27ba4(%rip), %rsi    # 0xc7e7a0
callq 0xe160
movb %al, -0x152(%rbp)
jmp 0x56c09
movb -0x152(%rbp), %al
testb $0x1, %al
jne 0x56c15
jmp 0x56c60
movq -0x118(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jg 0x56c25
jmp 0x56c5e
leaq 0x4819(%rip), %rdi      # 0x5b445
leaq 0x46cd(%rip), %rsi      # 0x5b300
movl $0x99, %edx
leaq 0x47ab(%rip), %rcx      # 0x5b3ea
callq 0x31a0
movq -0x118(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x5a20
jmp 0x56c98
jmp 0x56c60
movb $0x1, -0x102(%rbp)
movl $0x1, -0xc8(%rbp)
testb $0x1, -0x102(%rbp)
jne 0x56c86
movq -0x118(%rbp), %rdi
callq 0x5a20
jmp 0x56c88
movq -0x110(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x3480
nopw %cs:(%rax,%rax)