// File: /workspace/github_cpp_makefile_star2_O2/Laakeri[P]maxpre/src/AMSLEX.cpp
// Function: maxPreprocessor::AMSLEX::amsLexSEPerm(std::vector<int, std::allocator<int>> const&)
vector<int> AMSLEX::amsLexSEPerm(const vector<int>& clauses) {
	vector<vecP> D(clauses.size());
	vector<int> d0Index;
	ALIt++;
	int pid = 0;
	int maxFreq = 0;
	unsigned dataP = 0;
	for (unsigned i = 0; i < clauses.size(); i++) {
		assumeSize(dataP + pi.clauses[clauses[i]].lit.size());
		memcpy(data + dataP, pi.clauses[clauses[i]].lit.data(), pi.clauses[clauses[i]].lit.size()*sizeof(int));
		D[i].B = dataP;
		D[i].E = dataP + pi.clauses[clauses[i]].lit.size();
		D[i].O = clauses[i];
		dataP += D[i].size();
		
		for (unsigned j = D[i].B; j < D[i].E; j++) {
			if ((int)ALU.size() <= data[j]) {
				ALU.resize(data[j] + 1);
				ALI.resize(data[j] + 1);
			}
			if (ALU[data[j]] != ALIt) {
				ALU[data[j]] = ALIt;
				if (pid >= (int)ALF.size()) ALF.resize(pid + 1);
				ALF[pid] = 0;
				ALI[data[j]] = pid++;
			}
			data[j] = ALI[data[j]];
			ALF[data[j]]++;
			maxFreq = max(maxFreq, ALF[data[j]]);
		}
	}
	vector<vector<int> > cSort(maxFreq + 1);
	for (int i = 0; i < pid; i++) {
		cSort[ALF[i]].push_back(i);
	}
	vector<unsigned> perm(pid);
	unsigned i2 = 0;
	for (int i = 0; i <= maxFreq; i++) {
		for (int t : cSort[i]) {
			perm[t] = i2++;
		}
	}
	for (unsigned i = 0; i < D.size(); i++) {
		for (unsigned j = D[i].B; j < D[i].E; j++) {
			data[j] = perm[data[j]];
		}
		sort(data + D[i].B, data + D[i].E);
	}
	auto cmp = [&](vecP a, vecP b) {
		if (getD(a, 0) < getD(b, 0)) return true;
		else if (getD(a, 0) > getD(b, 0)) return false;
		unsigned sz = min(a.size(), b.size());
		for (unsigned i = 1; i < sz; i++) {
			if (getD(a, i) < getD(b, i)) return true;
			else if (getD(a, i) > getD(b, i)) return false;
		}
		return a.size() < b.size();
	};
	vector<vector<vecP> > cSort2(pid);
	for (unsigned i = 0; i < D.size(); i++) {
		cSort2[getD(D[i], 0)].push_back(D[i]);
	}
	unsigned di = 0;
	for (int i = 0; i < pid; i++) {
		sort(cSort2[i].begin(), cSort2[i].end(), cmp);
		for (unsigned j = 0; j < cSort2[i].size(); j++) {
			D[di++] = cSort2[i][j];
		}
	}
	d0Index.resize(pid + 1);
	int idx = 0;
	for (unsigned i = 0; i < D.size(); i++) {
		if (i == 0 || getD(D[i], 0) > getD(D[i - 1], 0)) {
			while (idx <= getD(D[i], 0)) {
				d0Index[idx++] = i;
			}
		}
	}
	while (idx <= pid) {
		d0Index[idx++] = (int)D.size();
	}
	vector<int> subsumed(D.size());
	unsigned S = 0;
	for (unsigned i = 1; i < D.size(); i++) {
		if (D[S].size() <= D[i].size() && isPrefix(D[S], D[i])) {
			subsumed[i] = true;
		}
		else {
			S = i;
		}
	}
	for (unsigned i = 0; i + 1 < D.size(); i++) {
		if (!subsumed[i] && CSO1(D, i + 1, D.size() - 1, D[i], 0, 0, d0Index)) {
			subsumed[i] = true;
		}
	}
	vector<int> ret;
	for (unsigned i = 0; i < D.size(); i++) {
		if (subsumed[i]) ret.push_back(D[i].O);
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, 0xb0(%rsp)
movq 0x8(%rdx), %rsi
subq (%rdx), %rsi
sarq $0x2, %rsi
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rbx
movq %rbx, %rdx
callq 0x2622c
xorps %xmm0, %xmm0
andq $0x0, 0x10(%rbx)
movaps %xmm0, (%rbx)
incl 0x30(%r14)
leaq 0x18(%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0x38(%r14), %rax
movq %rax, 0x10(%rsp)
xorl %ebx, %ebx
xorl %r12d, %r12d
movl $0x0, 0x40(%rsp)
xorl %ebp, %ebp
movq %r15, 0x38(%rsp)
movl %r12d, %r12d
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r12, %rcx
jbe 0x2419a
movq 0x68(%r14), %rcx
movslq (%rax,%r12,4), %rax
movq (%rcx), %rcx
imulq $0x28, %rax, %rax
movq 0x8(%rcx,%rax), %rsi
subq (%rcx,%rax), %rsi
shrq $0x2, %rsi
movl 0x40(%rsp), %r13d
addl %r13d, %esi
movq %r14, %rdi
callq 0x237a8
movq %r15, %rcx
movq %r12, %r15
movl %r13d, %r12d
leaq (,%r12,4), %rdi
addq 0x58(%r14), %rdi
movq 0x68(%r14), %rax
movq (%rcx), %rcx
movslq (%rcx,%r15,4), %rcx
movq (%rax), %rax
imulq $0x28, %rcx, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
subq %rsi, %rdx
callq 0x3250
movq 0x20(%rsp), %rax
movq %r15, %rdi
imulq $0xc, %r15, %r15
movl %r13d, (%rax,%r15)
movq 0x68(%r14), %rcx
movq 0x38(%rsp), %rdx
movq (%rdx), %rdx
movslq (%rdx,%rdi,4), %rsi
movq %rdi, %r8
movq (%rcx), %rcx
imulq $0x28, %rsi, %rsi
movq 0x8(%rcx,%rsi), %rdi
subq (%rcx,%rsi), %rdi
shrq $0x2, %rdi
addl %edi, %r13d
movl %r13d, 0x40(%rsp)
movl %r13d, 0x4(%rax,%r15)
movq %r8, 0xb8(%rsp)
movl (%rdx,%r8,4), %ecx
movl %ecx, 0x8(%rax,%r15)
movl 0x4(%rax,%r15), %eax
cmpq %rax, %r12
jae 0x24185
movq (%r14), %rcx
movq 0x8(%r14), %rsi
subq %rcx, %rsi
shrq $0x2, %rsi
movq 0x58(%r14), %rax
movl (%rax,%r12,4), %edx
cmpl %esi, %edx
jl 0x240f4
movslq %edx, %rsi
incq %rsi
movq %r14, %rdi
callq 0x68c2
movq 0x58(%r14), %rax
movslq (%rax,%r12,4), %rsi
incq %rsi
movq 0x8(%rsp), %rdi
callq 0x68c2
movq (%r14), %rcx
movq 0x58(%r14), %rax
movl (%rax,%r12,4), %edx
movslq %edx, %rdx
movl 0x30(%r14), %esi
cmpl %esi, (%rcx,%rdx,4)
jne 0x24115
movq 0x8(%rsp), %rcx
movq (%rcx), %rsi
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movl %ebp, %r13d
jmp 0x2415e
movl %esi, (%rcx,%rdx,4)
movq 0x38(%r14), %rcx
movq 0x40(%r14), %rdx
subq %rcx, %rdx
shrq $0x2, %rdx
leal 0x1(%rbp), %r13d
cmpl %edx, %ebp
jl 0x24144
movslq %r13d, %rsi
movq 0x10(%rsp), %rdi
callq 0x68c2
movq 0x38(%r14), %rcx
movq 0x58(%r14), %rax
movslq %ebp, %rdx
andl $0x0, (%rcx,%rdx,4)
movslq (%rax,%r12,4), %rdx
movq 0x8(%rsp), %rsi
movq (%rsi), %rsi
movl %ebp, (%rsi,%rdx,4)
movslq (%rax,%r12,4), %rdx
movslq (%rsi,%rdx,4), %rdx
movl %edx, (%rax,%r12,4)
incl (%rcx,%rdx,4)
movslq (%rax,%r12,4), %rax
movl (%rcx,%rax,4), %eax
cmpl %eax, %ebx
cmovlel %eax, %ebx
incq %r12
movq 0x20(%rsp), %rax
movl %r13d, %ebp
jmp 0x2409e
movq 0xb8(%rsp), %r12
incl %r12d
movq 0x38(%rsp), %r15
jmp 0x23fcb
leal 0x1(%rbx), %esi
leaq 0xc0(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x19232
xorl %eax, %eax
leaq 0x48(%rsp), %r12
movl %eax, 0x48(%rsp)
cmpl %ebp, %eax
jge 0x241e8
cltq
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movslq (%rcx,%rax,4), %rax
imulq $0x18, %rax, %rdi
addq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x68a4
movl 0x48(%rsp), %eax
incl %eax
jmp 0x241b6
movslq %ebp, %r15
leaq 0x48(%rsp), %rdi
leaq 0x98(%rsp), %rdx
movq %r15, %rsi
callq 0x2627e
movq 0xc0(%rsp), %rax
movl %ebx, %ecx
xorl %edx, %edx
xorl %esi, %esi
cmpq %rcx, %rdx
ja 0x2423e
imulq $0x18, %rdx, %r8
movq (%rax,%r8), %rdi
movq 0x8(%rax,%r8), %r8
movq 0x48(%rsp), %r9
cmpq %r8, %rdi
je 0x24239
movslq (%rdi), %r10
movl %esi, (%r9,%r10,4)
incl %esi
addq $0x4, %rdi
jmp 0x24225
incq %rdx
jmp 0x2420e
xorl %ebx, %ebx
pushq $0xc
popq %r12
movl %ebx, %ebx
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rax
subq %rcx, %rax
cqto
idivq %r12
cmpq %rbx, %rax
jbe 0x242a0
imulq $0xc, %rbx, %rdx
leaq (%rcx,%rdx), %rax
movl (%rcx,%rdx), %ecx
movq 0x58(%r14), %rdx
movq 0x48(%rsp), %rsi
movl 0x4(%rax), %r8d
cmpq %r8, %rcx
jae 0x24289
movslq (%rdx,%rcx,4), %rdi
movl (%rsi,%rdi,4), %edi
movl %edi, (%rdx,%rcx,4)
incq %rcx
jmp 0x24271
movq 0x58(%r14), %rcx
movl (%rax), %eax
leaq (%rcx,%rax,4), %rdi
leaq (%rcx,%r8,4), %rsi
callq 0x2659f
incl %ebx
jmp 0x24244
leaq 0x98(%rsp), %rdi
leaq 0x80(%rsp), %rdx
movq %r15, %rsi
callq 0x262d0
xorl %ebx, %ebx
movl %ebx, %ebx
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rax
subq %rcx, %rax
cqto
idivq %r12
cmpq %rbx, %rax
jbe 0x242fb
movq 0x58(%r14), %rax
imulq $0xc, %rbx, %rdx
leaq (%rcx,%rdx), %rsi
movl (%rcx,%rdx), %ecx
movslq (%rax,%rcx,4), %rax
imulq $0x18, %rax, %rdi
addq 0x98(%rsp), %rdi
callq 0x26322
incl %ebx
jmp 0x242ba
movq %r15, 0x38(%rsp)
xorl %edx, %edx
testl %ebp, %ebp
movl $0x0, %eax
cmovgl %ebp, %eax
movq %rax, 0x40(%rsp)
xorl %r15d, %r15d
cmpq 0x40(%rsp), %rdx
je 0x24411
movq 0x98(%rsp), %rax
movq %rdx, 0x8(%rsp)
imulq $0x18, %rdx, %rbx
movq (%rax,%rbx), %rdi
movq 0x8(%rax,%rbx), %r12
cmpq %r12, %rdi
je 0x243b2
movq %r12, %r13
subq %rdi, %r13
movq %r13, %rax
cqto
pushq $0xc
popq %rcx
idivq %rcx
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rdi, 0x10(%rsp)
movq %r12, %rsi
movq %r14, %rcx
callq 0x256f0
cmpq $0xc1, %r13
jl 0x243a2
movq 0x10(%rsp), %rdi
leaq 0xc0(%rdi), %r13
movq %r13, %rsi
movq %r14, %rdx
callq 0x25b8d
cmpq %r12, %r13
je 0x243b2
movq %r13, %rdi
movq %r14, %rsi
callq 0x25c3e
addq $0xc, %r13
jmp 0x2438c
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x25b8d
xorl %esi, %esi
pushq $0xc
popq %r12
movl %esi, %ecx
movq 0x98(%rsp), %rax
movq (%rax,%rbx), %rdi
movq 0x8(%rax,%rbx), %rax
subq %rdi, %rax
cqto
idivq %r12
cmpq %rcx, %rax
jbe 0x24401
addl %r15d, %esi
imulq $0xc, %rcx, %rax
movl %esi, %edx
movq 0x20(%rsp), %rsi
imulq $0xc, %rdx, %rdx
movl 0x8(%rdi,%rax), %r8d
movl %r8d, 0x8(%rsi,%rdx)
movq (%rdi,%rax), %rax
movq %rax, (%rsi,%rdx)
leal 0x1(%rcx), %esi
jmp 0x243b8
movq 0x8(%rsp), %rdx
incq %rdx
addl %ecx, %r15d
jmp 0x24314
incl %ebp
movslq %ebp, %rsi
leaq 0x60(%rsp), %rdi
callq 0x68c2
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rax
subq %rcx, %rax
cqto
idivq %r12
movq 0x58(%r14), %rsi
xorl %edx, %edx
xorl %edi, %edi
movq 0x38(%rsp), %r11
movl %edi, %r8d
cmpq %r8, %rax
jbe 0x24491
testl %edi, %edi
je 0x24469
imulq $0xc, %r8, %r9
movl (%rcx,%r9), %r9d
movl (%rsi,%r9,4), %r9d
leal -0x1(%rdi), %r10d
imulq $0xc, %r10, %r10
movl (%rcx,%r10), %r10d
cmpl (%rsi,%r10,4), %r9d
jle 0x2448d
imulq $0xc, %r8, %r8
addq %rcx, %r8
movq 0x60(%rsp), %r9
movslq %edx, %rdx
movl (%r8), %r10d
movslq (%rsi,%r10,4), %r10
cmpq %r10, %rdx
jg 0x2448d
movl %edi, (%r9,%rdx,4)
incq %rdx
jmp 0x24478
incl %edi
jmp 0x2443f
movslq %edx, %rcx
movq 0x60(%rsp), %rdx
cmpq %r11, %rcx
jg 0x244a6
movl %eax, (%rdx,%rcx,4)
incq %rcx
jmp 0x24499
leaq 0x80(%rsp), %rdi
leaq 0x1c(%rsp), %rdx
movq %rax, %rsi
callq 0x6852
movq 0x20(%rsp), %r13
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
subq %r13, %rax
cqto
idivq %r12
movq %rax, %r12
pushq $0x1
popq %rbx
xorl %r15d, %r15d
movq 0x80(%rsp), %rax
movq %rax, 0x8(%rsp)
movl %ebx, %ebp
cmpq %rbp, %r12
jbe 0x24544
movl %r15d, %eax
imulq $0xc, %rax, %rax
movl 0x4(%r13,%rax), %esi
subl (%r13,%rax), %esi
imulq $0xc, %rbp, %rcx
movl 0x4(%r13,%rcx), %edi
subl (%r13,%rcx), %edi
movl %ebx, %edx
cmpl %edi, %esi
ja 0x2453d
addq %r13, %rax
addq %r13, %rcx
movq (%rax), %rsi
movq (%rcx), %rcx
movq %r14, %rdi
callq 0x23812
movl %ebx, %edx
testb %al, %al
je 0x2453d
movq 0x8(%rsp), %rax
movl $0x1, (%rax,%rbp,4)
movl %r15d, %edx
incl %ebx
movl %edx, %r15d
jmp 0x244e8
movq 0x80(%rsp), %r15
leal -0x1(%r12), %eax
movl %eax, 0x8(%rsp)
xorl %ecx, %ecx
leal 0x1(%rcx), %ebx
cmpq %rbx, %r12
jbe 0x245af
movl %ecx, %ebp
cmpl $0x0, (%r15,%rbp,4)
movl %ebx, %ecx
jne 0x24557
imulq $0xc, %rbp, %rax
movq (%r13,%rax), %r8
movl 0x8(%r13,%rax), %r9d
subq $0x8, %rsp
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
movl %ebx, %edx
movl 0x10(%rsp), %ecx
leaq 0x68(%rsp), %rax
pushq %rax
pushq $0x0
pushq $0x0
callq 0x23848
addq $0x20, %rsp
movl %ebx, %ecx
testb %al, %al
je 0x24557
movl $0x1, (%r15,%rbp,4)
movl %ebx, %ecx
jmp 0x24557
movq 0xb0(%rsp), %r15
andq $0x0, 0x10(%r15)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
xorl %ebx, %ebx
leaq 0x1c(%rsp), %r14
pushq $0xc
popq %r12
movq 0x10(%rsp), %rcx
movl %ebx, %ebx
movq %rcx, %rax
subq %r13, %rax
cqto
idivq %r12
cmpq %rbx, %rax
jbe 0x24619
movq 0x80(%rsp), %rax
cmpl $0x0, (%rax,%rbx,4)
je 0x24615
imulq $0xc, %rbx, %rax
movl 0x8(%r13,%rax), %eax
movl %eax, 0x1c(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x19ed4
movq 0x20(%rsp), %r13
movq 0x28(%rsp), %rcx
incl %ebx
jmp 0x245d3
leaq 0x80(%rsp), %rdi
callq 0x7512
leaq 0x98(%rsp), %rdi
callq 0x26346
leaq 0x48(%rsp), %rdi
callq 0x264c8
leaq 0xc0(%rsp), %rdi
callq 0x6aa2
leaq 0x60(%rsp), %rdi
callq 0x7512
leaq 0x20(%rsp), %rdi
callq 0x2639a
movq %r15, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x24697
jmp 0x24697
jmp 0x246a9
jmp 0x246b8
jmp 0x246ca
movq %rax, %r14
movq %r15, %rdi
callq 0x7512
leaq 0x80(%rsp), %rdi
callq 0x7512
jmp 0x2469a
movq %rax, %r14
leaq 0x98(%rsp), %rdi
callq 0x26346
jmp 0x246ac
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x264c8
jmp 0x246bb
movq %rax, %r14
leaq 0xc0(%rsp), %rdi
callq 0x6aa2
jmp 0x246cd
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0x7512
leaq 0x20(%rsp), %rdi
callq 0x2639a
movq %r14, %rdi
callq 0x3490
nop