// File: /workspace/github_cpp_makefile_star2_O1/Laakeri[P]maxpre/src/cardinalityconstraint.cpp
// Function: maxPreprocessor::CardinalityConstraint::HMerge(std::vector<int, std::allocator<int>> const&, std::vector<int, std::allocator<int>> const&, maxPreprocessor::CardinalityConstraint::Formula&, bool, bool)
vector<int> CardinalityConstraint::HMerge(const vector<int>& A, const vector<int>& B, Formula& F, bool d1, bool d2) {
	// use the bit reversal trick to do HMerge without recursion
	assert(A.size() == B.size());
	int n = A.size();
	vector<int> c(2*n);
	for (int i = 0; i < n; i++) {
		c[2*i] = F.freeVar++;
		c[2*i+1] = F.freeVar++;
		if (d1) {
			F.clauses.push_back({-A[i], -B[i], c[2*i+1]});
			F.clauses.push_back({-A[i], c[2*i]});
			F.clauses.push_back({-B[i], c[2*i]});
		}
		if (d2) {
			F.clauses.push_back({A[i], B[i], -c[2*i]});
			F.clauses.push_back({A[i], -c[2*i+1]});
			F.clauses.push_back({B[i], -c[2*i+1]});
		}
	}
	for (int i = 0; i < n; i++) {
		int u = 0;
		for (int j = 1; j < n; j *= 2) {
			u *= 2;
			if (i & j) u++;
		}
		if (i < u) {
			swap(c[2*i], c[2*u]);
			swap(c[2*i+1], c[2*u+1]);
		}
	}
	for (int le = 4; le <= 2*n; le *= 2) {
		for (int i = 0; i < 2*n; i+=le) {
			for (int j = 0; j+1 < le/2; j++) {
				if (d1) {
					F.clauses.push_back({-c[i+j+1], -c[i+j+le/2], F.freeVar+2*j+1});
					F.clauses.push_back({-c[i+j+1], F.freeVar+2*j});
					F.clauses.push_back({-c[i+j+le/2], F.freeVar+2*j});
				}
				if (d2) {
					F.clauses.push_back({c[i+j+1], c[i+j+le/2], -(F.freeVar+2*j)});
					F.clauses.push_back({c[i+j+1], -(F.freeVar+2*j+1)});
					F.clauses.push_back({c[i+j+le/2], -(F.freeVar+2*j+1)});
				}
			}
			for (int j = 1; j+1 < le; j++) c[i+j] = F.freeVar++;
		}
	}
	return c;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %r9d, 0x44(%rsp)
movq 0x8(%rdx), %r15
subq (%rdx), %r15
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cmpq %rax, %r15
jne 0x33e7b
movq %r8, %r14
movq %rdx, %r12
movq %rcx, %rbx
shrq $0x2, %r15
leal (%r15,%r15), %eax
movl %eax, 0x40(%rsp)
movslq %eax, %rsi
leaq 0x28(%rsp), %rdx
movq %rdi, 0x10(%rsp)
movq 0x10(%rsp), %rdi
callq 0x8c32
movq 0x10(%rsp), %rsi
testl %r15d, %r15d
jle 0x33a90
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x48(%rsp)
xorl %ebp, %ebp
leaq 0x28(%rsp), %r13
movl 0x18(%r14), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x18(%r14)
movq (%rsi), %rax
movl %ecx, (%rax,%rbp,8)
movl 0x18(%r14), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x18(%r14)
movl %ecx, 0x4(%rax,%rbp,8)
cmpb $0x0, 0x44(%rsp)
je 0x3396a
movq (%r12), %rcx
xorl %edx, %edx
subl (%rcx,%rbp,4), %edx
movl %edx, 0x1c(%rsp)
movq (%rbx), %rcx
xorl %edx, %edx
subl (%rcx,%rbp,4), %edx
movl %edx, 0x20(%rsp)
movl 0x4(%rax,%rbp,8), %eax
movl %eax, 0x24(%rsp)
movl $0x3, %edx
movq %r13, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r13, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x338bc
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq (%r12), %rax
xorl %ecx, %ecx
subl (%rax,%rbp,4), %ecx
movl %ecx, 0x1c(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl (%rax,%rbp,8), %eax
movl %eax, 0x20(%rsp)
movl $0x2, %edx
movq %r13, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r13, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33911
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq (%rbx), %rax
xorl %ecx, %ecx
subl (%rax,%rbp,4), %ecx
movl %ecx, 0x1c(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl (%rax,%rbp,8), %eax
movl %eax, 0x20(%rsp)
movl $0x2, %edx
movq %r13, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r13, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33965
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x10(%rsp), %rsi
cmpb $0x0, 0xc0(%rsp)
je 0x33a82
movq (%r12), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0x1c(%rsp)
movq (%rbx), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0x20(%rsp)
movq (%rsi), %rax
xorl %ecx, %ecx
subl (%rax,%rbp,8), %ecx
movl %ecx, 0x24(%rsp)
movl $0x3, %edx
movq %r13, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r13, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x339d2
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq (%r12), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0x1c(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rax
xorl %ecx, %ecx
subl 0x4(%rax,%rbp,8), %ecx
movl %ecx, 0x20(%rsp)
movl $0x2, %edx
movq %r13, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r13, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33a28
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq (%rbx), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0x1c(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rax
xorl %ecx, %ecx
subl 0x4(%rax,%rbp,8), %ecx
movl %ecx, 0x20(%rsp)
movl $0x2, %edx
movq %r13, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r13, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33a7d
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x10(%rsp), %rsi
incq %rbp
cmpq %rbp, 0x48(%rsp)
jne 0x33837
testl %r15d, %r15d
jle 0x33b0b
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl %r15d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edx, %edx
movl $0x0, %esi
cmpl $0x1, %r15d
je 0x33ace
movl $0x1, %edi
xorl %esi, %esi
xorl %r8d, %r8d
testl %edx, %edi
setne %r8b
leal (%r8,%rsi,2), %esi
addl %edi, %edi
cmpl %r15d, %edi
jl 0x33aba
movslq %esi, %rdi
cmpq %rdi, %rdx
jge 0x33b03
leal (%rsi,%rsi), %edi
movslq %edi, %rdi
movl (%rax,%rdx,8), %r8d
movl (%rax,%rdi,4), %r9d
movl %r9d, (%rax,%rdx,8)
movl %r8d, (%rax,%rdi,4)
leal 0x1(%rsi,%rsi), %esi
movslq %esi, %rsi
movl 0x4(%rax,%rdx,8), %edi
movl (%rax,%rsi,4), %r8d
movl %r8d, 0x4(%rax,%rdx,8)
movl %edi, (%rax,%rsi,4)
incq %rdx
cmpq %rcx, %rdx
jne 0x33aa8
cmpl $0x2, %r15d
movq 0x10(%rsp), %rax
jl 0x33e69
movl 0x40(%rsp), %ecx
movq %rcx, 0x58(%rsp)
movl $0x4, %r8d
leaq 0x28(%rsp), %r15
movl %r8d, %ecx
sarl %ecx
movl %ecx, 0x54(%rsp)
movslq %ecx, %rcx
movslq %r8d, %rdx
leaq (,%rcx,4), %rbp
leaq (,%rdx,4), %rsi
movq %rsi, 0x68(%rsp)
addl $-0x2, %ecx
leaq 0x2(,%rcx,2), %rcx
movq %rcx, 0x48(%rsp)
movq %rdx, 0x70(%rsp)
leal -0x4(%rdx), %r9d
addq $0x2, %r9
movl $0x4, %r10d
xorl %ebx, %ebx
xorl %edx, %edx
movl %r8d, 0x50(%rsp)
movq %r9, 0x60(%rsp)
movq %rdx, 0x78(%rsp)
movq %r10, 0x80(%rsp)
cmpl $0x2, 0x54(%rsp)
jl 0x33e02
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %r13d, %r13d
cmpb $0x0, 0x44(%rsp)
je 0x33ccc
movq (%rax), %rax
leaq (%rax,%rbx), %rcx
xorl %edx, %edx
subl 0x4(%rcx,%r13,2), %edx
movl %edx, 0x1c(%rsp)
addq %rbp, %rax
xorl %ecx, %ecx
subl (%rax,%r13,2), %ecx
movl %ecx, 0x20(%rsp)
movl 0x18(%r14), %eax
addl %r13d, %eax
incl %eax
movl %eax, 0x24(%rsp)
movl $0x3, %edx
movq %r15, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r15, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33c14
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x10(%rsp), %rax
movq (%rax), %rax
addq %rbx, %rax
xorl %ecx, %ecx
subl 0x4(%rax,%r13,2), %ecx
movl %ecx, 0x1c(%rsp)
movl 0x18(%r14), %eax
addl %r13d, %eax
movl %eax, 0x20(%rsp)
movl $0x2, %edx
movq %r15, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r15, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33c6e
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x10(%rsp), %rax
movq (%rax), %rax
addq %rbp, %rax
xorl %ecx, %ecx
subl (%rax,%r13,2), %ecx
movl %ecx, 0x1c(%rsp)
movl 0x18(%r14), %eax
addl %r13d, %eax
movl %eax, 0x20(%rsp)
movl $0x2, %edx
movq %r15, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r15, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33cc7
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x10(%rsp), %rax
cmpb $0x0, 0xc0(%rsp)
je 0x33def
movq (%rax), %rax
leaq (%rax,%rbx), %rcx
movl 0x4(%rcx,%r13,2), %ecx
movl %ecx, 0x1c(%rsp)
addq %rbp, %rax
movl (%rax,%r13,2), %eax
movl %eax, 0x20(%rsp)
movl %r12d, %eax
subl 0x18(%r14), %eax
incl %eax
movl %eax, 0x24(%rsp)
movl $0x3, %edx
movq %r15, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r15, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33d3b
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x10(%rsp), %rax
movq (%rax), %rax
addq %rbx, %rax
movl 0x4(%rax,%r13,2), %eax
movl %eax, 0x1c(%rsp)
movl %r12d, %eax
subl 0x18(%r14), %eax
movl %eax, 0x20(%rsp)
movl $0x2, %edx
movq %r15, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r15, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33d93
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x10(%rsp), %rax
movq (%rax), %rax
addq %rbp, %rax
movl (%rax,%r13,2), %eax
movl %eax, 0x1c(%rsp)
movl %r12d, %eax
subl 0x18(%r14), %eax
movl %eax, 0x20(%rsp)
movl $0x2, %edx
movq %r15, %rdi
leaq 0x1c(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x1f586
movq %r14, %rdi
movq %r15, %rsi
callq 0x23202
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33dea
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x10(%rsp), %rax
addq $0x2, %r13
addl $-0x2, %r12d
cmpq %r13, 0x48(%rsp)
jne 0x33ba4
movl 0x50(%rsp), %r8d
cmpl $0x3, %r8d
movq 0x60(%rsp), %r9
movq 0x80(%rsp), %r10
jl 0x33e38
movq (%rax), %rdi
addq %r10, %rdi
xorl %ecx, %ecx
movl 0x18(%r14), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x18(%r14)
movl %edx, (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %r9
jne 0x33e22
movq 0x78(%rsp), %rdx
addq 0x70(%rsp), %rdx
movq 0x68(%rsp), %rcx
addq %rcx, %rbp
addq %rcx, %rbx
addq %rcx, %r10
cmpq 0x58(%rsp), %rdx
jl 0x33b83
addl %r8d, %r8d
cmpl 0x40(%rsp), %r8d
jle 0x33b2e
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7379(%rip), %rdi      # 0x3b1fb
leaq 0x728f(%rip), %rsi      # 0x3b118
leaq 0x7380(%rip), %rcx      # 0x3b210
movl $0x19, %edx
callq 0x31b0
jmp 0x33ebc
jmp 0x33ebc
jmp 0x33ebc
jmp 0x33ebc
jmp 0x33ebc
jmp 0x33ebc
jmp 0x33ecb
jmp 0x33ecb
jmp 0x33ecb
jmp 0x33ecb
jmp 0x33ecb
jmp 0x33ecb
jmp 0x33ebc
jmp 0x33ebc
jmp 0x33ebc
jmp 0x33ebc
jmp 0x33ebc
movq %rax, %r14
jmp 0x33ee5
jmp 0x33ecb
jmp 0x33ecb
jmp 0x33ecb
jmp 0x33ecb
jmp 0x33ecb
movq %rax, %r14
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x33ee5
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x10(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x33efe
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %r14, %rdi
callq 0x34a0