// File: 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
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x1d8(%rbp)
movq %rdi, %rax
movq %rax, -0x1d0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq %r9, -0x28(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x1ed6a
jmp 0x1ed89
leaq 0x3a5b1(%rip), %rdi     # 0x59322
leaq 0x3aa38(%rip), %rsi     # 0x597b0
movl $0x1e, %edx
leaq 0x3aa36(%rip), %rcx     # 0x597ba
callq 0x31a0
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1ed93
jmp 0x1edb2
leaq 0x3aa91(%rip), %rdi     # 0x5982b
leaq 0x3aa0f(%rip), %rsi     # 0x597b0
movl $0x1f, %edx
leaq 0x3aa0d(%rip), %rcx     # 0x597ba
callq 0x31a0
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x1eddd
movq -0x1d8(%rbp), %rdi
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
leaq -0x2c(%rbp), %rsi
leaq 0x5b515(%rip), %rdx     # 0x7a2e8
callq 0x23c40
jmp 0x1f1d6
leaq -0x18(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x23c80
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x28a90
movq -0x10(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0xb8b0
jmp 0x1ee0e
leaq -0xb8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x15db0
jmp 0x1ee20
movq -0x28(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x2ace0
movl %eax, -0x1dc(%rbp)
jmp 0x1ee38
movl -0x1dc(%rbp), %eax
movl %eax, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x1ee51
jmp 0x1ee9e
leaq 0x3a40c(%rip), %rdi     # 0x59264
leaq 0x3a951(%rip), %rsi     # 0x597b0
movl $0x2a, %edx
leaq 0x3a94f(%rip), %rcx     # 0x597ba
callq 0x31a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x1f1cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x1f1bf
movl -0xc8(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0x1eed1
movq -0x1d8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x23cc0
jmp 0x1eec2
movl $0x1, -0xcc(%rbp)
jmp 0x1f1a8
leaq -0x60(%rbp), %rdi
callq 0x5680
cmpq $0x0, %rax
jne 0x1ef48
movl -0xc8(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1ef13
movq -0x1d8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x23cc0
jmp 0x1ef04
movl $0x1, -0xcc(%rbp)
jmp 0x1f1a8
movq -0x1d8(%rbp), %rdi
movl $0xffffffff, -0xd0(%rbp) # imm = 0xFFFFFFFF
leaq 0x5b3bd(%rip), %rdx     # 0x7a2e8
leaq -0xd0(%rbp), %rsi
callq 0x23c40
jmp 0x1ef39
movl $0x1, -0xcc(%rbp)
jmp 0x1f1a8
movq -0x28(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x6490
jmp 0x1ef5a
leaq -0xe8(%rbp), %rdi
callq 0x3a070
jmp 0x1ef68
leaq -0xe8(%rbp), %rdi
callq 0x6d30
movq -0x10(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movslq -0x14(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x3a0f0
jmp 0x1ef91
movslq -0x1c(%rbp), %rsi
leaq -0x160(%rbp), %rdi
callq 0x3a0f0
jmp 0x1efa3
movq -0x1e8(%rbp), %rsi
movaps -0x160(%rbp), %xmm0
movaps -0x150(%rbp), %xmm1
movaps -0x140(%rbp), %xmm2
movq %rsp, %rax
movaps %xmm2, 0x50(%rax)
movaps %xmm1, 0x40(%rax)
movaps %xmm0, 0x30(%rax)
movaps -0x130(%rbp), %xmm0
movaps -0x120(%rbp), %xmm1
movaps -0x110(%rbp), %xmm2
movaps %xmm2, 0x20(%rax)
movaps %xmm1, 0x10(%rax)
movaps %xmm0, (%rax)
leaq -0x100(%rbp), %rdi
movl $0x4, %edx
callq 0x41440
jmp 0x1f001
leaq 0x5b2e0(%rip), %rsi     # 0x7a2e8
leaq -0x100(%rbp), %rdi
callq 0x5600
movb %al, -0x1e9(%rbp)
jmp 0x1f01c
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0x1f028
jmp 0x1f097
movq -0x1d8(%rbp), %rdi
movl $0xffffffff, -0x164(%rbp) # imm = 0xFFFFFFFF
leaq 0x5b2a8(%rip), %rdx     # 0x7a2e8
leaq -0x164(%rbp), %rsi
callq 0x23c40
jmp 0x1f04e
movl $0x1, -0xcc(%rbp)
jmp 0x1f18c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x6d30
jmp 0x1f1bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x1f19a
movq -0x10(%rbp), %rsi
leaq -0x1c0(%rbp), %rdi
callq 0xb8b0
jmp 0x1f0a9
leaq -0x1c0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x15db0
jmp 0x1f0be
movq -0x28(%rbp), %rsi
leaq -0x1c0(%rbp), %rdi
callq 0x2ace0
movl %eax, -0x1f0(%rbp)
jmp 0x1f0d6
movl -0x1f0(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movl -0x1c4(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x1f0ef
jmp 0x1f12e
leaq 0x3a204(%rip), %rdi     # 0x592fa
leaq 0x3a6b3(%rip), %rsi     # 0x597b0
movl $0x39, %edx
leaq 0x3a6b1(%rip), %rcx     # 0x597ba
callq 0x31a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x59e0
jmp 0x1f19a
movl -0x1c4(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x1f13b
jmp 0x1f15a
leaq 0x3a1cc(%rip), %rdi     # 0x5930e
leaq 0x3a667(%rip), %rsi     # 0x597b0
movl $0x3a, %edx
leaq 0x3a665(%rip), %rcx     # 0x597ba
callq 0x31a0
movq -0x1d8(%rbp), %rdi
leaq -0x1c4(%rbp), %rsi
leaq -0x100(%rbp), %rdx
callq 0x23cc0
jmp 0x1f176
movl $0x1, -0xcc(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x59e0
leaq -0x100(%rbp), %rdi
callq 0x5470
jmp 0x1f1a8
leaq -0x100(%rbp), %rdi
callq 0x5470
jmp 0x1f1bf
leaq -0xb8(%rbp), %rdi
callq 0x59e0
leaq -0x60(%rbp), %rdi
callq 0x57e0
jmp 0x1f1d6
leaq -0xb8(%rbp), %rdi
callq 0x59e0
leaq -0x60(%rbp), %rdi
callq 0x57e0
jmp 0x1f1e6
movq -0x1d0(%rbp), %rax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
movq -0xc0(%rbp), %rdi
callq 0x3480
nopw %cs:(%rax,%rax)