// File: 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
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x1a0(%rbp)
movq %rdi, -0x198(%rbp)
leaq 0x40(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x188(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
jne 0x3b556
movq -0x10(%rbp), %rdi
callq 0x59a0
movq -0x1a0(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x3a0f0
jmp 0x3be02
cmpl $0x1, -0x1c(%rbp)
jne 0x3b761
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x1a4(%rbp)
movq -0x18(%rbp), %rdi
callq 0x59a0
movq %rax, %rcx
movl -0x1a4(%rbp), %eax
cmpl %ecx, %eax
jge 0x3b5eb
movq -0x18(%rbp), %rdi
movslq -0x20(%rbp), %rsi
callq 0x17a50
movl (%rax), %eax
movl %eax, -0x1a8(%rbp)
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x17a50
movq %rax, %rcx
movl -0x1a8(%rbp), %eax
cmpl (%rcx), %eax
jle 0x3b5bc
jmp 0x3b5db
leaq 0x1f426(%rip), %rdi     # 0x5a9e9
leaq 0x1f0ac(%rip), %rsi     # 0x5a676
movl $0x103, %edx            # imm = 0x103
leaq 0x1f431(%rip), %rcx     # 0x5aa07
callq 0x31a0
jmp 0x3b5dd
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3b567
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x1ac(%rbp)
movq -0x10(%rbp), %rdi
callq 0x59a0
movq %rax, %rcx
movl -0x1ac(%rbp), %eax
cmpl %ecx, %eax
jge 0x3b74c
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x1b0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x59a0
movq %rax, %rcx
movl -0x1b0(%rbp), %eax
cmpl %ecx, %eax
jge 0x3b73c
movq -0x10(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0x17a50
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x17a50
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
movl -0x38(%rbp), %edx
callq 0x16400
testb $0x1, %al
jne 0x3b6ee
movq -0x18(%rbp), %rdi
callq 0x6680
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x66b0
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq -0x34(%rbp), %rdx
callq 0x43410
testb $0x1, %al
jne 0x3b6b1
jmp 0x3b6e0
movq -0x18(%rbp), %rdi
callq 0x6680
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
callq 0x66b0
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x43410
testb $0x1, %al
jne 0x3b6ec
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x3b6ee
movq -0x28(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x3a0f0
movq -0x190(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x3a2c0
testb $0x1, %al
jne 0x3b717
jmp 0x3b72c
movq -0x1a0(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3a0f0
jmp 0x3be02
jmp 0x3b72e
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3b626
jmp 0x3b73e
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3b5fa
movq -0x1a0(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3a0f0
jmp 0x3be02
cmpl $0x3, -0x1c(%rbp)
jne 0x3b90d
movq -0x190(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0x3b77a
jmp 0x3b799
leaq 0x1f2eb(%rip), %rdi     # 0x5aa6c
leaq 0x1eeee(%rip), %rsi     # 0x5a676
movl $0x115, %edx            # imm = 0x115
leaq 0x1f273(%rip), %rcx     # 0x5aa07
callq 0x31a0
leaq 0x6593d8(%rip), %rdi    # 0x694b78
callq 0xbb80
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jne 0x3b7b0
jmp 0x3b7cf
leaq 0x1dc0a(%rip), %rdi     # 0x593c1
leaq 0x1eeb8(%rip), %rsi     # 0x5a676
movl $0x116, %edx            # imm = 0x116
leaq 0x1f23d(%rip), %rcx     # 0x5aa07
callq 0x31a0
movq $0x1, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x6680
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x66b0
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xbbc0
testb $0x1, %al
jne 0x3b827
jmp 0x3b8f5
leaq -0xa8(%rbp), %rdi
callq 0xbc00
movl (%rax), %eax
movl %eax, -0xb4(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x180(%rbp)
fildll -0x180(%rbp)
fstpt -0x1bc(%rbp)
movslq -0xb4(%rbp), %rsi
leaq 0x659315(%rip), %rdi    # 0x694b78
callq 0xbc60
fldt -0x1bc(%rbp)
movq %rax, %rcx
movq -0x190(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x178(%rbp)
fildll -0x178(%rbp)
fmulp %st, %st(1)
movq (%rax), %rax
addq $0x2, %rax
movq %rax, -0x170(%rbp)
fildll -0x170(%rbp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x3b8bf
jmp 0x3b8a8
movq -0x190(%rbp), %rax
movq (%rax), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x3b8f5
movslq -0xb4(%rbp), %rsi
leaq 0x6592ab(%rip), %rdi    # 0x694b78
callq 0xbc60
movq (%rax), %rax
imulq -0x98(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xbc80
jmp 0x3b80b
movq -0x1a0(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x3a0f0
jmp 0x3be02
cmpl $0x4, -0x1c(%rbp)
jne 0x3bbc6
movq -0x188(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0x3b926
jmp 0x3b945
leaq 0x1f163(%rip), %rdi     # 0x5aa90
leaq 0x1ed42(%rip), %rsi     # 0x5a676
movl $0x122, %edx            # imm = 0x122
leaq 0x1f0c7(%rip), %rcx     # 0x5aa07
callq 0x31a0
movq -0x190(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0x3b954
jmp 0x3b973
leaq 0x1f111(%rip), %rdi     # 0x5aa6c
leaq 0x1ed14(%rip), %rsi     # 0x5a676
movl $0x123, %edx            # imm = 0x123
leaq 0x1f099(%rip), %rcx     # 0x5aa07
callq 0x31a0
movq -0x10(%rbp), %rdi
callq 0x59a0
movq %rax, -0x1d0(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x111b0
movq -0x1d0(%rbp), %rsi
movq -0x1c8(%rbp), %rdx
leaq -0xd0(%rbp), %rdi
callq 0x17ab0
jmp 0x3b9b2
leaq -0xd1(%rbp), %rdi
callq 0x6620
movl $0x0, -0xe8(%rbp)
movl -0xe8(%rbp), %eax
movl %eax, -0x1d4(%rbp)
movq -0x10(%rbp), %rdi
callq 0x59a0
movq %rax, %rcx
movl -0x1d4(%rbp), %eax
cmpl %ecx, %eax
jge 0x3ba60
movq -0x10(%rbp), %rdi
movslq -0xe8(%rbp), %rsi
callq 0x17a50
movslq (%rax), %rsi
leaq 0x65918c(%rip), %rdi    # 0x694b90
callq 0x178f0
movl (%rax), %eax
movl %eax, -0x1d8(%rbp)
movslq -0xe8(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x178f0
movl -0x1d8(%rbp), %ecx
movl %ecx, (%rax)
movl -0xe8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe8(%rbp)
jmp 0x3b9c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0xd1(%rbp), %rdi
callq 0x6620
jmp 0x3be12
leaq -0x118(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x6490
jmp 0x3ba75
movq -0x190(%rbp), %rax
movq -0x188(%rbp), %rcx
movl (%rcx), %edx
movl (%rax), %ecx
leaq -0x100(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x4b820
jmp 0x3ba9c
leaq -0x118(%rbp), %rdi
callq 0x6d30
leaq -0x100(%rbp), %rdi
callq 0x59a0
cmpq $0x0, %rax
jbe 0x3babc
jmp 0x3bb15
leaq 0x1e423(%rip), %rdi     # 0x59ee6
leaq 0x1ebac(%rip), %rsi     # 0x5a676
movl $0x129, %edx            # imm = 0x129
leaq 0x1ef31(%rip), %rcx     # 0x5aa07
callq 0x31a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x3bbb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x6d30
jmp 0x3bbb5
leaq -0x100(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x178f0
cmpl $-0x1, (%rax)
jne 0x3bb71
movq -0x1a0(%rbp), %rdi
movq -0x190(%rbp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x3a0f0
jmp 0x3bb45
movl $0x1, -0x11c(%rbp)
jmp 0x3bb98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x6d30
jmp 0x3bbb5
leaq -0x100(%rbp), %rdi
callq 0x59a0
movq -0x1a0(%rbp), %rdi
movq %rax, %rsi
callq 0x3a0f0
jmp 0x3bb8e
movl $0x1, -0x11c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x6d30
leaq -0xd0(%rbp), %rdi
callq 0x6d30
jmp 0x3be02
leaq -0xd0(%rbp), %rdi
callq 0x6d30
jmp 0x3be12
cmpl $0x6, -0x1c(%rbp)
jne 0x3bdcb
movq -0x188(%rbp), %rax
cmpl $0x2, 0x20(%rax)
jne 0x3bbdf
jmp 0x3bbfe
leaq 0x1eeca(%rip), %rdi     # 0x5aab0
leaq 0x1ea89(%rip), %rsi     # 0x5a676
movl $0x12e, %edx            # imm = 0x12E
leaq 0x1ee0e(%rip), %rcx     # 0x5aa07
callq 0x31a0
movq -0x190(%rbp), %rax
cmpl $0x2, 0x20(%rax)
jne 0x3bc0d
jmp 0x3bc2c
leaq 0x1eebf(%rip), %rdi     # 0x5aad3
leaq 0x1ea5b(%rip), %rsi     # 0x5a676
movl $0x12f, %edx            # imm = 0x12F
leaq 0x1ede0(%rip), %rcx     # 0x5aa07
callq 0x31a0
movq -0x10(%rbp), %rdi
callq 0x59a0
movq %rax, -0x1e8(%rbp)
leaq -0x139(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x111b0
movq -0x1e8(%rbp), %rsi
movq -0x1e0(%rbp), %rdx
leaq -0x138(%rbp), %rdi
callq 0x17ab0
jmp 0x3bc6b
leaq -0x139(%rbp), %rdi
callq 0x6620
movl $0x0, -0x140(%rbp)
movl -0x140(%rbp), %eax
movl %eax, -0x1ec(%rbp)
movq -0x10(%rbp), %rdi
callq 0x59a0
movq %rax, %rcx
movl -0x1ec(%rbp), %eax
cmpl %ecx, %eax
jge 0x3bd19
movq -0x10(%rbp), %rdi
movslq -0x140(%rbp), %rsi
callq 0x17a50
movslq (%rax), %rsi
leaq 0x658ed3(%rip), %rdi    # 0x694b90
callq 0x178f0
movl (%rax), %eax
movl %eax, -0x1f0(%rbp)
movslq -0x140(%rbp), %rsi
leaq -0x138(%rbp), %rdi
callq 0x178f0
movl -0x1f0(%rbp), %ecx
movl %ecx, (%rax)
movl -0x140(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x140(%rbp)
jmp 0x3bc81
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x139(%rbp), %rdi
callq 0x6620
jmp 0x3be12
leaq -0x168(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x6490
jmp 0x3bd2e
leaq -0x168(%rbp), %rdi
callq 0x4c830
fstpt -0x1fc(%rbp)
jmp 0x3bd42
leaq -0x168(%rbp), %rdi
callq 0x6d30
fldt -0x1fc(%rbp)
movq -0x1a0(%rbp), %rdi
fstpt -0x150(%rbp)
fldt -0x150(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0x3a110
jmp 0x3bd73
movl $0x1, -0x11c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x6d30
jmp 0x3be02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x3bdbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x6d30
leaq -0x138(%rbp), %rdi
callq 0x6d30
jmp 0x3be12
cmpl $0x5, -0x1c(%rbp)
jne 0x3bde3
movq -0x1a0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3a0f0
jmp 0x3be02
leaq 0x1d386(%rip), %rdi     # 0x59170
leaq 0x1e885(%rip), %rsi     # 0x5a676
movl $0x13b, %edx            # imm = 0x13B
leaq 0x1ec0a(%rip), %rcx     # 0x5aa07
callq 0x31a0
movq -0x198(%rbp), %rax
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0xe0(%rbp), %rdi
callq 0x3480
nop