// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movq %rcx, %r15
movq %rdi, 0x68(%rsp)
movl 0x38(%rsi), %ebx
movq (%rcx), %rax
movq 0x8(%rcx), %r8
movq %r8, %rcx
subq %rax, %rcx
shrq $0x2, %rcx
subl %ebx, %ecx
cmpl %ebx, %ecx
jge 0x2b6d2
movq %rax, %rdi
cmpq %r8, %rdi
je 0x2b6d0
negl (%rdi)
addq $0x4, %rdi
jmp 0x2b6c3
movl %ecx, %ebx
movq %rsi, 0x70(%rsp)
pushq $0x1
popq %rcx
movl %ecx, %r12d
leal (%r12,%r12), %ecx
cmpl %ebx, %r12d
jle 0x2b6da
leaq 0x20(%rsp), %rcx
andq $0x0, 0x10(%rcx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rcx)
movl %edx, 0x18(%rcx)
leal -0x1(%r12), %r14d
leaq 0x40(%rsp), %rbp
leaq 0x5c(%rsp), %r13
subq %rax, %r8
shrq $0x2, %r8
testl %r8d, %r14d
je 0x2b769
xorl %eax, %eax
subl 0x38(%rsp), %eax
movl %eax, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x18af6
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
callq 0x1cb40
movq %rbp, %rdi
callq 0x7512
movl 0x38(%rsp), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x38(%rsp)
movl %eax, 0x40(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x19ed4
movq (%r15), %rax
movq 0x8(%r15), %r8
jmp 0x2b708
decl %r8d
subq $0x8, %rsp
pushq $0x1
popq %rax
leaq 0x48(%rsp), %rdi
movq 0x78(%rsp), %r13
movq %r13, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
movl %r12d, %r9d
pushq %rax
pushq %rax
leaq 0x38(%rsp), %rax
pushq %rax
callq 0x2b20e
addq $0x20, %rsp
movl 0x38(%rsp), %r14d
leal 0x1(%r14), %eax
movl %eax, 0x38(%rsp)
movslq %ebx, %rbx
movq 0x40(%rsp), %rax
movl -0x4(%rax,%rbx,4), %eax
leaq 0x5c(%rsp), %rsi
movl %eax, (%rsi)
movl %r14d, %ebp
negl %ebp
movl %ebp, 0x4(%rsi)
leaq 0x8(%rsp), %rdi
pushq $0x2
popq %rdx
leaq 0x7(%rsp), %rcx
callq 0x18af6
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1cb40
leaq 0x8(%rsp), %rdi
callq 0x7512
movq 0x40(%rsp), %rax
xorl %ecx, %ecx
subl (%rax,%rbx,4), %ecx
leaq 0x5c(%rsp), %rsi
movl %ecx, (%rsi)
movl %ebp, 0x4(%rsi)
leaq 0x8(%rsp), %rdi
pushq $0x2
popq %rdx
leaq 0x7(%rsp), %rcx
callq 0x18af6
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1cb40
leaq 0x8(%rsp), %rdi
callq 0x7512
cmpb $0x1, 0x58(%r13)
jne 0x2b87c
leaq -0x1(%rbx), %rax
movq 0x40(%rsp), %rcx
xorl %edx, %edx
subl (%rcx,%rax,4), %edx
leaq 0x5c(%rsp), %rsi
movl %edx, (%rsi)
movl (%rcx,%rbx,4), %eax
movl %eax, 0x4(%rsi)
movl %r14d, 0x8(%rsi)
leaq 0x8(%rsp), %rdi
pushq $0x3
popq %rdx
leaq 0x7(%rsp), %rcx
callq 0x18af6
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1cb40
leaq 0x8(%rsp), %rdi
callq 0x7512
leaq 0x20(%rsp), %rsi
movq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0x2d50a
movl %r14d, 0x20(%rbx)
leaq 0x40(%rsp), %rdi
callq 0x7512
leaq 0x20(%rsp), %rdi
callq 0x6aa2
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b8c2
jmp 0x2b8d1
jmp 0x2b8d1
jmp 0x2b8c2
jmp 0x2b8d1
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x7512
jmp 0x2b8d4
movq %rax, %rbx
jmp 0x2b8dd
jmp 0x2b8e9
jmp 0x2b8e9
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x7512
jmp 0x2b8ec
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x6aa2
movq %rbx, %rdi
callq 0x3490