// File: /workspace/github_cpp_makefile_star2_O1/Laakeri[P]Triangulator/src/PMC.cpp
// Function: PMC::cliqueCost(Graph const&, std::vector<int, std::allocator<int>> const&, std::vector<int, std::allocator<int>> const&, int, PMC::valueT, PMC::valueT)
valueT cliqueCost(const Graph& G, const vector<int>& pmc, const vector<int>& parentSep, int PROBLEM, valueT okCost, valueT upperBound) {
	if (PROBLEM == PROBLEM_TREEWIDTH) return (int64_t)pmc.size()-1;
	else if (PROBLEM == PROBLEM_MINFILL) {
		for (int j = 1; j < (int)parentSep.size(); j++) {
			assert(parentSep[j] > parentSep[j-1]); // just assert
		}
		int64_t cost = 0;
		for (int i = 0; i < (int)pmc.size(); i++) {
			for (int ii = i+1; ii < (int)pmc.size(); ii++) {
				int a = pmc[i];
				int b = pmc[ii];
				if (!G.hasEdge(a, b)) {
					if (!binary_search(parentSep.begin(), parentSep.end(), a) || !binary_search(parentSep.begin(), parentSep.end(), b)) {
						cost++;
					}
				}
				if (valueT(cost) > upperBound) return cost;
			}
		}
		return cost;
	}
	else if (PROBLEM == PROBLEM_BAYES) {
		assert(upperBound.TYPE == valueT::TYPE_INT);
		assert((int)tableSizes.size() == G.n);
		int64_t ts = 1;
		for (int x : pmc) {
			if ((long double)ts*(long double)tableSizes[x] > (long double)(upperBound.valInt+2)) {
				ts = upperBound.valInt+1;
				break;
			}
			ts *= tableSizes[x];
		}
		return ts;
	}
	else if (PROBLEM == PROBLEM_HYPER) {
		assert(okCost.TYPE == valueT::TYPE_INT);
		assert(upperBound.TYPE == valueT::TYPE_INT);
		vector<int> ppmc(pmc.size());
		for (int i = 0; i < (int)pmc.size(); i++) {
			ppmc[i] = vertMap[pmc[i]];
		}
		auto setCoverSol = SetCover::solve(ppmc, okCost.valInt, upperBound.valInt);
		assert(setCoverSol.size() > 0);
		if (setCoverSol[0] == -1) return (int64_t)(upperBound.valInt + 1);
		return (int64_t)setCoverSol.size();
	}
	else if (PROBLEM == PROBLEM_FRACHYPER) {
		assert(okCost.TYPE == valueT::TYPE_DOUBLE);
		assert(upperBound.TYPE == valueT::TYPE_DOUBLE);
		vector<int> ppmc(pmc.size());
		for (int i = 0; i < (int)pmc.size(); i++) {
			ppmc[i] = vertMap[pmc[i]];
		}
		ld setCoverSol = SetCover::solveFrac(ppmc);
		return setCoverSol;
	}
	else if (PROBLEM == PROBLEM_DECIDE) {
		return (int64_t)0;
	}
	else {
		assert(0);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rcx, 0x30(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, (%rsp)
decl %r8d
cmpl $0x5, %r8d
ja 0x1c4f2
movq %rdx, %rbp
leaq 0x140(%rsp), %r12
leaq 0x110(%rsp), %rbx
leaq 0xf78b(%rip), %rax      # 0x2b694
movslq (%rax,%r8,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x30(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
cmpl $0x2, %ecx
jl 0x1bf4a
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl $0x1, %edx
movl (%rax,%rdx,4), %esi
cmpl -0x4(%rax,%rdx,4), %esi
jle 0x1c3fa
incq %rdx
cmpq %rdx, %rcx
jne 0x1bf35
movq (%rsp), %rax
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movl $0x1, %r12d
xorl %ecx, %ecx
xorl %r15d, %r15d
movq 0x8(%rbp), %rax
subq (%rbp), %rax
movq %rcx, %rdx
shrq $0x2, %rax
cltq
movq %rax, 0x70(%rsp)
cmpq %rax, %rcx
jge 0x1c0db
leaq 0x1(%rdx), %rsi
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movq %r12, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
cmpl %ecx, %esi
setl %r13b
movq %rdx, 0x18(%rsp)
jge 0x1c0a8
movl (%rax,%rdx,4), %r14d
movl (%rax,%r12,4), %ebx
movq 0x38(%rsp), %rdi
movl %r14d, %esi
movl %ebx, %edx
callq 0x9b60
testb %al, %al
jne 0x1c061
movq 0x30(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movq %rax, %rsi
testq %rdx, %rdx
jle 0x1c01c
movq %rdx, %rdi
movq %rax, %rsi
movq %rdi, %r8
shrq %r8
movq %r8, %r9
notq %r9
addq %rdi, %r9
leaq (%rsi,%r8,4), %rdi
addq $0x4, %rdi
cmpl %r14d, -0x4(%rdi)
cmovlq %rdi, %rsi
cmovgeq %r8, %r9
movq %r9, %rdi
testq %r9, %r9
jg 0x1bff1
cmpq %rcx, %rsi
je 0x1c05e
cmpl (%rsi), %r14d
jl 0x1c05e
testq %rdx, %rdx
jle 0x1c055
movq %rdx, %rsi
shrq %rsi
movq %rsi, %rdi
notq %rdi
addq %rdx, %rdi
leaq (%rax,%rsi,4), %rdx
addq $0x4, %rdx
cmpl %ebx, -0x4(%rdx)
cmovlq %rdx, %rax
cmovgeq %rsi, %rdi
movq %rdi, %rdx
testq %rdi, %rdi
jg 0x1c02b
cmpq %rcx, %rax
je 0x1c05e
cmpl (%rax), %ebx
jge 0x1c061
incq %r15
movl $0x1, 0x60(%rsp)
movq %r15, 0x40(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x1b3b0
testb %al, %al
jne 0x1c0af
incq %r12
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
cmpl %ecx, %r12d
setl %r13b
movq 0x18(%rsp), %rdx
jl 0x1bfae
movq 0x10(%rsp), %r12
jmp 0x1c0c9
movq (%rsp), %rax
movl $0x1, 0x20(%rax)
movq %r15, 0x28(%rsp)
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rcx
incq %r12
testb $0x1, %r13b
je 0x1bf61
movq (%rsp), %r14
movq 0x28(%rsp), %rax
movq %rax, (%r14)
cmpq 0x70(%rsp), %rdx
jl 0x1c3e5
movl $0x1, 0x20(%r14)
movq %r15, (%r14)
jmp 0x1c3e5
movq (%rsp), %r14
movl $0x1, 0x20(%r14)
movq $0x0, (%r14)
jmp 0x1c3e5
cmpl $0x1, 0x20(%r12)
jne 0x1c419
movq 0x634973(%rip), %rcx    # 0x650aa0
movq 0x634964(%rip), %rax    # 0x650a98
subq %rax, %rcx
shrq $0x3, %rcx
movq 0x38(%rsp), %rdx
cmpl %ecx, 0x50(%rdx)
jne 0x1c476
movq (%rbp), %rdx
movq 0x8(%rbp), %rcx
cmpq %rcx, %rdx
je 0x1c3c9
movq (%r12), %rdi
leaq 0x2(%rdi), %rsi
movq %rsi, 0x88(%rsp)
fildll 0x88(%rsp)
incq %rdi
addq $0x4, %rdx
movl $0x1, %esi
movq (%rsp), %r14
movslq -0x4(%rdx), %r8
movq %rsi, 0x78(%rsp)
fildll 0x78(%rsp)
movq (%rax,%r8,8), %r8
movq %r8, 0x80(%rsp)
fildll 0x80(%rsp)
fmulp %st, %st(1)
imulq %r8, %rsi
fucompi %st(1), %st
cmovaq %rdi, %rsi
ja 0x1c3d4
leaq 0x4(%rdx), %r8
cmpq %rcx, %rdx
movq %r8, %rdx
jne 0x1c181
jmp 0x1c3d8
cmpl $0x1, 0x20(%rbx)
jne 0x1c438
cmpl $0x1, 0x20(%r12)
jne 0x1c495
movq 0x8(%rbp), %rsi
subq (%rbp), %rsi
sarq $0x2, %rsi
leaq 0x40(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0xa6ba
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
testl %ecx, %ecx
jle 0x1c233
movq 0x63489e(%rip), %rdx    # 0x650ab0
movq 0x40(%rsp), %rsi
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edi, %edi
movslq (%rax,%rdi,4), %r8
movl (%rdx,%r8,4), %r8d
movl %r8d, (%rsi,%rdi,4)
incq %rdi
cmpq %rdi, %rcx
jne 0x1c21f
leaq 0xa8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x431c
movq (%rsp), %r14
movl (%rbx), %edx
movq (%r12), %rbx
leaq 0xc0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movl %ebx, %ecx
callq 0x22f21
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x1c283
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0xc0(%rsp), %rdi
movq 0xc8(%rsp), %rax
subq %rdi, %rax
je 0x1c4d3
sarq $0x2, %rax
incq %rbx
cmpl $-0x1, (%rdi)
cmovneq %rax, %rbx
movl $0x1, 0x20(%r14)
movq %rbx, (%r14)
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x1c3b0
movq 0x8(%rbp), %rax
subq (%rbp), %rax
sarq $0x2, %rax
decq %rax
movq (%rsp), %r14
movl $0x1, 0x20(%r14)
movq %rax, (%r14)
jmp 0x1c3e5
cmpl $0x2, 0x20(%rbx)
jne 0x1c457
cmpl $0x2, 0x20(%r12)
jne 0x1c4b4
movq 0x8(%rbp), %rsi
subq (%rbp), %rsi
sarq $0x2, %rsi
leaq 0x40(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0xa6ba
movq (%rbp), %rax
movq 0x8(%rbp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
testl %ecx, %ecx
jle 0x1c35c
movq 0x634775(%rip), %rdx    # 0x650ab0
movq 0x40(%rsp), %rsi
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edi, %edi
movslq (%rax,%rdi,4), %r8
movl (%rdx,%r8,4), %r8d
movl %r8d, (%rsi,%rdi,4)
incq %rdi
cmpq %rdi, %rcx
jne 0x1c348
leaq 0x90(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x431c
movq (%rsp), %r14
leaq 0x90(%rsp), %rdi
callq 0x2398f
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x1c3a4
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
fstpt 0x18(%rsp)
callq 0x2210
fldt 0x18(%rsp)
movl $0x2, 0x20(%r14)
fstpt 0x10(%r14)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1c3e5
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x1c3e5
movl $0x1, %esi
movq (%rsp), %r14
jmp 0x1c3d6
fstp %st(0)
fldz
fstp %st(0)
movl $0x1, 0x20(%r14)
movq %rsi, (%r14)
movq %r14, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf628(%rip), %rdi      # 0x2ba29
leaq 0xf2ae(%rip), %rsi      # 0x2b6b6
leaq 0xf638(%rip), %rcx      # 0x2ba47
movl $0x103, %edx            # imm = 0x103
callq 0x2140
leaq 0xf68c(%rip), %rdi      # 0x2baac
leaq 0xf28f(%rip), %rsi      # 0x2b6b6
leaq 0xf619(%rip), %rcx      # 0x2ba47
movl $0x115, %edx            # imm = 0x115
callq 0x2140
leaq 0xf691(%rip), %rdi      # 0x2bad0
leaq 0xf270(%rip), %rsi      # 0x2b6b6
leaq 0xf5fa(%rip), %rcx      # 0x2ba47
movl $0x122, %edx            # imm = 0x122
callq 0x2140
leaq 0xf692(%rip), %rdi      # 0x2baf0
leaq 0xf251(%rip), %rsi      # 0x2b6b6
leaq 0xf5db(%rip), %rcx      # 0x2ba47
movl $0x12e, %edx            # imm = 0x12E
callq 0x2140
leaq 0xdf60(%rip), %rdi      # 0x2a3dd
leaq 0xf232(%rip), %rsi      # 0x2b6b6
leaq 0xf5bc(%rip), %rcx      # 0x2ba47
movl $0x116, %edx            # imm = 0x116
callq 0x2140
leaq 0xf610(%rip), %rdi      # 0x2baac
leaq 0xf213(%rip), %rsi      # 0x2b6b6
leaq 0xf59d(%rip), %rcx      # 0x2ba47
movl $0x123, %edx            # imm = 0x123
callq 0x2140
leaq 0xf658(%rip), %rdi      # 0x2bb13
leaq 0xf1f4(%rip), %rsi      # 0x2b6b6
leaq 0xf57e(%rip), %rcx      # 0x2ba47
movl $0x12f, %edx            # imm = 0x12F
callq 0x2140
leaq 0xea2c(%rip), %rdi      # 0x2af06
leaq 0xf1d5(%rip), %rsi      # 0x2b6b6
leaq 0xf55f(%rip), %rcx      # 0x2ba47
movl $0x129, %edx            # imm = 0x129
callq 0x2140
leaq 0xdc93(%rip), %rdi      # 0x2a18c
leaq 0xf1b6(%rip), %rsi      # 0x2b6b6
leaq 0xf540(%rip), %rcx      # 0x2ba47
movl $0x13b, %edx            # imm = 0x13B
callq 0x2140
fstp %st(0)
movq %rax, %rbx
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x1c554
movq 0xa0(%rsp), %rsi
jmp 0x1c545
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x1c554
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x1c554
jmp 0x1c551
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1c572
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x1c572
jmp 0x1c56f
movq %rax, %rbx
movq %rbx, %rdi
callq 0x2310