// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/probleminstance.cpp
// Function: maxPreprocessor::ProblemInstance::ProblemInstance(std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>> const&, std::vector<unsigned long, std::allocator<unsigned long>> const&, unsigned long)
ProblemInstance::ProblemInstance(const vector<vector<int> >& clauses_, const vector<uint64_t>& weights_, uint64_t topWeight) : tl(*this) {
	assert(clauses_.size() == weights_.size());
	excessVar = 0;
	
	int maxVar = 0;
	
	clauses.reserve(clauses_.size());
	for (unsigned i = 0; i < clauses_.size(); i++) {
		clauses.emplace_back(Clause(clauses_[i], weights_[i]));
	}
	
	for (unsigned i = 0; i < clauses.size(); i++) {
		for (int lit : clauses[i].lit) {
			maxVar = max(maxVar, abs(lit) - 1);
		}
	}
	
	for (unsigned i = 0; i < clauses.size(); i++) {
		for (int& lit : clauses[i].lit) {
			lit=litFromDimacs(lit);
		}
		
		if (clauses[i].weight >= topWeight) clauses[i].weight = HARDWEIGHT;
		
		sort(clauses[i].lit.begin(), clauses[i].lit.end());
		clauses[i].lit.erase(unique(clauses[i].lit.begin(), clauses[i].lit.end()), clauses[i].lit.end());
		clauses[i].updateHash();
	}
	vars = maxVar + 1;
	
	isLabel.resize(vars);
	litClauses.resize(vars*2);
	removedClauses.resize(clauses.size());
	
	tl.init(vars);
	
	for (unsigned i = 0; i < clauses.size(); i++) {
		populateLitClauses(i);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, 0x20(%rsp)
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x18(%rdi), %r12
leaq 0x30(%rdi), %r13
leaq 0x48(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x68(%rdi), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movq %rdi, 0x10(%rsp)
movq %rbx, %rsi
callq 0x26be4
movq 0x8(%r15), %rax
subq (%r15), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq 0x8(%r14), %rcx
subq (%r14), %rcx
sarq $0x3, %rcx
cmpq %rcx, %rax
jne 0x21321
andl $0x0, 0x64(%rbx)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x21806
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
xorl %ebp, %ebp
leaq 0x28(%rsp), %r12
leaq 0x40(%rsp), %r13
movl %ebp, %ebp
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %rbp, %rax
jbe 0x2119c
imulq $0x18, %rbp, %rax
addq %rax, %rsi
movq %r12, %rdi
callq 0x19284
movq (%r14), %rax
movq (%rax,%rbp,8), %rdx
movq %r13, %rdi
movq %r12, %rsi
callq 0x21b64
movq %rbx, %rdi
movq %r13, %rsi
callq 0x218a8
movq %r13, %rdi
callq 0x7512
movq %r12, %rdi
callq 0x7512
incl %ebp
jmp 0x21143
movq (%rbx), %rsi
movq 0x8(%rbx), %rcx
movq %rcx, %rax
subq %rsi, %rax
pushq $0x28
popq %r15
cqto
idivq %r15
xorl %r14d, %r14d
xorl %edx, %edx
movl %edx, %edx
cmpq %rdx, %rax
jbe 0x211f1
imulq $0x28, %rdx, %r8
movq (%rsi,%r8), %rdi
movq 0x8(%rsi,%r8), %r8
cmpq %r8, %rdi
je 0x211ed
movl (%rdi), %r9d
movl %r9d, %r10d
negl %r10d
cmovsl %r9d, %r10d
decl %r10d
cmpl %r10d, %r14d
cmovlel %r10d, %r14d
addq $0x4, %rdi
jmp 0x211cb
incl %edx
jmp 0x211b7
xorl %ebp, %ebp
movl %ebp, %ebp
subq %rsi, %rcx
movq %rcx, %rax
cqto
idivq %r15
cmpq %rbp, %rax
jbe 0x2129f
imulq $0x28, %rbp, %r15
movq (%rsi,%r15), %r12
movq 0x8(%rsi,%r15), %r13
cmpq %r13, %r12
je 0x2122e
movl (%r12), %edi
callq 0x20ee4
movl %eax, (%r12)
addq $0x4, %r12
jmp 0x21216
movq (%rbx), %rcx
leaq (%rcx,%r15), %rax
movq 0x20(%rsp), %rdx
cmpq %rdx, 0x18(%rcx,%r15)
jb 0x2124f
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq %rcx, 0x18(%rax)
movq (%rax), %rdi
movq 0x8(%rax), %rsi
callq 0x1c706
movq (%rbx), %r12
movq (%r12,%r15), %rdi
movq 0x8(%r12,%r15), %rsi
callq 0x1cd6f
addq %r15, %r12
movq (%rbx), %rcx
movq 0x8(%rcx,%r15), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x1902e
addq (%rbx), %r15
movq %r15, %rdi
callq 0x21b86
incl %ebp
movq (%rbx), %rsi
movq 0x8(%rbx), %rcx
pushq $0x28
popq %r15
jmp 0x211f3
incl %r14d
movl %r14d, 0x60(%rbx)
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movq 0x8(%rsp), %r12
movq (%rsp), %r13
callq 0x68c2
movslq 0x60(%rbx), %rsi
addq %rsi, %rsi
movq %r12, %rdi
callq 0x68f4
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
idivq %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0x68c2
movl 0x60(%rbx), %esi
movq 0x10(%rsp), %rdi
callq 0x26c94
xorl %ebp, %ebp
movl %ebp, %ecx
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
idivq %r15
cmpq %rcx, %rax
jbe 0x21312
movq %rbx, %rdi
movl %ebp, %esi
callq 0x213b0
incl %ebp
jmp 0x212f1
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf38d(%rip), %rdi      # 0x306b5
leaq 0xf30c(%rip), %rsi      # 0x3063b
leaq 0xf3a2(%rip), %rcx      # 0x306d8
pushq $0x35
popq %rdx
callq 0x31c0
movq %rax, %r14
jmp 0x21386
jmp 0x21345
movq %rax, %r14
jmp 0x2137c
jmp 0x21370
jmp 0x21370
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x7512
jmp 0x21360
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x7512
jmp 0x21373
jmp 0x21370
jmp 0x21370
movq %rax, %r14
movq 0x8(%rsp), %r12
movq (%rsp), %r13
movq 0x10(%rsp), %rdi
callq 0x6e12
movq 0x18(%rsp), %rdi
callq 0x7512
movq %r13, %rdi
callq 0x7512
movq %r12, %rdi
callq 0x6aa2
movq %rbx, %rdi
callq 0x6e58
movq %r14, %rdi
callq 0x3490