// File: /workspace/github_cpp_makefile_star2_O3/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, %r15
callq 0x3360
movsd %xmm0, -0x58(%rbp)
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
movq %rsi, %r13
subq %rax, %r13
sarq $0x2, %r13
movq %r13, -0x50(%rbp)
shrq %r13
movl $0x0, -0x2c(%rbp)
testl %r13d, %r13d
jle 0xce30
xorl %r12d, %r12d
movq (%rbx), %rax
movslq (%rax,%r12,8), %rcx
movl 0x4(%rax,%r12,8), %eax
movl %eax, -0x38(%rbp)
movq (%r14), %rdx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rcx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xce14
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xce1d
leaq -0x38(%rbp), %rdx
callq 0x5002
incq %r12
movl %r12d, -0x2c(%rbp)
cmpl %r13d, %r12d
jl 0xcde4
movq (%rbx), %rax
movq 0x8(%rbx), %rsi
cmpq %rax, %rsi
je 0xce3c
movq %rax, 0x8(%rbx)
movq %rax, %rsi
movl $0x0, -0x34(%rbp)
cmpq 0x10(%rbx), %rsi
je 0xce59
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xce65
leaq -0x34(%rbp), %rdx
movq %rbx, %rdi
callq 0x5002
movl $0x0, -0x2c(%rbp)
cmpl $0x0, 0x4(%r15)
jle 0xcf67
movq (%r14), %rcx
xorl %eax, %eax
movslq %eax, %rdx
leaq (%rdx,%rdx,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
subq (%rcx,%rdx,8), %rsi
shrq $0x2, %rsi
movl %esi, -0x30(%rbp)
testl %esi, %esi
jle 0xcf58
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rcx
cmpq %rcx, %rsi
je 0xceb4
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xcec8
movq %rbx, %rdi
leaq -0x2c(%rbp), %rdx
callq 0x5002
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rcx
cmpq %rcx, %rsi
je 0xcedc
movl -0x30(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xceeb
movq %rbx, %rdi
leaq -0x30(%rbp), %rdx
callq 0x5002
movl -0x30(%rbp), %eax
testl %eax, %eax
jle 0xcf37
xorl %r13d, %r13d
xorl %r12d, %r12d
movslq -0x2c(%rbp), %rax
movq (%r14), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rdx
addq %r13, %rdx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xcf1f
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xcf27
movq %rbx, %rdi
callq 0x5002
incq %r12
movslq -0x30(%rbp), %rax
addq $0x4, %r13
cmpq %rax, %r12
jl 0xcef5
incl -0x34(%rbp)
movslq -0x2c(%rbp), %rax
movq (%r14), %rcx
leaq (%rax,%rax,2), %rsi
movq (%rcx,%rsi,8), %rdx
cmpq %rdx, 0x8(%rcx,%rsi,8)
je 0xcf58
leaq (%rcx,%rsi,8), %rsi
movq %rdx, 0x8(%rsi)
incl %eax
movl %eax, -0x2c(%rbp)
cmpl 0x4(%r15), %eax
jl 0xce7c
movsd -0x50(%rbp), %xmm0
movsd 0x52cc(%rip), %xmm1     # 0x12240
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x52d1(%rip), %xmm2     # 0x12250
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 0x3360
subsd -0x58(%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