// File: ADAPTLab[P]MuDBSCAN/clustering.cpp
// Function: trivial_compression(dataHdr*, std::vector<int, std::allocator<int>>*, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>*, int, int, int, double&, double&)
void trivial_compression(DataHdr dataList, vector <int>* data, vector < vector <int> >* parser, int nproc, int rank, int round, double& comtime, double& sum_comp_rate)
{
	double start = MPI_Wtime();
	double org = 0, comp = 0;
	int pairs, pid, npid, i, j, pid_count, npid_count;

	pairs = (*data).size()/2;

	org = (*data).size();		

	for(i = 0; i < pairs; i++)
	{
		pid = (*data)[2 * i];
		npid = (*data)[2 * i + 1];

		(*parser)[pid].push_back(npid);
	}

	(*data).clear();

	pid_count = 0;
	(*data).push_back(pid_count); // uniques pids, should update later
		
	for(i = 0; i < dataList->localCnt; i++)
	{
		npid_count = (*parser)[i].size();
		if(npid_count > 0)
		{
			(*data).push_back(i);
			(*data).push_back(npid_count);

			for(j = 0; j < npid_count; j++)
				(*data).push_back((*parser)[i][j]);						 
			
			pid_count++;

			(*parser)[i].clear();
		}
	}
		
	(*data)[0] = pid_count;

	comp = (*data).size();
	
	double stop = MPI_Wtime();
	comtime += (stop - start);

	sum_comp_rate += (comp / org);
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
callq 0x9880
movsd %xmm0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x11f90
shrq %rax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
callq 0x11f90
movq %rax, %xmm0
movaps 0x8568(%rip), %xmm1     # 0x2c2d0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x856c(%rip), %xmm1     # 0x2c2e0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x23dea
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %eax
shll %eax
movslq %eax, %rsi
callq 0x1c1b0
movl (%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movl -0x50(%rbp), %eax
shll %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x1c1b0
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x48(%rbp), %rsi
callq 0x11a90
movq %rax, %rdi
leaq -0x4c(%rbp), %rsi
callq 0x11ab0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x23d8f
movq -0x10(%rbp), %rdi
callq 0x1c0e0
movl $0x0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x11ab0
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x23ecb
movq -0x18(%rbp), %rdi
movslq -0x50(%rbp), %rsi
callq 0x11a90
movq %rax, %rdi
callq 0x11f90
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jle 0x23ebb
movq -0x10(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x11ab0
movq -0x10(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x11ab0
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x23e9d
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x50(%rbp), %rsi
callq 0x11a90
movq %rax, %rdi
movslq -0x54(%rbp), %rsi
callq 0x1c1b0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x11ab0
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x23e5d
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x50(%rbp), %rsi
callq 0x11a90
movq %rax, %rdi
callq 0x1c0e0
jmp 0x23ebd
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x23e0e
movl -0x58(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1c1b0
movl -0x74(%rbp), %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
callq 0x11f90
movq %rax, %xmm0
movaps 0x83d8(%rip), %xmm1     # 0x2c2d0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x83dc(%rip), %xmm1     # 0x2c2e0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x9880
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
movq 0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
divsd -0x38(%rbp), %xmm0
movq 0x18(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)