// File: /workspace/github_cpp_makefile_star2_O3/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, 0x3c(%rsp)
movq 0x8(%rdx), %r15
subq (%rdx), %r15
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cmpq %rax, %r15
jne 0x32e87
movq %r8, %r14
movq %rdx, %r12
movq %rcx, %rbx
shrq $0x2, %r15
leal (%r15,%r15), %eax
movl %eax, 0x4c(%rsp)
movslq %eax, %rsi
leaq 0x20(%rsp), %rdx
movq %rdi, 0x8(%rsp)
movq 0x8(%rsp), %rdi
movq %rsi, 0x58(%rsp)
callq 0x8c20
movq 0x8(%rsp), %rax
testl %r15d, %r15d
jle 0x32e75
movl %r15d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq %rcx, 0x40(%rsp)
xorl %ebp, %ebp
leaq 0x20(%rsp), %r13
movl 0x18(%r14), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x18(%r14)
movq (%rax), %rsi
movl %ecx, (%rsi,%rbp,8)
movl 0x18(%r14), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x18(%r14)
movl %ecx, 0x4(%rsi,%rbp,8)
cmpb $0x0, 0x3c(%rsp)
je 0x32998
movq (%r12), %rcx
xorl %edx, %edx
subl (%rcx,%rbp,4), %edx
movl %edx, 0x14(%rsp)
movq (%rbx), %rcx
xorl %edx, %edx
subl (%rcx,%rbp,4), %edx
movl %edx, 0x18(%rsp)
movl 0x4(%rsi,%rbp,8), %eax
movl %eax, 0x1c(%rsp)
movl $0x3, %edx
movq %r13, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r13, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x328ea
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq (%r12), %rax
xorl %ecx, %ecx
subl (%rax,%rbp,4), %ecx
movl %ecx, 0x14(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movl (%rax,%rbp,8), %eax
movl %eax, 0x18(%rsp)
movl $0x2, %edx
movq %r13, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r13, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3293f
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq (%rbx), %rax
xorl %ecx, %ecx
subl (%rax,%rbp,4), %ecx
movl %ecx, 0x14(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movl (%rax,%rbp,8), %eax
movl %eax, 0x18(%rsp)
movl $0x2, %edx
movq %r13, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r13, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32993
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rax
cmpb $0x0, 0xc0(%rsp)
je 0x32ab0
movq (%r12), %rcx
movl (%rcx,%rbp,4), %ecx
movl %ecx, 0x14(%rsp)
movq (%rbx), %rcx
movl (%rcx,%rbp,4), %ecx
movl %ecx, 0x18(%rsp)
movq (%rax), %rax
xorl %ecx, %ecx
subl (%rax,%rbp,8), %ecx
movl %ecx, 0x1c(%rsp)
movl $0x3, %edx
movq %r13, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r13, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32a00
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq (%r12), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0x14(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
xorl %ecx, %ecx
subl 0x4(%rax,%rbp,8), %ecx
movl %ecx, 0x18(%rsp)
movl $0x2, %edx
movq %r13, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r13, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32a56
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq (%rbx), %rax
movl (%rax,%rbp,4), %eax
movl %eax, 0x14(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
xorl %ecx, %ecx
subl 0x4(%rax,%rbp,8), %ecx
movl %ecx, 0x18(%rsp)
movl $0x2, %edx
movq %r13, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r13, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32aab
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rax
incq %rbp
cmpq %rbp, 0x40(%rsp)
jne 0x32865
testl %r15d, %r15d
jle 0x32e75
movq (%rax), %rax
movl %r15d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edx, %edx
movl $0x0, %esi
cmpl $0x1, %r15d
je 0x32afb
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 0x32ae7
movslq %esi, %rdi
cmpq %rdi, %rdx
jge 0x32b18
addl %esi, %esi
movslq %esi, %rsi
movq (%rax,%rdx,8), %rdi
movq (%rax,%rsi,4), %r8
movq %r8, (%rax,%rdx,8)
movq %rdi, (%rax,%rsi,4)
incq %rdx
cmpq %rcx, %rdx
jne 0x32ad5
cmpl $0x1, %r15d
movq 0x8(%rsp), %rax
je 0x32e75
movl $0x4, %r8d
leaq 0x20(%rsp), %r12
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, 0x40(%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 0x32e0e
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %r15d, %r15d
cmpb $0x0, 0x3c(%rsp)
je 0x32cd8
movq (%rax), %rax
leaq (%rax,%rbx), %rcx
xorl %edx, %edx
subl 0x4(%rcx,%r15,2), %edx
movl %edx, 0x14(%rsp)
addq %rbp, %rax
xorl %ecx, %ecx
subl (%rax,%r15,2), %ecx
movl %ecx, 0x18(%rsp)
movl 0x18(%r14), %eax
addl %r15d, %eax
incl %eax
movl %eax, 0x1c(%rsp)
movl $0x3, %edx
movq %r12, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r12, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32c20
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rax
movq (%rax), %rax
addq %rbx, %rax
xorl %ecx, %ecx
subl 0x4(%rax,%r15,2), %ecx
movl %ecx, 0x14(%rsp)
movl 0x18(%r14), %eax
addl %r15d, %eax
movl %eax, 0x18(%rsp)
movl $0x2, %edx
movq %r12, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r12, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32c7a
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rax
movq (%rax), %rax
addq %rbp, %rax
xorl %ecx, %ecx
subl (%rax,%r15,2), %ecx
movl %ecx, 0x14(%rsp)
movl 0x18(%r14), %eax
addl %r15d, %eax
movl %eax, 0x18(%rsp)
movl $0x2, %edx
movq %r12, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r12, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32cd3
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rax
cmpb $0x0, 0xc0(%rsp)
je 0x32dfb
movq (%rax), %rax
leaq (%rax,%rbx), %rcx
movl 0x4(%rcx,%r15,2), %ecx
movl %ecx, 0x14(%rsp)
addq %rbp, %rax
movl (%rax,%r15,2), %eax
movl %eax, 0x18(%rsp)
movl %r13d, %eax
subl 0x18(%r14), %eax
incl %eax
movl %eax, 0x1c(%rsp)
movl $0x3, %edx
movq %r12, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r12, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32d47
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rax
movq (%rax), %rax
addq %rbx, %rax
movl 0x4(%rax,%r15,2), %eax
movl %eax, 0x14(%rsp)
movl %r13d, %eax
subl 0x18(%r14), %eax
movl %eax, 0x18(%rsp)
movl $0x2, %edx
movq %r12, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r12, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32d9f
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rax
movq (%rax), %rax
addq %rbp, %rax
movl (%rax,%r15,2), %eax
movl %eax, 0x14(%rsp)
movl %r13d, %eax
subl 0x18(%r14), %eax
movl %eax, 0x18(%rsp)
movl $0x2, %edx
movq %r12, %rdi
leaq 0x14(%rsp), %rsi
leaq 0x7(%rsp), %rcx
callq 0x1e9a8
movq %r14, %rdi
movq %r12, %rsi
callq 0x2259a
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32df6
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rax
addl $-0x2, %r13d
addq $0x2, %r15
cmpq %r15, 0x40(%rsp)
jne 0x32bb0
movl 0x50(%rsp), %r8d
cmpl $0x3, %r8d
movq 0x60(%rsp), %r9
movq 0x80(%rsp), %r10
jl 0x32e44
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 0x32e2e
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 0x32b8f
addl %r8d, %r8d
cmpl 0x4c(%rsp), %r8d
jle 0x32b3a
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7481(%rip), %rdi      # 0x3a30f
leaq 0x7397(%rip), %rsi      # 0x3a22c
leaq 0x7488(%rip), %rcx      # 0x3a324
movl $0x19, %edx
callq 0x31b0
jmp 0x32ec8
jmp 0x32ec8
jmp 0x32ec8
jmp 0x32ec8
jmp 0x32ec8
jmp 0x32ec8
jmp 0x32ed7
jmp 0x32ed7
jmp 0x32ed7
jmp 0x32ed7
jmp 0x32ed7
jmp 0x32ed7
jmp 0x32ec8
jmp 0x32ec8
jmp 0x32ec8
jmp 0x32ec8
jmp 0x32ec8
movq %rax, %r14
jmp 0x32ef1
jmp 0x32ed7
jmp 0x32ed7
jmp 0x32ed7
jmp 0x32ed7
jmp 0x32ed7
movq %rax, %r14
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32ef1
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32b0
movq 0x8(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x32f0a
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x32b0
movq %r14, %rdi
callq 0x34a0