// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
movq %rcx, 0x18(%rsp)
movq %rsi, (%rsp)
decl %r8d
cmpl $0x5, %r8d
ja 0x1c5be
movq %rdx, %r15
movq %rdi, %r12
leaq 0x130(%rsp), %r14
leaq 0x100(%rsp), %rbx
leaq 0xe671(%rip), %rax      # 0x2a6a4
movslq (%rax,%r8,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
cmpl $0x2, %ecx
jl 0x1c074
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl $0x1, %edx
movl (%rax,%rdx,4), %esi
cmpl -0x4(%rax,%rdx,4), %esi
jle 0x1c4c6
incq %rdx
cmpq %rdx, %rcx
jne 0x1c05f
movq %r12, 0x10(%rsp)
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
movq %rcx, %rdx
shlq $0x1e, %rdx
movabsq $0x100000000, %rsi      # imm = 0x100000000
cmpq %rsi, %rdx
jl 0x1c47b
movl $0x1, %r13d
xorl %ebx, %ebx
xorl %r12d, %r12d
shrq $0x2, %rcx
leaq 0x1(%r12), %rdx
movq %r13, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
cmpl %ecx, %edx
jge 0x1c1b6
movl (%rax,%r12,4), %ebp
movl (%rax,%r13,4), %r14d
movq (%rsp), %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0x9ea6
testb %al, %al
jne 0x1c175
movq 0x18(%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 0x1c12f
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 %ebp, -0x4(%rdi)
cmovlq %rdi, %rsi
cmovgeq %r8, %r9
movq %r9, %rdi
testq %r9, %r9
jg 0x1c105
cmpq %rcx, %rsi
je 0x1c172
cmpl (%rsi), %ebp
jl 0x1c172
testq %rdx, %rdx
jle 0x1c168
movq %rdx, %rsi
shrq %rsi
movq %rsi, %rdi
notq %rdi
addq %rdx, %rdi
leaq (%rax,%rsi,4), %rdx
addq $0x4, %rdx
cmpl %r14d, -0x4(%rdx)
cmovlq %rdx, %rax
cmovgeq %rsi, %rdi
movq %rdi, %rdx
testq %rdi, %rdi
jg 0x1c13d
cmpq %rcx, %rax
je 0x1c172
cmpl (%rax), %r14d
jge 0x1c175
incq %rbx
movl $0x1, 0x40(%rsp)
movq %rbx, 0x20(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x1b4e8
testb %al, %al
jne 0x1c47d
incq %r13
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
cmpl %ecx, %r13d
jl 0x1c0c3
movq 0x60(%rsp), %r13
incq %r13
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
movq %rcx, %rdx
shrq $0x2, %rdx
movslq %edx, %rdx
movq 0x58(%rsp), %rsi
movq %rsi, %r12
cmpq %rdx, %rsi
jl 0x1c0a8
jmp 0x1c47d
movl $0x1, 0x20(%r12)
movq $0x0, (%r12)
jmp 0x1c4b1
cmpl $0x1, 0x20(%r14)
jne 0x1c4e5
movq 0x633890(%rip), %rcx    # 0x64faa0
movq 0x633881(%rip), %rax    # 0x64fa98
subq %rax, %rcx
shrq $0x3, %rcx
movq (%rsp), %rdx
cmpl %ecx, 0x50(%rdx)
jne 0x1c542
movq (%r15), %rcx
movq 0x8(%r15), %rsi
cmpq %rsi, %rcx
je 0x1c491
movq (%r14), %rdi
leaq 0x2(%rdi), %rdx
movq %rdx, 0x78(%rsp)
movl $0x1, %edx
fildll 0x78(%rsp)
movslq (%rcx), %r8
movq %rdx, 0x68(%rsp)
fildll 0x68(%rsp)
movq (%rax,%r8,8), %r8
movq %r8, 0x70(%rsp)
fildll 0x70(%rsp)
fmulp %st, %st(1)
fucompi %st(1), %st
ja 0x1c498
imulq %r8, %rdx
addq $0x4, %rcx
cmpq %rsi, %rcx
jne 0x1c250
jmp 0x1c4a2
cmpl $0x1, 0x20(%rbx)
jne 0x1c504
cmpl $0x1, 0x20(%r14)
jne 0x1c561
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x2, %rsi
leaq 0x20(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0xaa18
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
testl %ecx, %ecx
jle 0x1c2f1
movq 0x6337e0(%rip), %rdx    # 0x64fab0
movq 0x20(%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 0x1c2dd
leaq 0x98(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x42ce
movl (%rbx), %edx
movq (%r14), %r14
leaq 0xb0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
movl %r14d, %ecx
callq 0x22e22
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x1c33d
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
movq 0xb0(%rsp), %rdi
movq 0xb8(%rsp), %rax
subq %rdi, %rax
je 0x1c59f
sarq $0x2, %rax
incq %r14
cmpl $-0x1, (%rdi)
cmovneq %rax, %r14
movl $0x1, 0x20(%r12)
movq %r14, (%r12)
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x1c462
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x2, %rax
decq %rax
movl $0x1, 0x20(%r12)
movq %rax, (%r12)
jmp 0x1c4b1
cmpl $0x2, 0x20(%rbx)
jne 0x1c523
cmpl $0x2, 0x20(%r14)
jne 0x1c580
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x2, %rsi
leaq 0x20(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0xaa18
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
testl %ecx, %ecx
jle 0x1c412
movq 0x6336bf(%rip), %rdx    # 0x64fab0
movq 0x20(%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 0x1c3fe
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x42ce
leaq 0x80(%rsp), %rdi
callq 0x2392b
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1c454
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
fstpt (%rsp)
callq 0x2210
fldt (%rsp)
movl $0x2, 0x20(%r12)
fstpt 0x10(%r12)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1c4b1
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x1c4b1
xorl %ebx, %ebx
movq 0x10(%rsp), %r12
movl $0x1, 0x20(%r12)
movq %rbx, (%r12)
jmp 0x1c4b1
movl $0x1, %edx
jmp 0x1c4a0
fstp %st(0)
incq %rdi
movq %rdi, %rdx
fldz
fstp %st(0)
movl $0x1, 0x20(%r12)
movq %rdx, (%r12)
movq %r12, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe56c(%rip), %rdi      # 0x2aa39
leaq 0xe1f2(%rip), %rsi      # 0x2a6c6
leaq 0xe57c(%rip), %rcx      # 0x2aa57
movl $0x103, %edx            # imm = 0x103
callq 0x2140
leaq 0xe5d0(%rip), %rdi      # 0x2aabc
leaq 0xe1d3(%rip), %rsi      # 0x2a6c6
leaq 0xe55d(%rip), %rcx      # 0x2aa57
movl $0x115, %edx            # imm = 0x115
callq 0x2140
leaq 0xe5d5(%rip), %rdi      # 0x2aae0
leaq 0xe1b4(%rip), %rsi      # 0x2a6c6
leaq 0xe53e(%rip), %rcx      # 0x2aa57
movl $0x122, %edx            # imm = 0x122
callq 0x2140
leaq 0xe5d6(%rip), %rdi      # 0x2ab00
leaq 0xe195(%rip), %rsi      # 0x2a6c6
leaq 0xe51f(%rip), %rcx      # 0x2aa57
movl $0x12e, %edx            # imm = 0x12E
callq 0x2140
leaq 0xcea4(%rip), %rdi      # 0x293ed
leaq 0xe176(%rip), %rsi      # 0x2a6c6
leaq 0xe500(%rip), %rcx      # 0x2aa57
movl $0x116, %edx            # imm = 0x116
callq 0x2140
leaq 0xe554(%rip), %rdi      # 0x2aabc
leaq 0xe157(%rip), %rsi      # 0x2a6c6
leaq 0xe4e1(%rip), %rcx      # 0x2aa57
movl $0x123, %edx            # imm = 0x123
callq 0x2140
leaq 0xe59c(%rip), %rdi      # 0x2ab23
leaq 0xe138(%rip), %rsi      # 0x2a6c6
leaq 0xe4c2(%rip), %rcx      # 0x2aa57
movl $0x12f, %edx            # imm = 0x12F
callq 0x2140
leaq 0xd970(%rip), %rdi      # 0x29f16
leaq 0xe119(%rip), %rsi      # 0x2a6c6
leaq 0xe4a3(%rip), %rcx      # 0x2aa57
movl $0x129, %edx            # imm = 0x129
callq 0x2140
leaq 0xcbab(%rip), %rdi      # 0x29170
leaq 0xe0fa(%rip), %rsi      # 0x2a6c6
leaq 0xe484(%rip), %rcx      # 0x2aa57
movl $0x13b, %edx            # imm = 0x13B
callq 0x2140
fstp %st(0)
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1c620
movq 0x90(%rsp), %rsi
jmp 0x1c611
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x1c620
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x1c620
jmp 0x1c61d
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1c63e
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2210
jmp 0x1c63e
jmp 0x1c63b
movq %rax, %rbx
movq %rbx, %rdi
callq 0x2310