// File: 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
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x128(%rbp)
movq %rdi, %rax
movq %rax, -0x148(%rbp)
callq 0x5fe50
movq -0x128(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0x140(%rbp)
callq 0xb2e0
movq -0x128(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x138(%rbp)
callq 0xa7e0
movq -0x128(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0x130(%rbp)
callq 0xa7e0
movq -0x128(%rbp), %rsi
movq %rsi, %rdi
addq $0x68, %rdi
movq %rdi, -0x120(%rbp)
callq 0x720b0
jmp 0x5ef86
movq -0x10(%rbp), %rdi
callq 0xfd70
movq %rax, -0x150(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3f1b0
movq %rax, %rcx
movq -0x150(%rbp), %rax
cmpq %rcx, %rax
jne 0x5efb0
jmp 0x5efe0
leaq 0x286df(%rip), %rdi     # 0x87696
leaq 0x2865e(%rip), %rsi     # 0x8761c
movl $0x35, %edx
leaq 0x286ef(%rip), %rcx     # 0x876b9
callq 0x4260
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x5f586
movq -0x148(%rbp), %rax
movl $0x0, 0x64(%rax)
movl $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0xfd70
movq -0x148(%rbp), %rdi
movq %rax, %rsi
callq 0x5fe70
jmp 0x5f00f
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq %rax, -0x158(%rbp)
movq -0x10(%rbp), %rdi
callq 0xfd70
movq %rax, %rcx
movq -0x158(%rbp), %rax
cmpq %rcx, %rax
jae 0x5f0fa
movq -0x148(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %eax
movl %eax, %esi
callq 0x3d180
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x3edb0
jmp 0x5f066
movq -0x18(%rbp), %rdi
movl -0x34(%rbp), %eax
movl %eax, %esi
callq 0x5fff0
movq (%rax), %rdx
leaq -0x60(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x60da0
jmp 0x5f086
movq -0x160(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x5ff70
jmp 0x5f098
leaq -0x60(%rbp), %rdi
callq 0xd5b0
leaq -0x78(%rbp), %rdi
callq 0xab00
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5f016
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x5f57a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x5f0ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0xd5b0
leaq -0x78(%rbp), %rdi
callq 0xab00
jmp 0x5f57a
movl $0x0, -0x7c(%rbp)
movq -0x148(%rbp), %rdi
movl -0x7c(%rbp), %eax
movq %rax, -0x168(%rbp)
callq 0x3c4b0
movq %rax, %rcx
movq -0x168(%rbp), %rax
cmpq %rcx, %rax
jae 0x5f1ed
movq -0x148(%rbp), %rdi
movl -0x7c(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0xa800
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rdi
callq 0xa830
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x5f181
jmp 0x5f1dd
leaq -0x90(%rbp), %rdi
callq 0xa8a0
movl (%rax), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
decl %eax
movl %eax, -0xa0(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3e430
movq %rax, -0x170(%rbp)
jmp 0x5f1c3
movq -0x170(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x30(%rbp)
leaq -0x90(%rbp), %rdi
callq 0xa930
jmp 0x5f168
jmp 0x5f1df
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x5f101
movl $0x0, -0xa4(%rbp)
movq -0x148(%rbp), %rdi
movl -0xa4(%rbp), %eax
movq %rax, -0x178(%rbp)
callq 0x3c4b0
movq %rax, %rcx
movq -0x178(%rbp), %rax
cmpq %rcx, %rax
jae 0x5f497
movq -0x148(%rbp), %rdi
movl -0xa4(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0xa800
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rdi
callq 0xa830
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x5f27d
jmp 0x5f2c3
leaq -0xb8(%rbp), %rdi
callq 0xa8a0
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movl (%rax), %edi
callq 0x5eae0
movl %eax, -0x17c(%rbp)
jmp 0x5f2a6
movl -0x17c(%rbp), %ecx
movq -0xc8(%rbp), %rax
movl %ecx, (%rax)
leaq -0xb8(%rbp), %rdi
callq 0xa930
jmp 0x5f264
movq -0x148(%rbp), %rdi
movl -0xa4(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq 0x18(%rax), %rax
cmpq -0x20(%rbp), %rax
jb 0x5f303
movq -0x148(%rbp), %rdi
movl -0xa4(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movq %rcx, 0x18(%rax)
movq -0x148(%rbp), %rdi
movl -0xa4(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq %rax, %rdi
callq 0xa800
movq -0x148(%rbp), %rdi
movq %rax, -0xd0(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq %rax, %rdi
callq 0xa830
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x3e130
jmp 0x5f35e
movq -0x148(%rbp), %rdi
movl -0xa4(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq -0x148(%rbp), %rdi
movq %rax, -0x190(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq %rax, %rdi
callq 0xa800
movq -0x148(%rbp), %rdi
movq %rax, -0xf0(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq %rax, %rdi
callq 0xa830
movq %rax, -0xf8(%rbp)
movq -0xf0(%rbp), %rdi
movq -0xf8(%rbp), %rsi
callq 0x3e5a0
movq %rax, -0x188(%rbp)
jmp 0x5f3db
movq -0x188(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x3e5e0
movq -0x148(%rbp), %rdi
movl -0xa4(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq %rax, %rdi
callq 0xa830
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x3e5e0
movq -0x190(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0x100(%rbp), %rdx
callq 0x3e510
movq %rax, -0x198(%rbp)
jmp 0x5f455
movq -0x148(%rbp), %rdi
movq -0x198(%rbp), %rax
movq %rax, -0x110(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, %esi
callq 0x3c600
movq %rax, %rdi
callq 0x60e00
jmp 0x5f481
jmp 0x5f483
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x5f1f7
movq -0x148(%rbp), %rax
movl -0x30(%rbp), %ecx
incl %ecx
movl %ecx, 0x60(%rax)
movq %rax, %rdi
addq $0x48, %rdi
movslq 0x60(%rax), %rsi
callq 0xa990
jmp 0x5f4b8
movq -0x148(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movl 0x60(%rax), %eax
addl %eax, %eax
movslq %eax, %rsi
callq 0xaa20
jmp 0x5f4d5
movq -0x148(%rbp), %rdi
movq %rdi, %rax
addq $0x30, %rax
movq %rax, -0x1a0(%rbp)
callq 0x3c4b0
movq -0x1a0(%rbp), %rdi
movq %rax, %rsi
callq 0xa990
jmp 0x5f500
movq -0x148(%rbp), %rax
movq %rax, %rdi
addq $0x68, %rdi
movl 0x60(%rax), %esi
callq 0x72190
jmp 0x5f518
movl $0x0, -0x114(%rbp)
movq -0x148(%rbp), %rdi
movl -0x114(%rbp), %eax
movq %rax, -0x1a8(%rbp)
callq 0x3c4b0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
cmpq %rcx, %rax
jae 0x5f571
movq -0x148(%rbp), %rdi
movl -0x114(%rbp), %esi
callq 0x5f5c0
jmp 0x5f55e
jmp 0x5f560
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x5f522
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq -0x120(%rbp), %rdi
callq 0xcb90
movq -0x130(%rbp), %rdi
callq 0xab00
movq -0x138(%rbp), %rdi
callq 0xab00
movq -0x140(%rbp), %rdi
callq 0xb3b0
movq -0x128(%rbp), %rdi
callq 0xcc00
movq -0x28(%rbp), %rdi
callq 0x4610
nop