// File: /workspace/github_cpp_makefile_star2_O1/Laakeri[P]Triangulator/src/hyper.cpp
// Function: Hyper::SolveGraph::solveFracGraph(Graph const&, long double, long double, long double, std::vector<int, std::allocator<int>> const&)
pair<ld, vector<pair<int, int> > > solveFracGraph(const Graph& G, ld lowerBound, ld okWidth, ld upperBound, const vector<int>& vertMap) {
	assert(lowerBound > -eps);
	assert(okWidth < upperBound + eps);
	if (lowerBound > upperBound) return {-1, FAILSOLUTION};
	okWidth = max(okWidth, lowerBound);
	
	auto fill = MCS::MCS_MP(G);
	
	Graph gFill = G;
	gFill.addEdges(fill.F);
	
	ld fillWidth = MCS::getFracHyperTreeWidth(gFill, vertMap);
	assert(fillWidth > lowerBound - eps);
	
	if (fillWidth < okWidth + eps) return {fillWidth, fill.F};
	
	vector<Graph> atoms = MCS::getAtoms(G, gFill, fill).S;
	
	auto cmp = [](const Graph& a, const Graph& b) {
		return a.n > b.n;
	};
	sort(atoms.begin(), atoms.end(), cmp);
	pair<ld, vector<pair<int, int> > > sol = {lowerBound, {}};
	for (int i = 0; i < (int)atoms.size(); i++) {
		pair<ld, vector<pair<int, int> > > tSol;
		if (i+1 < (int)atoms.size()) {
			tSol = SolveAtom::solveFracAtom(atoms[i], 1, sol.F, min(upperBound, fillWidth), atoms[i].mapTableInto(vertMap));
		}
		else {
			tSol = SolveAtom::solveFracAtom(atoms[i], 1, sol.F, min(upperBound, fillWidth), atoms[i].mapTableInto(vertMap));
		}
		if (tSol.S == FAILSOLUTION) {
			if (fillWidth < upperBound + eps) {
				return {fillWidth, fill.F};
			}
			else {
				return {-1, FAILSOLUTION};
			}
		}
		sol.F = max(sol.F, tSol.F);
		tSol.S = atoms[i].mapBack(tSol.S);
		sol.S.insert(sol.S.end(), tSol.S.begin(), tSol.S.end());
	}
	assert(sol.F < upperBound + eps);
	return sol;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdx, 0xc8(%rsp)
movq %rdi, 0x38(%rsp)
fldt 0x250(%rsp)
fldt 0x240(%rsp)
fldt 0x230(%rsp)
fldl 0x1d11a(%rip)           # 0x2a7b8
fld %st(1)
fstpt 0x44(%rsp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0xddcc
fld %st(1)
faddl 0x1d108(%rip)           # 0x2a7c0
fld %st(0)
fstpt 0x14c(%rsp)
fld %st(1)
fxch %st(1)
fucompi %st(2), %st
fstp %st(1)
jbe 0xddef
fldt 0x44(%rsp)
fucomi %st(2), %st
jbe 0xd703
fstp %st(0)
fstp %st(1)
fstp %st(0)
fld1
fchs
movq 0x38(%rsp), %rbx
fstpt (%rbx)
movq %rbx, %rdi
addq $0x10, %rdi
leaq 0x28b12(%rip), %rsi     # 0x36208
callq 0x402a
movq %rbx, %rax
jmp 0xddba
movq %rsi, %r14
fxch %st(2)
fstpt 0x84(%rsp)
fxch %st(1)
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
fstpt 0xd4(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x12a60
leaq 0x1a0(%rsp), %rdi
movq %r14, %rsi
callq 0x431c
leaq 0x1b8(%rsp), %r15
leaq 0x18(%r14), %rsi
movq %r15, %rdi
callq 0x7e36
movb 0x30(%r14), %al
leaq 0x1d8(%rsp), %rbx
movb %al, -0x8(%rbx)
leaq 0x38(%r14), %rsi
movq %rbx, %rdi
callq 0x4164
movq 0x50(%r14), %rax
leaq 0x1a0(%rsp), %rdi
movq %rax, 0x50(%rdi)
leaq 0x170(%rsp), %rsi
callq 0x9880
leaq 0x1a0(%rsp), %rdi
movq 0xc8(%rsp), %rsi
callq 0x14467
fldt 0x44(%rsp)
faddl 0x1d010(%rip)           # 0x2a7b8
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jbe 0xde12
fldt 0xd4(%rsp)
faddl 0x1cfff(%rip)           # 0x2a7c0
fucompi %st(1), %st
jbe 0xd7e4
movq 0x38(%rsp), %rdi
fstpt (%rdi)
addq $0x10, %rdi
leaq 0x170(%rsp), %rsi
callq 0x402a
fldz
jmp 0xdd4c
fstpt 0xd4(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0x1a0(%rsp), %rdx
leaq 0x170(%rsp), %rcx
movq %r14, %rsi
callq 0x12fba
leaq 0xe8(%rsp), %rdi
movq (%rdi), %rax
movq %rax, 0x130(%rsp)
movups 0x8(%rdi), %xmm0
movups %xmm0, 0x138(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x69a0
movq 0x130(%rsp), %r15
movq 0x138(%rsp), %r14
cmpq %r14, %r15
je 0xd8be
movq %r14, %rbx
subq %r15, %rbx
movq %rbx, %rax
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0xf840
cmpq $0x581, %rbx            # imm = 0x581
jl 0xd8b3
leaq 0x580(%r15), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x100b4
cmpq %r14, %r13
je 0xd8be
movq %r13, %rdi
callq 0x102ad
addq $0x58, %r13
jmp 0xd8a0
movq %r15, %rdi
movq %r14, %rsi
callq 0x100b4
leaq 0x50(%rsp), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
fldt 0x44(%rsp)
fstpt 0xe0(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x402a
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xd900
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x38(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x110(%rsp)
fldt 0x84(%rsp)
fldt 0xd4(%rsp)
fxch %st(1)
fucomi %st(1), %st
fcmovnbe %st(1), %st
fstp %st(1)
xorl %ebx, %ebx
leaq 0x118(%rsp), %rbp
leaq 0x158(%rsp), %r15
fstpt 0x84(%rsp)
movq 0x130(%rsp), %r14
movq 0x138(%rsp), %rax
subq %r14, %rax
sarq $0x3, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rcx, %rax
movslq %eax, %rcx
cmpq %rcx, %rbx
jge 0xdcb9
fldz
fstpt 0x50(%rsp)
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rcx
movaps %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
imulq $0x58, %rbx, %r12
incq %rbx
addq %r12, %r14
cmpl %eax, %ebx
jge 0xd9e3
fldt 0xe0(%rsp)
fstpt 0x44(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
movq 0xc8(%rsp), %rdx
callq 0x104a6
fldt 0x84(%rsp)
fstpt 0x20(%rsp)
fldt 0x44(%rsp)
fstpt 0x10(%rsp)
fld1
fstpt (%rsp)
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0xc854
jmp 0xda2c
fldt 0xe0(%rsp)
fstpt 0x44(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
movq 0xc8(%rsp), %rdx
callq 0x104a6
fldt 0x84(%rsp)
fstpt 0x20(%rsp)
fldt 0x44(%rsp)
fstpt 0x10(%rsp)
fld1
fstpt (%rsp)
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0xc854
fldt 0x90(%rsp)
fstpt 0x50(%rsp)
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rsi
movq 0xa0(%rsp), %rcx
movq %rcx, 0x60(%rsp)
movups 0xa8(%rsp), %xmm0
movups %xmm0, 0x68(%rsp)
movq %rdi, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
movq %rsi, 0xb0(%rsp)
leaq 0xa0(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
testq %rdi, %rdi
je 0xda9b
subq %rdi, %rsi
callq 0x2210
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xdab8
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
je 0xdad5
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rax
movq %rax, %rsi
subq %rcx, %rsi
movq 0x28724(%rip), %rdi     # 0x36210
movq 0x28715(%rip), %rdx     # 0x36208
subq %rdx, %rdi
cmpq %rdi, %rsi
jne 0xdb44
cmpq %rax, %rcx
sete %r13b
je 0xdb47
movl (%rcx), %esi
xorl %r13d, %r13d
cmpl (%rdx), %esi
jne 0xdb47
movl 0x4(%rdx), %esi
cmpl %esi, 0x4(%rcx)
jne 0xdb47
addq $0x8, %rcx
addq $0xc, %rdx
cmpq %rax, %rcx
sete %r13b
je 0xdb47
movl (%rcx), %esi
xorl %r13d, %r13d
cmpl -0x4(%rdx), %esi
jne 0xdb47
leaq 0x8(%rcx), %rsi
movl (%rdx), %edi
addq $0x8, %rdx
cmpl %edi, 0x4(%rcx)
movq %rsi, %rcx
je 0xdb1d
jmp 0xdb47
xorl %r13d, %r13d
testb %r13b, %r13b
je 0xdb85
fldt 0x14c(%rsp)
fldt 0xd4(%rsp)
fxch %st(1)
fucompi %st(1), %st
jbe 0xdc6d
movq 0x38(%rsp), %rax
fstpt (%rax)
movq 0x110(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x402a
jmp 0xdc8e
fldt 0xe0(%rsp)
fldt 0x50(%rsp)
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
fstpt 0xe0(%rsp)
movq 0x130(%rsp), %r14
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
callq 0x402a
addq %r12, %r14
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x9f86
movq 0x60(%rsp), %rdi
movq 0x70(%rsp), %rsi
movq 0x90(%rsp), %rax
movq %rax, 0x60(%rsp)
movups 0x98(%rsp), %xmm0
movups %xmm0, 0x68(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
testq %rdi, %rdi
je 0xdc12
subq %rdi, %rsi
callq 0x2210
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0xdc2f
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0xdc4c
movq 0x168(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0xf8(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x68(%rsp), %rcx
leaq 0xf0(%rsp), %rdi
callq 0x8bb4
jmp 0xdc8e
fstp %st(0)
fld1
fchs
movq 0x38(%rsp), %rax
fstpt (%rax)
movq 0x110(%rsp), %rdi
leaq 0x2857f(%rip), %rsi     # 0x36208
callq 0x402a
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xdca5
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
testb %r13b, %r13b
fldt 0x84(%rsp)
fstp %st(0)
je 0xd940
jmp 0xdd10
fldt 0xe0(%rsp)
fldt 0x14c(%rsp)
fucompi %st(1), %st
jbe 0xde33
movq 0x38(%rsp), %rcx
fstpt (%rcx)
movq 0xf0(%rsp), %rax
movq %rax, 0x10(%rcx)
movq 0xf8(%rsp), %rax
movq %rax, 0x18(%rcx)
movq 0x100(%rsp), %rax
movq %rax, 0x20(%rcx)
xorps %xmm0, %xmm0
leaq 0xf0(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0xdd2d
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
leaq 0x130(%rsp), %rdi
callq 0x69a0
leaq 0x1b8(%rsp), %r15
leaq 0x1d8(%rsp), %rbx
fldz
fstp %st(0)
movq %rbx, %rdi
callq 0x41fe
movq %r15, %rdi
callq 0x43b8
movq 0x1a0(%rsp), %rdi
testq %rdi, %rdi
je 0xdd7b
movq 0x1b0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x188(%rsp), %rdi
testq %rdi, %rdi
je 0xdd98
movq 0x198(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0xddb5
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x38(%rsp), %rax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
fstp %st(1)
fstp %st(0)
leaq 0x1ca8a(%rip), %rdi     # 0x2a861
leaq 0x1c9f2(%rip), %rsi     # 0x2a7d0
leaq 0x1cbdc(%rip), %rcx     # 0x2a9c1
movl $0x93, %edx
callq 0x2140
fstp %st(1)
fstp %st(0)
leaq 0x1caea(%rip), %rdi     # 0x2a8e4
leaq 0x1c9cf(%rip), %rsi     # 0x2a7d0
leaq 0x1cbb9(%rip), %rcx     # 0x2a9c1
movl $0x94, %edx
callq 0x2140
fstp %st(0)
leaq 0x1cae4(%rip), %rdi     # 0x2a8ff
leaq 0x1c9ae(%rip), %rsi     # 0x2a7d0
leaq 0x1cb98(%rip), %rcx     # 0x2a9c1
movl $0x9e, %edx
callq 0x2140
fstp %st(0)
leaq 0x1cbf8(%rip), %rdi     # 0x2aa34
leaq 0x1c98d(%rip), %rsi     # 0x2a7d0
leaq 0x1cb77(%rip), %rcx     # 0x2a9c1
movl $0xbd, %edx
callq 0x2140
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xdf3a
movq 0x60(%rsp), %rsi
jmp 0xdf32
jmp 0xdeb3
jmp 0xdeb3
movq %rax, %rbx
movq %r15, %rdi
callq 0x43b8
jmp 0xde83
movq %rax, %rbx
movq 0x1a0(%rsp), %rdi
testq %rdi, %rdi
je 0xdf54
movq 0x1b0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0xdf54
movq %rax, %rbx
jmp 0xdf54
fstp %st(0)
movq %rax, %rbx
jmp 0xdf47
jmp 0xdec5
jmp 0xdec5
jmp 0xdec5
jmp 0xdec5
jmp 0xdec5
movq %rax, %rbx
jmp 0xdf06
jmp 0xdecc
movq %rax, %rbx
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
je 0xdf06
movq 0x128(%rsp), %rsi
jmp 0xdefe
movq %rax, %rbx
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0xdf06
movq 0x168(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xdf1d
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0xdf3a
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
leaq 0x130(%rsp), %rdi
callq 0x69a0
leaq 0x1a0(%rsp), %rdi
callq 0x412c
leaq 0x170(%rsp), %rdi
callq 0x40a0
movq %rbx, %rdi
callq 0x2310