// File: /workspace/github_cpp_makefile_star2_O1/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), %rcx
movq 0x8(%r15), %r8
movq %r8, %rax
subq %rcx, %rax
shrq $0x2, %rax
subl %ebp, %eax
cmpl %ebp, %eax
jge 0x34f19
cmpq %r8, %rcx
je 0x34f17
negl (%rcx)
addq $0x4, %rcx
jmp 0x34f0a
movl %eax, %ebp
movq %rsi, 0x80(%rsp)
movq %rdi, 0x78(%rsp)
movl $0x1, %eax
movl %eax, %r12d
leal (%r12,%r12), %eax
cmpl %ebp, %r12d
jle 0x34f2b
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movl %edx, 0x58(%rsp)
leal -0x1(%r12), %ebx
movq 0x8(%r15), %r8
subq (%r15), %r8
shrq $0x2, %r8
testl %r8d, %ebx
je 0x34ff6
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 0x1f586
movq %r14, %rdi
movq %r13, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x34fb2
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), %rsi
cmpq 0x10(%r15), %rsi
je 0x34fd7
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r15)
jmp 0x34fe2
movq %r15, %rdi
movq %r13, %rdx
callq 0x20b8a
movq 0x8(%r15), %r8
subq (%r15), %r8
shrq $0x2, %r8
testl %r8d, %ebx
jne 0x34f6f
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 0x3495c
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 0x1f586
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x23202
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3508c
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 0x1f586
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x23202
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x350db
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
cmpb $0x1, 0x58(%r13)
jne 0x3513b
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 0x1f586
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x23202
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3513b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0x40(%rsp), %rsi
movq 0x78(%rsp), %r14
movq %r14, %rdi
callq 0x373d2
movl 0x58(%rsp), %eax
movl %eax, 0x18(%r14)
movl %ebx, 0x20(%r14)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x35170
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0x40(%rsp), %rdi
callq 0x8f6e
movq %r14, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x35199
jmp 0x351c0
jmp 0x351c0
jmp 0x35199
jmp 0x351c0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x351c3
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
jmp 0x351c3
jmp 0x351c0
jmp 0x351bb
jmp 0x351bb
movq %rax, %rbx
jmp 0x351da
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x351da
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
leaq 0x40(%rsp), %rdi
callq 0x8f6e
movq %rbx, %rdi
callq 0x34a0