// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]Triangulator/src/hyper.cpp
// Function: Hyper::SolveAtom::solveAtom(Graph const&, int, int, int, std::vector<int, std::allocator<int>> const&)
pair<int, vector<pair<int, int> > > solveAtom(const Graph& G, int lowerBound, int okWidth, int upperBound, const vector<int>& vertMap) {
	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::getHyperTreeWidth(gFill, vertMap);
	assert(fillWidth >= lowerBound);
	
	if (fillWidth <= okWidth) return {fillWidth, fill.F};
	
	if (fill.F.size() == 0) {
		if (fillWidth <= upperBound) return {fillWidth, fill.F};
		else return {-1, FAILSOLUTION};
	}
	
	PMC::initVertMap(vertMap);
	auto fillO = PMC::solve(G, (int64_t)lowerBound, (int64_t)upperBound, PROBLEM_HYPER);
	if (fillO == FAILSOLUTION) return {-1, FAILSOLUTION};
	Graph gFillO = G;
	gFillO.addEdges(fillO);
	int width = MCS::getHyperTreeWidth(gFillO, vertMap);
	assert(width >= lowerBound);
	assert(width <= upperBound);
	return {width, fillO};
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
testl %edx, %edx
js 0xa668
movl %r8d, %ebp
movl %ecx, %r13d
cmpl %r8d, %ecx
jg 0xa681
movl %edx, %r14d
movq %rdi, %rbx
cmpl %ebp, %edx
jle 0xa449
orl $-0x1, (%rbx)
movq %rbx, %rdi
addq $0x8, %rdi
leaq 0x25dd9(%rip), %rsi     # 0x30218
callq 0x35f2
jmp 0xa64c
movq %r9, %r15
movq %rsi, %r12
cmpl %r14d, %r13d
cmovlel %r14d, %r13d
leaq 0x90(%rsp), %rdi
callq 0xe30c
leaq 0x180(%rsp), %rdi
movq %r12, %rsi
callq 0x5152
leaq 0x180(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x7cf8
leaq 0x180(%rsp), %rdi
movq %r15, %rsi
callq 0xf49b
cmpl %r14d, %eax
jl 0xa69a
cmpl %r13d, %eax
jbe 0xa58d
movq 0x98(%rsp), %rcx
cmpq 0x90(%rsp), %rcx
je 0xa5a8
leaq 0x78(%rsp), %rdi
movq %r15, %rsi
callq 0x3896
leaq 0x78(%rsp), %rdi
callq 0x14b58
leaq 0x78(%rsp), %rdi
callq 0x38e4
movl %r14d, %esi
leaq 0xf0(%rsp), %rdi
callq 0x14b7c
movl %ebp, %esi
leaq 0xc0(%rsp), %rdi
callq 0x14b7c
movaps 0xc0(%rsp), %xmm0
movaps 0xd0(%rsp), %xmm1
movaps 0xe0(%rsp), %xmm2
movaps %xmm2, 0x50(%rsp)
movaps %xmm1, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps 0xf0(%rsp), %xmm0
movaps 0x100(%rsp), %xmm1
movaps 0x110(%rsp), %xmm2
movaps %xmm2, 0x20(%rsp)
movaps %xmm1, 0x10(%rsp)
movaps %xmm0, (%rsp)
leaq 0x60(%rsp), %rdi
pushq $0x4
popq %rdx
movq %r12, %rsi
callq 0x18a6f
leaq 0x25cb4(%rip), %rsi     # 0x30218
leaq 0x60(%rsp), %rdi
callq 0x35c8
testb %al, %al
je 0xa5c5
orl $-0x1, (%rbx)
movq %rbx, %rdi
addq $0x8, %rdi
leaq 0x25c95(%rip), %rsi     # 0x30218
callq 0x35f2
jmp 0xa628
movl %eax, (%rbx)
movq %rbx, %rdi
addq $0x8, %rdi
leaq 0x90(%rsp), %rsi
callq 0x35f2
jmp 0xa632
leaq 0x8(%rbx), %rdi
cmpl %ebp, %eax
jbe 0xa661
orl $-0x1, (%rbx)
leaq 0x25c5a(%rip), %rsi     # 0x30218
callq 0x35f2
jmp 0xa632
leaq 0x128(%rsp), %rdi
movq %r12, %rsi
callq 0x5152
leaq 0x128(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x7cf8
leaq 0x128(%rsp), %rdi
movq %r15, %rsi
callq 0xf49b
cmpl %r14d, %eax
jl 0xa6b7
cmpl %ebp, %eax
ja 0xa6d0
movl %eax, (%rbx)
movq %rbx, %rdi
addq $0x8, %rdi
leaq 0x60(%rsp), %rsi
callq 0x35f2
leaq 0x128(%rsp), %rdi
callq 0x36d2
leaq 0x60(%rsp), %rdi
callq 0x3bfe
leaq 0x180(%rsp), %rdi
callq 0x36d2
leaq 0x90(%rsp), %rdi
callq 0x3642
movq %rbx, %rax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, (%rbx)
jmp 0xa596
leaq 0x15cdf(%rip), %rdi     # 0x2034e
leaq 0x1616a(%rip), %rsi     # 0x207e0
leaq 0x1616d(%rip), %rcx     # 0x207ea
pushq $0x1e
jmp 0xa6b1
leaq 0x161d3(%rip), %rdi     # 0x2085b
leaq 0x16151(%rip), %rsi     # 0x207e0
leaq 0x16154(%rip), %rcx     # 0x207ea
pushq $0x1f
jmp 0xa6b1
leaq 0x15bef(%rip), %rdi     # 0x20290
leaq 0x16138(%rip), %rsi     # 0x207e0
leaq 0x1613b(%rip), %rcx     # 0x207ea
pushq $0x2a
popq %rdx
callq 0x2150
leaq 0x15c68(%rip), %rdi     # 0x20326
leaq 0x1611b(%rip), %rsi     # 0x207e0
leaq 0x1611e(%rip), %rcx     # 0x207ea
pushq $0x39
jmp 0xa6b1
leaq 0x15c63(%rip), %rdi     # 0x2033a
leaq 0x16102(%rip), %rsi     # 0x207e0
leaq 0x16105(%rip), %rcx     # 0x207ea
pushq $0x3a
jmp 0xa6b1
jmp 0xa72a
jmp 0xa6f1
jmp 0xa703
jmp 0xa703
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x36d2
jmp 0xa706
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3bfe
jmp 0xa72d
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x38e4
jmp 0xa72d
jmp 0xa72a
jmp 0xa72a
movq %rax, %rbx
jmp 0xa73a
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0x36d2
leaq 0x90(%rsp), %rdi
callq 0x3642
movq %rbx, %rdi
callq 0x2340