// File: /workspace/github_cpp_makefile_star2_O3/Laakeri[P]maxpre/src/cardinalityconstraint.cpp
// Function: maxPreprocessor::CardinalityConstraint::getEqualNetwork(int, std::vector<int, std::allocator<int>>)
pair<CardinalityConstraint::Formula, int> CardinalityConstraint::getEqualNetwork(int freeVar, vector<int> input) {
	int KK = K;
	if ((int)input.size() - K < KK) {
		KK = (int)input.size() - K;
		for (int& lit : input) {
			lit = -lit;
		}
	}
	int k = 1;
	while (k <= KK) k *= 2;
	Formula F(freeVar);
	while ((int)input.size()%k != 0) {
		F.clauses.push_back({-F.freeVar});
		input.push_back(F.freeVar++);
	}
	vector<int> output = Card(input, 0, (int)input.size()-1, k, F, true, true);
	int oV = F.freeVar++;
	F.clauses.push_back({output[KK-1], -oV});
	F.clauses.push_back({-output[KK], -oV});
	if (iff) {
		F.clauses.push_back({-output[KK-1], output[KK], oV});
	}
	return {F, oV};
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %r15
movl 0x38(%rsi), %ebp
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq %rcx, %r8
subq %rax, %r8
shrq $0x2, %r8
movl %r8d, %r9d
subl %ebp, %r9d
cmpl %ebp, %r9d
jge 0x33f73
cmpq %rcx, %rax
je 0x33f70
negl (%rax)
addq $0x4, %rax
jmp 0x33f63
movl %r9d, %ebp
movq %rsi, 0x80(%rsp)
movq %rdi, 0x78(%rsp)
movl $0x1, %eax
movl %eax, %r12d
leal (%r12,%r12), %eax
cmpl %ebp, %r12d
jle 0x33f85
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movl %edx, 0x58(%rsp)
leal -0x1(%r12), %ebx
testl %r8d, %ebx
je 0x34049
leaq 0x28(%rsp), %r13
leaq 0x40(%rsp), %r14
xorl %eax, %eax
subl 0x58(%rsp), %eax
movl %eax, 0x10(%rsp)
movl $0x1, %edx
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x6c(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r13, %rsi
callq 0x2259a
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x34001
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movl 0x58(%rsp), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x58(%rsp)
movl %eax, 0x28(%rsp)
movq 0x8(%r15), %r8
cmpq 0x10(%r15), %r8
je 0x34027
movl %eax, (%r8)
addq $0x4, %r8
movq %r8, 0x8(%r15)
jmp 0x34039
movq %r15, %rdi
movq %r8, %rsi
movq %r13, %rdx
callq 0x1ffb8
movq 0x8(%r15), %r8
subq (%r15), %r8
shrq $0x2, %r8
testl %r8d, %ebx
jne 0x33fbe
decl %r8d
subq $0x8, %rsp
movl $0x1, %eax
leaq 0x48(%rsp), %r10
leaq 0x30(%rsp), %rdi
movq 0x88(%rsp), %r13
movq %r13, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
movl %r12d, %r9d
pushq %rax
pushq %rax
pushq %r10
callq 0x339b2
addq $0x20, %rsp
movl 0x58(%rsp), %ebx
leal 0x1(%rbx), %eax
movl %eax, 0x58(%rsp)
movslq %ebp, %r14
movq 0x28(%rsp), %rax
movl -0x4(%rax,%r14,4), %eax
leaq 0x6c(%rsp), %rsi
movl %eax, (%rsi)
movl %ebx, %ebp
negl %ebp
movl %ebp, 0x4(%rsi)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movl $0x2, %edx
callq 0x1e9a8
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2259a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x340df
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x28(%rsp), %rax
xorl %ecx, %ecx
subl (%rax,%r14,4), %ecx
leaq 0x6c(%rsp), %rsi
movl %ecx, (%rsi)
movl %ebp, 0x4(%rsi)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movl $0x2, %edx
callq 0x1e9a8
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2259a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3412e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
cmpb $0x1, 0x58(%r13)
jne 0x3418e
leaq -0x1(%r14), %rax
movq 0x28(%rsp), %rcx
xorl %edx, %edx
subl (%rcx,%rax,4), %edx
leaq 0x6c(%rsp), %rsi
movl %edx, (%rsi)
movl (%rcx,%r14,4), %eax
movl %eax, 0x4(%rsi)
movl %ebx, 0x8(%rsi)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movl $0x3, %edx
callq 0x1e9a8
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2259a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3418e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0x40(%rsp), %rsi
movq 0x78(%rsp), %r14
movq %r14, %rdi
callq 0x363a4
movl 0x58(%rsp), %eax
movl %eax, 0x18(%r14)
movl %ebx, 0x20(%r14)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x341c3
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0x40(%rsp), %rdi
callq 0x8f5e
movq %r14, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x341ec
jmp 0x34213
jmp 0x34213
jmp 0x341ec
jmp 0x34213
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x34216
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
jmp 0x34216
jmp 0x34213
jmp 0x3420e
jmp 0x3420e
movq %rax, %rbx
jmp 0x3422d
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x3422d
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0x40(%rsp), %rdi
callq 0x8f5e
movq %rbx, %rdi
callq 0x34a0
nop