// File: /workspace/github_cpp_makefile_star2_O2/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 $0xb8, %rsp
movq %rsi, (%rsp)
decl %r8d
cmpl $0x5, %r8d
ja 0x15a67
movq %rcx, %r13
movq %rdx, %r15
movq %rdi, %r14
leaq 0x120(%rsp), %r12
leaq 0xf0(%rsp), %rbx
leaq 0xc0c2(%rip), %rax      # 0x216a4
movslq (%rax,%r8,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq (%r13), %rax
movq 0x8(%r13), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movslq %ecx, %rcx
pushq $0x1
popq %rdx
cmpq %rcx, %rdx
jge 0x15880
movl (%rax,%rdx,4), %esi
leaq 0x1(%rdx), %rdi
cmpl -0x4(%rax,%rdx,4), %esi
movq %rdi, %rdx
jg 0x15600
leaq 0xc419(%rip), %rdi      # 0x21a39
leaq 0xc09f(%rip), %rsi      # 0x216c6
leaq 0xc429(%rip), %rcx      # 0x21a57
movl $0x103, %edx            # imm = 0x103
callq 0x2150
movl $0x1, 0x20(%r14)
andq $0x0, (%r14)
jmp 0x15979
cmpl $0x1, 0x20(%r12)
jne 0x1598e
movq 0x635454(%rip), %rcx    # 0x64aab0
movq 0x635445(%rip), %rax    # 0x64aaa8
subq %rax, %rcx
shrq $0x3, %rcx
movq (%rsp), %rdx
cmpl %ecx, 0x50(%rdx)
jne 0x159eb
movq (%r15), %rsi
movq 0x8(%r15), %rdi
movq (%r12), %rdx
leaq 0x2(%rdx), %rcx
movq %rcx, 0x80(%rsp)
pushq $0x1
popq %rcx
fildll 0x80(%rsp)
cmpq %rdi, %rsi
je 0x15962
movslq (%rsi), %r8
movq %rcx, 0x70(%rsp)
fildll 0x70(%rsp)
movq (%rax,%r8,8), %r8
movq %r8, 0x78(%rsp)
fildll 0x78(%rsp)
fmulp %st, %st(1)
fucompi %st(1), %st
ja 0x15966
imulq %r8, %rcx
addq $0x4, %rsi
jmp 0x15698
cmpl $0x1, 0x20(%rbx)
jne 0x159ad
cmpl $0x1, 0x20(%r12)
jne 0x15a0a
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x2, %rsi
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x8852
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movq 0x6353ad(%rip), %rdx    # 0x64aac0
movq 0x30(%rsp), %rsi
xorl %edi, %edi
testl %ecx, %ecx
cmovlel %edi, %ecx
cmpq %rdi, %rcx
je 0x157c2
movslq (%rax,%rdi,4), %r8
movl (%rdx,%r8,4), %r8d
movl %r8d, (%rsi,%rdi,4)
incq %rdi
jmp 0x1571f
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x2, %rax
decq %rax
movl $0x1, 0x20(%r14)
movq %rax, (%r14)
jmp 0x15979
cmpl $0x2, 0x20(%rbx)
jne 0x159cc
cmpl $0x2, 0x20(%r12)
jne 0x15a29
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x2, %rsi
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x8852
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movq 0x635324(%rip), %rdx    # 0x64aac0
movq 0x30(%rsp), %rsi
xorl %edi, %edi
testl %ecx, %ecx
cmovlel %edi, %ecx
cmpq %rdi, %rcx
je 0x15833
movslq (%rax,%rdi,4), %r8
movl (%rdx,%r8,4), %r8d
movl %r8d, (%rsi,%rdi,4)
incq %rdi
jmp 0x157a8
leaq 0xa0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x3896
movl (%rbx), %edx
movq (%r12), %rbx
leaq 0x18(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
movl %ebx, %ecx
callq 0x1b195
leaq 0xa0(%rsp), %rdi
callq 0x38e4
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rax
subq %rcx, %rax
je 0x15a48
sarq $0x2, %rax
incq %rbx
cmpl $-0x1, (%rcx)
cmovneq %rax, %rbx
movl $0x1, 0x20(%r14)
movq %rbx, (%r14)
leaq 0x18(%rsp), %rdi
callq 0x38e4
jmp 0x15871
leaq 0x88(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x3896
leaq 0x88(%rsp), %rdi
callq 0x1b9c2
fstpt (%rsp)
leaq 0x88(%rsp), %rdi
callq 0x38e4
movl $0x2, 0x20(%r14)
fldt (%rsp)
fstpt 0x10(%r14)
leaq 0x30(%rsp), %rdi
callq 0x38e4
jmp 0x15979
movq %r14, 0x10(%rsp)
movq (%r15), %rax
movq 0x8(%r15), %rcx
pushq $0x1
popq %rbp
xorl %r14d, %r14d
xorl %ebx, %ebx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x2, %rdx
movslq %edx, %rdx
cmpq %rdx, %r14
jge 0x15950
leaq 0x1(%r14), %rdx
movq %rdx, 0x60(%rsp)
movq %rbp, 0x68(%rsp)
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x2, %rdx
cmpl %edx, %ebp
jge 0x1593e
movl (%rax,%r14,4), %esi
movl %esi, 0x18(%rsp)
movl (%rax,%rbp,4), %edx
movl %edx, 0xc(%rsp)
movq (%rsp), %rdi
callq 0x7f98
testb %al, %al
jne 0x15911
movq (%r13), %rdi
movq 0x8(%r13), %rsi
leaq 0x18(%rsp), %rdx
callq 0x1959c
testb %al, %al
je 0x1590e
movq (%r13), %rdi
movq 0x8(%r13), %rsi
leaq 0xc(%rsp), %rdx
callq 0x1959c
testb %al, %al
jne 0x15911
incq %rbx
movl $0x1, 0x50(%rsp)
movq %rbx, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x14c62
testb %al, %al
jne 0x15950
incq %rbp
movq (%r15), %rax
movq 0x8(%r15), %rcx
jmp 0x158b8
movq 0x68(%rsp), %rbp
incq %rbp
movq 0x60(%rsp), %r14
jmp 0x15894
movq 0x10(%rsp), %r14
movl $0x1, 0x20(%r14)
movq %rbx, (%r14)
jmp 0x15979
fstp %st(0)
jmp 0x1596e
fstp %st(0)
incq %rdx
movq %rdx, %rcx
movl $0x1, 0x20(%r14)
movq %rcx, (%r14)
movq %r14, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc127(%rip), %rdi      # 0x21abc
leaq 0xbd2a(%rip), %rsi      # 0x216c6
leaq 0xc0b4(%rip), %rcx      # 0x21a57
movl $0x115, %edx            # imm = 0x115
callq 0x2150
leaq 0xc12c(%rip), %rdi      # 0x21ae0
leaq 0xbd0b(%rip), %rsi      # 0x216c6
leaq 0xc095(%rip), %rcx      # 0x21a57
movl $0x122, %edx            # imm = 0x122
callq 0x2150
leaq 0xc12d(%rip), %rdi      # 0x21b00
leaq 0xbcec(%rip), %rsi      # 0x216c6
leaq 0xc076(%rip), %rcx      # 0x21a57
movl $0x12e, %edx            # imm = 0x12E
callq 0x2150
leaq 0xa9fb(%rip), %rdi      # 0x203ed
leaq 0xbccd(%rip), %rsi      # 0x216c6
leaq 0xc057(%rip), %rcx      # 0x21a57
movl $0x116, %edx            # imm = 0x116
callq 0x2150
leaq 0xc0ab(%rip), %rdi      # 0x21abc
leaq 0xbcae(%rip), %rsi      # 0x216c6
leaq 0xc038(%rip), %rcx      # 0x21a57
movl $0x123, %edx            # imm = 0x123
callq 0x2150
leaq 0xc0f3(%rip), %rdi      # 0x21b23
leaq 0xbc8f(%rip), %rsi      # 0x216c6
leaq 0xc019(%rip), %rcx      # 0x21a57
movl $0x12f, %edx            # imm = 0x12F
callq 0x2150
leaq 0xb4c7(%rip), %rdi      # 0x20f16
leaq 0xbc70(%rip), %rsi      # 0x216c6
leaq 0xbffa(%rip), %rcx      # 0x21a57
movl $0x129, %edx            # imm = 0x129
callq 0x2150
leaq 0xa702(%rip), %rdi      # 0x20170
leaq 0xbc51(%rip), %rsi      # 0x216c6
leaq 0xbfdb(%rip), %rcx      # 0x21a57
movl $0x13b, %edx            # imm = 0x13B
callq 0x2150
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x15a9e
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x38e4
jmp 0x15aaa
jmp 0x15aa7
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x38e4
jmp 0x15abb
jmp 0x15ab8
movq %rax, %rbx
movq %rbx, %rdi
callq 0x2340