// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, -0x50(%rbp)
callq 0x22d0
movsd %xmm0, -0x60(%rbp)
movq 0x8(%rbx), %r13
subq (%rbx), %r13
sarq $0x2, %r13
movq %r13, -0x58(%rbp)
shrq %r13
xorl %r15d, %r15d
leaq -0x38(%rbp), %r12
cmpl %r13d, %r15d
jge 0xabc8
movq (%rbx), %rax
movslq (%rax,%r15,8), %rcx
movl 0x4(%rax,%r15,8), %eax
movl %eax, -0x38(%rbp)
imulq $0x18, %rcx, %rdi
addq (%r14), %rdi
movq %r12, %rsi
callq 0x3b0a
incq %r15
jmp 0xaba0
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0xabd5
movq %rax, 0x8(%rbx)
leaq -0x34(%rbp), %rsi
andl $0x0, (%rsi)
movq %rbx, %rdi
callq 0x3b0a
xorl %eax, %eax
leaq -0x30(%rbp), %r13
movl %eax, -0x2c(%rbp)
movq -0x50(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xac88
movslq %eax, %rcx
movq (%r14), %rdx
imulq $0x18, %rcx, %rcx
movq 0x8(%rdx,%rcx), %rsi
subq (%rdx,%rcx), %rsi
shrq $0x2, %rsi
movl %esi, -0x30(%rbp)
testl %esi, %esi
jle 0xac81
movq %rbx, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x3b0a
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3b0a
xorl %r12d, %r12d
xorl %r15d, %r15d
movslq -0x30(%rbp), %rax
cmpq %rax, %r15
jge 0xac61
movslq -0x2c(%rbp), %rax
movq (%r14), %rcx
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rsi
addq %r12, %rsi
movq %rbx, %rdi
callq 0x3b0a
incq %r15
addq $0x4, %r12
jmp 0xac35
incl -0x34(%rbp)
movslq -0x2c(%rbp), %rax
movq (%r14), %rcx
imulq $0x18, %rax, %rsi
movq (%rcx,%rsi), %rdx
cmpq %rdx, 0x8(%rcx,%rsi)
je 0xac81
addq %rsi, %rcx
movq %rdx, 0x8(%rcx)
incl %eax
jmp 0xabea
movsd -0x58(%rbp), %xmm0
movsd 0x455b(%rip), %xmm1     # 0xf1f0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x4560(%rip), %xmm2     # 0xf200
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movl -0x34(%rbp), %eax
movq (%rbx), %rcx
movl %eax, (%rcx)
movq 0x8(%rbx), %rax
subq %rcx, %rax
sarq $0x2, %rax
movq %rax, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm3, %xmm1
movapd %xmm1, -0x50(%rbp)
callq 0x22d0
subsd -0x60(%rbp), %xmm0
movq 0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq 0x18(%rbp), %rax
movapd -0x50(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq