// File: Laakeri[P]maxpre/src/cardinalityconstraint.cpp
// Function: maxPreprocessor::CardinalityConstraint::getGreaterNetwork(int, std::vector<int, std::allocator<int>>)
pair<CardinalityConstraint::Formula, int> CardinalityConstraint::getGreaterNetwork(int freeVar, vector<int> input) {
	int KK = (int)input.size() - K;
	int k = 1;
	while (k < KK) k *= 2;
	Formula F(freeVar);
	for (int& lit : input) {
		lit = -lit;
	}
	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, iff, true);
	return {F, output[KK-1]};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rcx, -0xe0(%rbp)
movq %rdi, %rax
movq -0xe0(%rbp), %rdi
movq %rax, -0xd8(%rbp)
movq %rax, %rcx
movq %rcx, -0xd0(%rbp)
movq %rax, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rdi, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
callq 0xf940
movq -0xc8(%rbp), %rcx
subl 0x38(%rcx), %eax
movl %eax, -0x24(%rbp)
movl $0x1, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7e342
movl -0x28(%rbp), %eax
shll %eax
movl %eax, -0x28(%rbp)
jmp 0x7e330
movl -0x14(%rbp), %esi
leaq -0x48(%rbp), %rdi
callq 0x7b6b0
movq -0xe0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0xa800
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
callq 0xa830
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x7e386
jmp 0x7e3ac
leaq -0x58(%rbp), %rdi
callq 0xa8a0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
xorl %ecx, %ecx
subl (%rax), %ecx
movq -0x68(%rbp), %rax
movl %ecx, (%rax)
leaq -0x58(%rbp), %rdi
callq 0xa930
jmp 0x7e373
jmp 0x7e3ae
movq -0xe0(%rbp), %rdi
callq 0xf940
cltd
idivl -0x28(%rbp)
cmpl $0x0, %edx
je 0x7e4d1
leaq -0x48(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl -0x30(%rbp), %eax
negl %eax
movl %eax, -0x94(%rbp)
leaq -0x94(%rbp), %rax
movq %rax, -0x90(%rbp)
movq $0x1, -0x88(%rbp)
leaq -0x95(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0xa710
movq -0xe8(%rbp), %rcx
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0x3c9b0
jmp 0x7e429
movq -0xf0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x3e200
jmp 0x7e43b
leaq -0x80(%rbp), %rdi
callq 0xab00
leaq -0x95(%rbp), %rdi
callq 0xa7a0
movq -0xe0(%rbp), %rdi
movl -0x30(%rbp), %eax
movl %eax, %ecx
incl %ecx
movl %ecx, -0x30(%rbp)
movl %eax, -0xa8(%rbp)
leaq -0xa8(%rbp), %rsi
callq 0x3c850
jmp 0x7e475
jmp 0x7e3ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x7e4a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xab00
leaq -0x95(%rbp), %rdi
callq 0xa7a0
jmp 0x7e58c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x7e58c
movq -0xe0(%rbp), %rdi
callq 0xf940
movq -0xc8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
movl %eax, %r8d
decl %r8d
movl -0x28(%rbp), %r9d
movzbl 0x58(%rsi), %ecx
andl $0x1, %ecx
movq %rsp, %rax
movl %ecx, 0x8(%rax)
leaq -0x48(%rbp), %rcx
movq %rcx, (%rax)
movl $0x1, 0x10(%rax)
leaq -0xc0(%rbp), %rdi
xorl %ecx, %ecx
callq 0x7de10
jmp 0x7e520
movl -0x24(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0xc0(%rbp), %rdi
callq 0xa7c0
movq -0xd8(%rbp), %rdi
movq %rax, %rdx
leaq -0x48(%rbp), %rsi
callq 0x840a0
jmp 0x7e549
leaq -0xc0(%rbp), %rdi
callq 0xab00
leaq -0x48(%rbp), %rdi
callq 0x84080
movq -0xd0(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xab00
leaq -0x48(%rbp), %rdi
callq 0x84080
movq -0xa0(%rbp), %rdi
callq 0x4610
nopw %cs:(%rax,%rax)