// File: jingdao[P]PointCloudApp/pcd.cpp
// Function: PCD::getCentroid(std::vector<int, std::allocator<int>>*)
PCD::Quaternion PCD::getCentroid(std::vector<int> *indices) {
	float sumX=0, sumY=0, sumZ=0;
	if (indices) {
		for (size_t i=0;i<indices->size();i++) {
			sumX += float_data[(*indices)[i] * 4];
			sumY += float_data[(*indices)[i] * 4 + 1];
			sumZ += float_data[(*indices)[i] * 4 + 2];
		}
	} else {
		for (int i=0;i<numPoints;i++) {
			sumX += float_data[i * 4];
			sumY += float_data[i * 4 + 1];
			sumZ += float_data[i * 4 + 2];
		}
	}
	Quaternion q = {0, sumX / numPoints, sumY / numPoints, sumZ / numPoints};
	return q;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x8b22
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
callq 0xaca0
movq %rax, %rcx
movq -0x50(%rbp), %rax
cmpq %rcx, %rax
jae 0x8b20
movq -0x48(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xacc0
movq -0x68(%rbp), %rcx
movq %rax, %rdx
movq -0x48(%rbp), %rax
movl (%rdx), %edx
shll $0x2, %edx
movslq %edx, %rdx
movss (%rcx,%rdx,4), %xmm0
addss -0x24(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
movq 0x58(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xacc0
movq -0x60(%rbp), %rcx
movq %rax, %rdx
movq -0x48(%rbp), %rax
movl (%rdx), %edx
shll $0x2, %edx
addl $0x1, %edx
movslq %edx, %rdx
movss (%rcx,%rdx,4), %xmm0
addss -0x28(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
movq 0x58(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xacc0
movq %rax, %rcx
movq -0x58(%rbp), %rax
movl (%rcx), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
addss -0x2c(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x8a43
jmp 0x8ba0
movl $0x0, -0x3c(%rbp)
movq -0x48(%rbp), %rcx
movl -0x3c(%rbp), %eax
cmpl 0x60(%rcx), %eax
jge 0x8b9e
movq -0x48(%rbp), %rax
movq 0x58(%rax), %rcx
movl -0x3c(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movss (%rcx,%rdx,4), %xmm0
addss -0x24(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
movq 0x58(%rax), %rcx
movl -0x3c(%rbp), %edx
shll $0x2, %edx
addl $0x1, %edx
movslq %edx, %rdx
movss (%rcx,%rdx,4), %xmm0
addss -0x28(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
movq 0x58(%rax), %rax
movl -0x3c(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
addss -0x2c(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8b29
jmp 0x8ba0
movq -0x48(%rbp), %rax
movl $0x0, -0x10(%rbp)
movss -0x24(%rbp), %xmm0
cvtsi2ssl 0x60(%rax), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0xc(%rbp)
movss -0x28(%rbp), %xmm0
cvtsi2ssl 0x60(%rax), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x8(%rbp)
movss -0x2c(%rbp), %xmm0
cvtsi2ssl 0x60(%rax), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x4(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x8(%rbp), %xmm1
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)