// File: Laakeri[P]maxpre/src/preprocessor.cpp
// Function: maxPreprocessor::Preprocessor::removeDuplicateClauses()
int Preprocessor::removeDuplicateClauses() {
	int removed = 0;
	vector<int> checkLit = pi.tl.getModLiterals("DPCLRM");
	vector<pair<uint64_t, int> > has;
	if ((int)checkLit.size() > pi.vars/2) { // magic constant
		for (int c = 0; c < (int)pi.clauses.size(); c++) {
			if (!pi.isClauseRemoved(c)) {
				if (pi.clauses[c].lit.size() == 0) {
					if (!pi.clauses[c].isHard()) {
						trace.removeWeight(pi.clauses[c].weight);
						pi.removeClause(c);
					}
				}
				else {
					if (pi.clauses[c].isHard()) {
						uint64_t h = 0;
						for (int l : pi.clauses[c].lit) {
							h *= polyHashMul;
							h += (uint64_t)(l + 1);
						}
						has.push_back({h, c});
					}
				}
			}
		}
		sort(has.begin(), has.end());
		for (unsigned i = 1; i < has.size(); i++) {
			if (has[i].F == has[i - 1].F) {
				if (pi.clauses[has[i].S].lit == pi.clauses[has[i - 1].S].lit) {
					pi.removeClause(has[i].S);
					removed++;
				}
			}
		}
	}
	else {
		for (int lit : checkLit) {
			has.clear();
			for (int c : pi.litClauses[lit]) {
				if (pi.clauses[c].isHard()) {
					uint64_t h = 0;
					for (int l : pi.clauses[c].lit) {
						h *= polyHashMul;
						h += (uint64_t)(l + 1);
					}
					has.push_back({h, c});
				}
			}
			sort(has.begin(), has.end());
			for (unsigned i = 1; i < has.size(); i++) {
				if (has[i].F == has[i - 1].F) {
					if (pi.clauses[has[i].S].lit == pi.clauses[has[i - 1].S].lit) {
						pi.removeClause(has[i].S);
						removed++;
					}
				}
			}
		}
	}
	return removed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x178(%rbp)
movl $0x0, -0xc(%rbp)
addq $0x68, %rax
movq %rax, -0x170(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x4620
movq -0x168(%rbp), %rdx
leaq 0x731f5(%rip), %rsi     # 0x863cf
leaq -0x48(%rbp), %rdi
callq 0xa430
jmp 0x131e5
movq -0x170(%rbp), %rsi
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rdx
callq 0x73130
jmp 0x131fb
leaq -0x48(%rbp), %rdi
callq 0x4240
leaq -0x49(%rbp), %rdi
callq 0x43f0
leaq -0x78(%rbp), %rdi
callq 0x3ca30
leaq -0x28(%rbp), %rdi
callq 0xf940
movq %rax, %rcx
movq -0x178(%rbp), %rax
movl %ecx, -0x17c(%rbp)
movl 0x60(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x17c(%rbp), %eax
cmpl %ecx, %eax
jle 0x13630
movl $0x0, -0x7c(%rbp)
movq -0x178(%rbp), %rdi
movl -0x7c(%rbp), %eax
movl %eax, -0x180(%rbp)
callq 0x3c4b0
movq %rax, %rcx
movl -0x180(%rbp), %eax
cmpl %ecx, %eax
jge 0x134ba
movq -0x178(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x5eb70
movb %al, -0x181(%rbp)
jmp 0x1328e
movb -0x181(%rbp), %al
testb $0x1, %al
jne 0x134aa
jmp 0x1329e
movq -0x178(%rbp), %rdi
movslq -0x7c(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0xf940
cmpq $0x0, %rax
jne 0x1338e
movq -0x178(%rbp), %rdi
movslq -0x7c(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0x60e90
movb %al, -0x182(%rbp)
jmp 0x132e0
movb -0x182(%rbp), %al
testb $0x1, %al
jne 0x13389
jmp 0x132f0
movq -0x178(%rbp), %rdi
movq %rdi, %rax
addq $0x2f0, %rax            # imm = 0x2F0
movq %rax, -0x190(%rbp)
movslq -0x7c(%rbp), %rsi
callq 0x3c600
movq -0x190(%rbp), %rdi
movq 0x18(%rax), %rsi
callq 0x5cae0
jmp 0x13322
movq -0x178(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x5f7f0
jmp 0x13333
jmp 0x13389
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x13358
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4240
leaq -0x49(%rbp), %rdi
callq 0x43f0
jmp 0x139f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3cc30
leaq -0x28(%rbp), %rdi
callq 0xab00
jmp 0x139f2
jmp 0x134a8
movq -0x178(%rbp), %rdi
movslq -0x7c(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0x60e90
movb %al, -0x191(%rbp)
jmp 0x133ae
movb -0x191(%rbp), %al
testb $0x1, %al
jne 0x133bd
jmp 0x134a6
movq -0x178(%rbp), %rdi
movq $0x0, -0x88(%rbp)
movslq -0x7c(%rbp), %rsi
callq 0x3c600
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0xa800
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rdi
callq 0xa830
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x1341e
jmp 0x13479
leaq -0x98(%rbp), %rdi
callq 0xa8a0
movq %rax, %rcx
movq -0x178(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0xa4(%rbp)
movq 0x328(%rax), %rax
imulq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
cltq
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xa930
jmp 0x13405
leaq -0xb8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x7c(%rbp), %rdx
callq 0x3ca80
jmp 0x13492
leaq -0x78(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x3ca50
jmp 0x134a4
jmp 0x134a6
jmp 0x134a8
jmp 0x134aa
jmp 0x134ac
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x13251
leaq -0x78(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x3caf0
movq -0x1a0(%rbp), %rdi
movq %rax, -0xc0(%rbp)
callq 0x3cb20
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0x3cab0
jmp 0x134f9
movl $0x1, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
movq %rax, -0x1a8(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3cb50
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
cmpq %rcx, %rax
jae 0x1362b
movl -0xcc(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x3cb70
movq (%rax), %rax
movq %rax, -0x1b0(%rbp)
movl -0xcc(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x3cb70
movq %rax, %rcx
movq -0x1b0(%rbp), %rax
cmpq (%rcx), %rax
jne 0x13615
movl -0xcc(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x3cb70
movq -0x178(%rbp), %rdi
movslq 0x8(%rax), %rsi
callq 0x3c600
movq -0x1c8(%rbp), %rdi
movq %rax, -0x1c0(%rbp)
movl -0xcc(%rbp), %eax
decl %eax
movl %eax, %esi
callq 0x3cb70
movq -0x178(%rbp), %rdi
movslq 0x8(%rax), %rsi
callq 0x3c600
movq -0x1c0(%rbp), %rdi
movq %rax, %rsi
callq 0x3cb90
movb %al, -0x1b1(%rbp)
jmp 0x135dc
movb -0x1b1(%rbp), %al
testb $0x1, %al
jne 0x135e8
jmp 0x13613
movl -0xcc(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x3cb70
movq -0x178(%rbp), %rdi
movl 0x8(%rax), %esi
callq 0x5f7f0
jmp 0x1360a
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x13615
jmp 0x13617
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x13503
jmp 0x139c8
leaq -0x28(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rdi
callq 0xa800
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rdi
callq 0xa830
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x1367d
jmp 0x139c6
leaq -0xe0(%rbp), %rdi
callq 0xa8a0
movl (%rax), %eax
movl %eax, -0xec(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3cc10
movq -0x178(%rbp), %rdi
addq $0x18, %rdi
movslq -0xec(%rbp), %rsi
callq 0xaab0
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rdi
callq 0xa800
movq %rax, -0x100(%rbp)
movq -0xf8(%rbp), %rdi
callq 0xa830
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x136fa
jmp 0x13842
leaq -0x100(%rbp), %rdi
callq 0xa8a0
movq -0x178(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x10c(%rbp)
movslq -0x10c(%rbp), %rsi
callq 0x3c600
movq %rax, %rdi
callq 0x60e90
movb %al, -0x1c9(%rbp)
jmp 0x13731
movb -0x1c9(%rbp), %al
testb $0x1, %al
jne 0x13740
jmp 0x1382f
movq -0x178(%rbp), %rdi
movq $0x0, -0x118(%rbp)
movslq -0x10c(%rbp), %rsi
callq 0x3c600
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rdi
callq 0xa800
movq %rax, -0x128(%rbp)
movq -0x120(%rbp), %rdi
callq 0xa830
movq %rax, -0x130(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0xa860
testb $0x1, %al
jne 0x137a4
jmp 0x137ff
leaq -0x128(%rbp), %rdi
callq 0xa8a0
movq %rax, %rcx
movq -0x178(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x134(%rbp)
movq 0x328(%rax), %rax
imulq -0x118(%rbp), %rax
movq %rax, -0x118(%rbp)
movl -0x134(%rbp), %eax
addl $0x1, %eax
cltq
addq -0x118(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x128(%rbp), %rdi
callq 0xa930
jmp 0x1378b
leaq -0x148(%rbp), %rdi
leaq -0x118(%rbp), %rsi
leaq -0x10c(%rbp), %rdx
callq 0x3ca80
jmp 0x1381b
leaq -0x78(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x3ca50
jmp 0x1382d
jmp 0x1382f
jmp 0x13831
leaq -0x100(%rbp), %rdi
callq 0xa930
jmp 0x136de
leaq -0x78(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x3caf0
movq -0x1d8(%rbp), %rdi
movq %rax, -0x150(%rbp)
callq 0x3cb20
movq %rax, -0x158(%rbp)
movq -0x150(%rbp), %rdi
movq -0x158(%rbp), %rsi
callq 0x3cab0
jmp 0x13881
movl $0x1, -0x15c(%rbp)
movl -0x15c(%rbp), %eax
movq %rax, -0x1e0(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3cb50
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
cmpq %rcx, %rax
jae 0x139b3
movl -0x15c(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x3cb70
movq (%rax), %rax
movq %rax, -0x1e8(%rbp)
movl -0x15c(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x3cb70
movq %rax, %rcx
movq -0x1e8(%rbp), %rax
cmpq (%rcx), %rax
jne 0x1399d
movl -0x15c(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x3cb70
movq -0x178(%rbp), %rdi
movslq 0x8(%rax), %rsi
callq 0x3c600
movq -0x200(%rbp), %rdi
movq %rax, -0x1f8(%rbp)
movl -0x15c(%rbp), %eax
decl %eax
movl %eax, %esi
callq 0x3cb70
movq -0x178(%rbp), %rdi
movslq 0x8(%rax), %rsi
callq 0x3c600
movq -0x1f8(%rbp), %rdi
movq %rax, %rsi
callq 0x3cb90
movb %al, -0x1e9(%rbp)
jmp 0x13964
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0x13970
jmp 0x1399b
movl -0x15c(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x3cb70
movq -0x178(%rbp), %rdi
movl 0x8(%rax), %esi
callq 0x5f7f0
jmp 0x13992
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1399d
jmp 0x1399f
movl -0x15c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x15c(%rbp)
jmp 0x1388b
jmp 0x139b5
leaq -0xe0(%rbp), %rdi
callq 0xa930
jmp 0x13661
jmp 0x139c8
movl -0xc(%rbp), %eax
movl %eax, -0x204(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3cc30
leaq -0x28(%rbp), %rdi
callq 0xab00
movl -0x204(%rbp), %eax
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x4610
nopl (%rax,%rax)