// File: 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
movq %rsp, %rbp
subq $0x3e0, %rsp            # imm = 0x3E0
movq %rdi, -0x2f8(%rbp)
movq %rdi, %rax
movq %rax, -0x2f0(%rbp)
fldt 0x30(%rbp)
fldt 0x20(%rbp)
fldt 0x10(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
fstpt -0x20(%rbp)
fstpt -0x30(%rbp)
fstpt -0x40(%rbp)
movq %rdx, -0x48(%rbp)
fldt -0x20(%rbp)
fldl 0x39795(%rip)           # 0x59798
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x2000f
jmp 0x2000d
jmp 0x2002e
leaq 0x3982b(%rip), %rdi     # 0x59841
leaq 0x39793(%rip), %rsi     # 0x597b0
movl $0x93, %edx
leaq 0x39978(%rip), %rcx     # 0x599a1
callq 0x31a0
fldt -0x30(%rbp)
fldt -0x40(%rbp)
fldl 0x39766(%rip)           # 0x597a0
faddp %st, %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x20046
jmp 0x20044
jmp 0x20065
leaq 0x39877(%rip), %rdi     # 0x598c4
leaq 0x3975c(%rip), %rsi     # 0x597b0
movl $0x94, %edx
leaq 0x39941(%rip), %rcx     # 0x599a1
callq 0x31a0
fldt -0x20(%rbp)
fldt -0x40(%rbp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x20098
jmp 0x20075
movq -0x2f8(%rbp), %rdi
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
leaq -0x4c(%rbp), %rsi
leaq 0x5a25a(%rip), %rdx     # 0x7a2e8
callq 0x23d00
jmp 0x2083b
leaq -0x30(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x23d40
fldt (%rax)
fstpt -0x30(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x28a90
movq -0x10(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0xb8b0
jmp 0x200c9
leaq -0xd8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x15db0
jmp 0x200db
movq -0x48(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x2b3c0
fstpt -0x304(%rbp)
jmp 0x200f3
fldt -0x304(%rbp)
fstpt -0x100(%rbp)
fldt -0x100(%rbp)
fldt -0x20(%rbp)
fldl 0x3968a(%rip)           # 0x59798
faddp %st, %st(1)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x2011c
jmp 0x2011a
jmp 0x20169
leaq 0x397bc(%rip), %rdi     # 0x598df
leaq 0x39686(%rip), %rsi     # 0x597b0
movl $0x9e, %edx
leaq 0x3986b(%rip), %rcx     # 0x599a1
callq 0x31a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x20830
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x20824
fldt -0x100(%rbp)
fldt -0x30(%rbp)
fldl 0x39628(%rip)           # 0x597a0
faddp %st, %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x201aa
jmp 0x20182
movq -0x2f8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x23d80
jmp 0x2019b
movl $0x1, -0x104(%rbp)
jmp 0x2080d
movq -0x10(%rbp), %rsi
leaq -0x140(%rbp), %rdi
leaq -0xd8(%rbp), %rdx
leaq -0x80(%rbp), %rcx
callq 0x292b0
jmp 0x201c7
leaq -0x138(%rbp), %rsi
leaq -0x120(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0xbca0
leaq -0x140(%rbp), %rdi
callq 0xbcd0
movq -0x310(%rbp), %rdi
callq 0xbcf0
movq -0x310(%rbp), %rdi
movq %rax, -0x150(%rbp)
callq 0xbd20
movq %rax, -0x158(%rbp)
movq -0x150(%rbp), %rdi
movq -0x158(%rbp), %rsi
callq 0x20860
jmp 0x20228
xorps %xmm0, %xmm0
movaps %xmm0, -0x1b0(%rbp)
movq $0x0, -0x1a0(%rbp)
leaq -0x1b0(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0xbd50
movq -0x318(%rbp), %rdx
leaq -0x190(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x24030
jmp 0x20269
leaq -0x1b0(%rbp), %rdi
callq 0x5470
movl $0x0, -0x1b4(%rbp)
movl -0x1b4(%rbp), %eax
movl %eax, -0x31c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0xbd70
movq %rax, %rcx
movl -0x31c(%rbp), %eax
cmpl %ecx, %eax
jge 0x20782
leaq -0x1f0(%rbp), %rdi
callq 0x24070
jmp 0x202b6
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x320(%rbp)
leaq -0x120(%rbp), %rdi
callq 0xbd70
movq %rax, %rcx
movl -0x320(%rbp), %eax
cmpl %ecx, %eax
jge 0x20448
movslq -0x1b4(%rbp), %rsi
leaq -0x120(%rbp), %rdi
callq 0xbde0
movq %rax, -0x340(%rbp)
fldt -0x190(%rbp)
fstpt -0x334(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x240b0
movq %rax, -0x328(%rbp)
jmp 0x20321
movq -0x328(%rbp), %rax
fldt (%rax)
fstpt -0x34c(%rbp)
movslq -0x1b4(%rbp), %rsi
leaq -0x120(%rbp), %rdi
callq 0xbde0
movq %rax, %rsi
movq -0x48(%rbp), %rdx
leaq -0x238(%rbp), %rdi
callq 0x23e80
jmp 0x20358
movq -0x340(%rbp), %rsi
fldt -0x334(%rbp)
fldt -0x34c(%rbp)
movq %rsp, %rax
fstpt 0x20(%rax)
fstpt 0x10(%rax)
fld1
fstpt (%rax)
leaq -0x220(%rbp), %rdi
leaq -0x238(%rbp), %rdx
callq 0x1f200
jmp 0x2038d
leaq -0x1f0(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x240f0
leaq -0x220(%rbp), %rdi
callq 0x24130
leaq -0x238(%rbp), %rdi
callq 0x6d30
jmp 0x20543
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x207ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x5470
jmp 0x207ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x207f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x20774
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x6d30
jmp 0x20774
movslq -0x1b4(%rbp), %rsi
leaq -0x120(%rbp), %rdi
callq 0xbde0
movq %rax, -0x370(%rbp)
fldt -0x190(%rbp)
fstpt -0x364(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x240b0
movq %rax, -0x358(%rbp)
jmp 0x20487
movq -0x358(%rbp), %rax
fldt (%rax)
fstpt -0x37c(%rbp)
movslq -0x1b4(%rbp), %rsi
leaq -0x120(%rbp), %rdi
callq 0xbde0
movq %rax, %rsi
movq -0x48(%rbp), %rdx
leaq -0x288(%rbp), %rdi
callq 0x23e80
jmp 0x204be
movq -0x370(%rbp), %rsi
fldt -0x364(%rbp)
fldt -0x37c(%rbp)
movq %rsp, %rax
fstpt 0x20(%rax)
fstpt 0x10(%rax)
fld1
fstpt (%rax)
leaq -0x270(%rbp), %rdi
leaq -0x288(%rbp), %rdx
callq 0x1f200
jmp 0x204f3
leaq -0x1f0(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x240f0
leaq -0x270(%rbp), %rdi
callq 0x24130
leaq -0x288(%rbp), %rdi
callq 0x6d30
jmp 0x20543
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x6d30
jmp 0x20774
leaq -0x1e0(%rbp), %rdi
leaq 0x59d97(%rip), %rsi     # 0x7a2e8
callq 0x5600
movb %al, -0x37d(%rbp)
jmp 0x2055e
movb -0x37d(%rbp), %al
testb $0x1, %al
jne 0x2056a
jmp 0x205e0
fldt -0x100(%rbp)
fldt -0x40(%rbp)
fldl 0x39227(%rip)           # 0x597a0
faddp %st, %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x205ab
jmp 0x20583
movq -0x2f8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x23d80
jmp 0x2059c
movl $0x1, -0x104(%rbp)
jmp 0x20724
movq -0x2f8(%rbp), %rdi
movl $0xffffffff, -0x28c(%rbp) # imm = 0xFFFFFFFF
leaq 0x59d25(%rip), %rdx     # 0x7a2e8
leaq -0x28c(%rbp), %rsi
callq 0x23d00
jmp 0x205d1
movl $0x1, -0x104(%rbp)
jmp 0x20724
leaq -0x190(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x23d40
movq %rax, -0x388(%rbp)
jmp 0x205fc
movq -0x388(%rbp), %rax
fldt (%rax)
fstpt -0x190(%rbp)
movslq -0x1b4(%rbp), %rsi
leaq -0x120(%rbp), %rdi
callq 0xbde0
movq %rax, -0x390(%rbp)
leaq -0x1e0(%rbp), %rsi
leaq -0x2c0(%rbp), %rdi
callq 0x56a0
jmp 0x2063a
movq -0x390(%rbp), %rsi
leaq -0x2a8(%rbp), %rdi
leaq -0x2c0(%rbp), %rdx
callq 0x16aa0
jmp 0x20656
leaq -0x1e0(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
leaq -0x2a8(%rbp), %rsi
movq %rsi, -0x3b0(%rbp)
callq 0x5790
movq -0x3b0(%rbp), %rdi
callq 0x5470
leaq -0x2c0(%rbp), %rdi
callq 0x5470
leaq -0x180(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0xc040
movq %rax, -0x2d0(%rbp)
leaq -0x2c8(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
callq 0xc070
movq -0x3a8(%rbp), %rdi
callq 0xc0b0
movq -0x3a8(%rbp), %rdi
movq %rax, -0x2d8(%rbp)
callq 0xc040
movq -0x3a0(%rbp), %rdi
movq %rax, -0x2e0(%rbp)
movq -0x2c8(%rbp), %rsi
movq -0x2d8(%rbp), %rdx
movq -0x2e0(%rbp), %rcx
callq 0xbf90
movq %rax, -0x398(%rbp)
jmp 0x2070c
movq -0x398(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movl $0x0, -0x104(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x24130
movl -0x104(%rbp), %eax
testl %eax, %eax
jne 0x207d9
jmp 0x20740
jmp 0x20742
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
jmp 0x2027f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x5470
leaq -0x1f0(%rbp), %rdi
callq 0x24130
jmp 0x207f3
fldt -0x190(%rbp)
fldt -0x40(%rbp)
fldl 0x3900f(%rip)           # 0x597a0
faddp %st, %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x2079d
jmp 0x2079b
jmp 0x207bc
leaq 0x39270(%rip), %rdi     # 0x59a14
leaq 0x39005(%rip), %rsi     # 0x597b0
movl $0xbd, %edx
leaq 0x391ea(%rip), %rcx     # 0x599a1
callq 0x31a0
movq -0x2f8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x24150
movl $0x1, -0x104(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x24130
leaq -0x120(%rbp), %rdi
callq 0xc120
jmp 0x2080d
leaq -0x190(%rbp), %rdi
callq 0x24130
leaq -0x120(%rbp), %rdi
callq 0xc120
jmp 0x20824
leaq -0xd8(%rbp), %rdi
callq 0x59e0
leaq -0x80(%rbp), %rdi
callq 0x57e0
jmp 0x2083b
leaq -0xd8(%rbp), %rdi
callq 0x59e0
leaq -0x80(%rbp), %rdi
callq 0x57e0
jmp 0x2084b
movq -0x2f0(%rbp), %rax
addq $0x3e0, %rsp            # imm = 0x3E0
popq %rbp
retq
movq -0xe0(%rbp), %rdi
callq 0x3480
nopw (%rax,%rax)