// File: Laakeri[P]Triangulator/src/treewidth.cpp
// Function: TreeWidth::SolveAtom::solveAtom1(Graph const&, int, int, int)
pair<int, vector<pair<int, int> > > solveAtom1(const Graph& G, int lowerBound, int okWidth, int upperBound) {
	assert(lowerBound >= 0);
	assert(okWidth <= upperBound);
	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};
	}
	auto fillO = PMC::solve(G, (int64_t)lowerBound, (int64_t)upperBound, PROBLEM_TREEWIDTH);
	if (fillO == FAILSOLUTION) return {-1, FAILSOLUTION};
	Graph gFillO = G;
	gFillO.addEdges(fillO);
	int width = MCS::getTreeWidth(gFillO);
	assert(width >= lowerBound);
	assert(width <= upperBound);
	return {width, fillO};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x1b8(%rbp)
movq %rdi, %rax
movq %rax, -0x1b0(%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 0x55c76
jmp 0x55c95
leaq 0x36a5(%rip), %rdi      # 0x59322
leaq 0x567c(%rip), %rsi      # 0x5b300
movl $0x18, %edx
leaq 0x567e(%rip), %rcx      # 0x5b30e
callq 0x31a0
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x55c9f
jmp 0x55cbe
leaq 0x3b85(%rip), %rdi      # 0x5982b
leaq 0x5653(%rip), %rsi      # 0x5b300
movl $0x19, %edx
leaq 0x5655(%rip), %rcx      # 0x5b30e
callq 0x31a0
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x55ce9
movq -0x1b8(%rbp), %rdi
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
leaq -0x20(%rbp), %rsi
leaq 0xc28ac1(%rip), %rdx    # 0xc7e7a0
callq 0x23c40
jmp 0x5608b
leaq -0x18(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x23c80
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x28a90
movq -0x10(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0xb8b0
jmp 0x55d1a
leaq -0xa8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x15db0
jmp 0x55d2c
leaq -0xa8(%rbp), %rdi
callq 0x29da0
movl %eax, -0x1bc(%rbp)
jmp 0x55d40
movl -0x1bc(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x55d59
jmp 0x55da6
leaq 0x3504(%rip), %rdi      # 0x59264
leaq 0x5599(%rip), %rsi      # 0x5b300
movl $0x23, %edx
leaq 0x559b(%rip), %rcx      # 0x5b30e
callq 0x31a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x56080
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x56074
movl -0xb8(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0x55dd9
movq -0x1b8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x23cc0
jmp 0x55dca
movl $0x1, -0xbc(%rbp)
jmp 0x5605d
leaq -0x50(%rbp), %rdi
callq 0x5680
cmpq $0x1, %rax
ja 0x55e50
movl -0xb8(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x55e28
movq -0x1b8(%rbp), %rdi
movl $0xffffffff, -0xc0(%rbp) # imm = 0xFFFFFFFF
leaq 0xc28995(%rip), %rdx    # 0xc7e7a0
leaq -0xc0(%rbp), %rsi
callq 0x23c40
jmp 0x55e19
movl $0x1, -0xbc(%rbp)
jmp 0x5605d
movq -0x1b8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x23cc0
jmp 0x55e41
movl $0x1, -0xbc(%rbp)
jmp 0x5605d
movq -0x10(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movslq -0x14(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x3a0f0
jmp 0x55e6d
movslq -0x1c(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x3a0f0
jmp 0x55e7f
movq -0x1c8(%rbp), %rsi
movaps -0x140(%rbp), %xmm0
movaps -0x130(%rbp), %xmm1
movaps -0x120(%rbp), %xmm2
movq %rsp, %rax
movaps %xmm2, 0x50(%rax)
movaps %xmm1, 0x40(%rax)
movaps %xmm0, 0x30(%rax)
movaps -0x110(%rbp), %xmm0
movaps -0x100(%rbp), %xmm1
movaps -0xf0(%rbp), %xmm2
movaps %xmm2, 0x20(%rax)
movaps %xmm1, 0x10(%rax)
movaps %xmm0, (%rax)
leaq -0xd8(%rbp), %rdi
movl $0x2, %edx
callq 0x41440
jmp 0x55edd
leaq 0xc288bc(%rip), %rsi    # 0xc7e7a0
leaq -0xd8(%rbp), %rdi
callq 0x5600
movb %al, -0x1c9(%rbp)
jmp 0x55ef8
movb -0x1c9(%rbp), %al
testb $0x1, %al
jne 0x55f04
jmp 0x55f50
movq -0x1b8(%rbp), %rdi
movl $0xffffffff, -0x144(%rbp) # imm = 0xFFFFFFFF
leaq 0xc28884(%rip), %rdx    # 0xc7e7a0
leaq -0x144(%rbp), %rsi
callq 0x23c40
jmp 0x55f2a
movl $0x1, -0xbc(%rbp)
jmp 0x56041
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
jmp 0x5604f
movq -0x10(%rbp), %rsi
leaq -0x1a0(%rbp), %rdi
callq 0xb8b0
jmp 0x55f62
leaq -0x1a0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x15db0
jmp 0x55f77
leaq -0x1a0(%rbp), %rdi
callq 0x29da0
movl %eax, -0x1d0(%rbp)
jmp 0x55f8b
movl -0x1d0(%rbp), %eax
movl %eax, -0x1a4(%rbp)
movl -0x1a4(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x55fa4
jmp 0x55fe3
leaq 0x334f(%rip), %rdi      # 0x592fa
leaq 0x534e(%rip), %rsi      # 0x5b300
movl $0x2e, %edx
leaq 0x5350(%rip), %rcx      # 0x5b30e
callq 0x31a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb0(%rbp)
movl %eax, -0xb4(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x59e0
jmp 0x5604f
movl -0x1a4(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x55ff0
jmp 0x5600f
leaq 0x3317(%rip), %rdi      # 0x5930e
leaq 0x5302(%rip), %rsi      # 0x5b300
movl $0x2f, %edx
leaq 0x5304(%rip), %rcx      # 0x5b30e
callq 0x31a0
movq -0x1b8(%rbp), %rdi
leaq -0x1a4(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
callq 0x23cc0
jmp 0x5602b
movl $0x1, -0xbc(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x59e0
leaq -0xd8(%rbp), %rdi
callq 0x5470
jmp 0x5605d
leaq -0xd8(%rbp), %rdi
callq 0x5470
jmp 0x56074
leaq -0xa8(%rbp), %rdi
callq 0x59e0
leaq -0x50(%rbp), %rdi
callq 0x57e0
jmp 0x5608b
leaq -0xa8(%rbp), %rdi
callq 0x59e0
leaq -0x50(%rbp), %rdi
callq 0x57e0
jmp 0x5609b
movq -0x1b0(%rbp), %rax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq -0xb0(%rbp), %rdi
callq 0x3480
nopw (%rax,%rax)