// File: /workspace/github_cpp_makefile_star2_O1/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 0x8(%rbx), %r13
subq (%rbx), %r13
sarq $0x2, %r13
movq %r13, -0x50(%rbp)
shrq %r13
movl $0x0, -0x2c(%rbp)
testl %r13d, %r13d
jle 0xce55
xorl %eax, %eax
leaq -0x38(%rbp), %r12
leal (%rax,%rax), %ecx
movslq %ecx, %rcx
movq (%rbx), %rdx
movslq (%rdx,%rcx,4), %rcx
leal 0x1(,%rax,2), %eax
cltq
movl (%rdx,%rax,4), %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 0xce40
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xce48
movq %r12, %rdx
callq 0x50ac
movl -0x2c(%rbp), %eax
incl %eax
movl %eax, -0x2c(%rbp)
cmpl %r13d, %eax
jl 0xce03
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0xce62
movq %rax, 0x8(%rbx)
movl $0x0, -0x34(%rbp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xce83
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xce8f
leaq -0x34(%rbp), %rdx
movq %rbx, %rdi
callq 0x50ac
movl $0x0, -0x2c(%rbp)
cmpl $0x0, 0x4(%r15)
jle 0xcf8d
xorl %eax, %eax
movslq %eax, %rcx
movq (%r14), %rdx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rdx,%rcx,8), %rsi
subq (%rdx,%rcx,8), %rsi
shrq $0x2, %rsi
movl %esi, -0x30(%rbp)
testl %esi, %esi
jle 0xcf7b
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xcedb
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xcee7
movq %rbx, %rdi
leaq -0x2c(%rbp), %rdx
callq 0x50ac
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xcf00
movl -0x30(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xcf0c
movq %rbx, %rdi
leaq -0x30(%rbp), %rdx
callq 0x50ac
cmpl $0x0, -0x30(%rbp)
jle 0xcf5a
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 0xcf42
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xcf4a
movq %rbx, %rdi
callq 0x50ac
incq %r12
movslq -0x30(%rbp), %rax
addq $0x4, %r13
cmpq %rax, %r12
jl 0xcf18
incl -0x34(%rbp)
movslq -0x2c(%rbp), %rcx
movq (%r14), %rax
leaq (%rcx,%rcx,2), %rdx
movq (%rax,%rdx,8), %rcx
cmpq %rcx, 0x8(%rax,%rdx,8)
je 0xcf7b
leaq (%rax,%rdx,8), %rax
movq %rcx, 0x8(%rax)
movl -0x2c(%rbp), %eax
incl %eax
movl %eax, -0x2c(%rbp)
cmpl 0x4(%r15), %eax
jl 0xcea3
movsd -0x50(%rbp), %xmm0
movsd 0x52a6(%rip), %xmm1     # 0x12240
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x52ab(%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