// File: /workspace/github_cpp_makefile_star2_O3/Laakeri[P]Triangulator/src/bayes.cpp
// Function: Bayes::SolveAtom::solveAtom(Graph const&, long, long, std::vector<long, std::allocator<long>>)
pair<int64_t, vector<pair<int, int> > > solveAtom(const Graph& G, int64_t lowerBound, int64_t upperBound, vector<int64_t> tableSizes) {
	auto fill = MCS::MCS_MP(G);
	
	if (fill.F.size() <= 0) {
		Graph gFill = G;
		gFill.addEdges(fill.F);
		int64_t fillWidth = MCS::getBayesWidth(gFill, tableSizes);
		assert(fillWidth >= lowerBound);
		if (fillWidth > upperBound) return {-1, FAILSOLUTION};
		return {fillWidth, fill.F};
	}
	
	PMC::initTableSz(tableSizes);
	auto fillO = PMC::solve(G, lowerBound, upperBound, PROBLEM_BAYES);
	if (fillO == FAILSOLUTION) return {-1, FAILSOLUTION};
	Graph gFillO = G;
	gFillO.addEdges(fillO);
	int width = MCS::getBayesWidth(gFillO, tableSizes);
	assert(width >= lowerBound);
	assert(width <= upperBound);
	return {width, fillO};
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %r8, %r12
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %rbx
leaq 0xf0(%rsp), %rbp
movq %rbp, %rdi
callq 0x12cbc
movq 0x8(%rbp), %rax
cmpq (%rbp), %rax
je 0x4860
leaq 0xd8(%rsp), %rdi
movq %r12, %rsi
callq 0x69d4
leaq 0xd8(%rsp), %rdi
callq 0x1b3df
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x46c4
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
leaq 0x150(%rsp), %rdi
movq %r15, %rsi
callq 0x1b3f6
leaq 0x120(%rsp), %rdi
movq %r14, %rsi
callq 0x1b3f6
movaps 0x120(%rsp), %xmm0
movaps 0x130(%rsp), %xmm1
movaps 0x140(%rsp), %xmm2
movaps %xmm2, 0x50(%rsp)
movaps %xmm1, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movapd 0x150(%rsp), %xmm0
movdqa 0x160(%rsp), %xmm1
movaps 0x170(%rsp), %xmm2
movaps %xmm2, 0x20(%rsp)
movdqa %xmm1, 0x10(%rsp)
movapd %xmm0, (%rsp)
leaq 0x68(%rsp), %rdi
movq %r13, %rsi
movl $0x3, %edx
callq 0x20611
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
movq %rcx, %rsi
subq %rax, %rsi
movq 0x30a92(%rip), %rdi     # 0x351f0
movq 0x30a83(%rip), %rdx     # 0x351e8
subq %rdx, %rdi
cmpq %rdi, %rsi
jne 0x479a
cmpq %rcx, %rax
je 0x48f0
movq (%rax), %xmm0
movq (%rdx), %xmm1
pcmpeqd %xmm0, %xmm1
pshufd $0x50, %xmm1, %xmm0     # xmm0 = xmm1[0,0,1,1]
movmskpd %xmm0, %esi
cmpl $0x3, %esi
jne 0x479a
addq $0x8, %rax
addq $0x8, %rdx
jmp 0x476d
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0x42ce
leaq 0x98(%rsp), %rdi
leaq 0x18(%r13), %rsi
callq 0x815a
movb 0x30(%r13), %al
leaq 0xb8(%rsp), %rbp
movb %al, -0x8(%rbp)
leaq 0x38(%r13), %rsi
movq %rbp, %rdi
callq 0x4110
movq 0x50(%r13), %rax
leaq 0x80(%rsp), %rdi
movq %rax, 0x50(%rdi)
leaq 0x68(%rsp), %rsi
callq 0x9bd8
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x13cbb
cltq
cmpq %r15, %rax
jl 0x49a9
cmpq %r14, %rax
jg 0x49c8
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3f7c
movq %rbp, %rdi
callq 0x41aa
leaq 0x98(%rsp), %rdi
callq 0x436a
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x4907
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x4907
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0x42ce
leaq 0x98(%rsp), %rdi
leaq 0x18(%r13), %rsi
callq 0x815a
movb 0x30(%r13), %al
leaq 0xb8(%rsp), %rbp
movb %al, -0x8(%rbp)
leaq 0x38(%r13), %rsi
movq %rbp, %rdi
callq 0x4110
movq 0x50(%r13), %rax
leaq 0x80(%rsp), %rdi
movq %rax, 0x50(%rdi)
leaq 0xf0(%rsp), %rsi
callq 0x9bd8
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x13cbb
cmpq %r15, %rax
jl 0x49e7
leaq 0x8(%rbx), %rdi
cmpq %r14, %rax
jle 0x4918
movq $-0x1, (%rbx)
leaq 0x308ff(%rip), %rsi     # 0x351e8
callq 0x3f7c
jmp 0x4928
movq $-0x1, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x308e6(%rip), %rsi     # 0x351e8
callq 0x3f7c
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x495a
movq 0x78(%rsp), %rsi
jmp 0x4952
movq %rax, (%rbx)
leaq 0xf0(%rsp), %rsi
callq 0x3f7c
movq %rbp, %rdi
callq 0x41aa
leaq 0x98(%rsp), %rdi
callq 0x436a
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x495a
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x4977
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x4994
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq %rbx, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x24976(%rip), %rdi     # 0x29326
leaq 0x248f1(%rip), %rsi     # 0x292a8
leaq 0x248f4(%rip), %rcx     # 0x292b2
movl $0x29, %edx
callq 0x2140
leaq 0x2496b(%rip), %rdi     # 0x2933a
leaq 0x248d2(%rip), %rsi     # 0x292a8
leaq 0x248d5(%rip), %rcx     # 0x292b2
movl $0x2a, %edx
callq 0x2140
leaq 0x248a2(%rip), %rdi     # 0x29290
leaq 0x248b3(%rip), %rsi     # 0x292a8
leaq 0x248b6(%rip), %rcx     # 0x292b2
movl $0x1e, %edx
callq 0x2140
jmp 0x4a7f
jmp 0x4a7a
jmp 0x4a7f
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x436a
jmp 0x4a21
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x4ad9
movq 0x90(%rsp), %rsi
jmp 0x4acc
jmp 0x4ad6
jmp 0x4aad
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x436a
jmp 0x4a5b
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x4abd
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x4abd
movq %rax, %rbx
jmp 0x4abd
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x40d8
jmp 0x4ad9
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x4ad9
movq 0xe8(%rsp), %rsi
jmp 0x4acc
jmp 0x4ad6
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x40d8
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x4ad9
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x4ad9
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x3ff2
movq %rbx, %rdi
callq 0x2310