// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/sphere_approx.cc
// Function: AtomCluster::calc_center(std::vector<ATOM, std::allocator<ATOM>>, int, int, int, int, int, double)
ATOM AtomCluster::calc_center(vector <ATOM> old_coords, int i_0, int i_1, int i_2, int i_3, int i_4, double shift){
	ATOM origin = center;

	vector <ATOM> coords;

	coords.push_back(old_coords.at(i_0));
	coords.push_back(old_coords.at(i_1));
	coords.push_back(old_coords.at(i_2));
	coords.push_back(old_coords.at(i_3));
	coords.push_back(old_coords.at(i_4));

	double x_sum = 0;
	double y_sum = 0;
	double z_sum = 0;
	for (int i = 0; i<coords.size(); i++){
		x_sum = x_sum + coords.at(i).x;
		y_sum = y_sum + coords.at(i).y;
		z_sum = z_sum + coords.at(i).z;
	}

	double n = coords.size();

	ATOM center_sphere;

//translation vector
	double x = (x_sum/n)-origin.x;
	double y = (y_sum/n)-origin.y;
	double z = (z_sum/n)-origin.z;
	
	double norm = sqrt(x*x + y*y + z*z);
	double scaled_shift = shift/norm;

	center_sphere.x = x*scaled_shift + origin.x;
	center_sphere.y = y*scaled_shift + origin.y;
	center_sphere.z = z*scaled_shift + origin.z;
	center_sphere.radius = smallSphereRadius;

	return center_sphere;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movaps %xmm0, 0x30(%rsp)
movl %r9d, %ebp
movl %r8d, %r12d
movl %ecx, %r13d
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movupd 0xa0(%rsi), %xmm0
movupd 0xb0(%rsi), %xmm1
movupd 0xc0(%rsi), %xmm2
movups 0xd0(%rsi), %xmm3
leaq 0x80(%rsp), %rdi
movaps %xmm3, -0x10(%rdi)
movapd %xmm2, -0x20(%rdi)
movapd %xmm1, -0x30(%rdi)
movapd %xmm0, -0x40(%rdi)
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0xe0(%rsi), %rsi
movq 0xe8(%r14), %rdx
addq %rsi, %rdx
callq 0xf3ce
leaq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x100(%r14), %rsi
movq 0x108(%r14), %rdx
addq %rsi, %rdx
callq 0xf3ce
movb 0x130(%r14), %al
movb %al, 0xd0(%rsp)
movupd 0x120(%r14), %xmm0
movapd %xmm0, 0xc0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movslq %r13d, %rsi
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %r13 # imm = 0x86BCA1AF286BCA1B
imulq %r13, %rdx
cmpq %rsi, %rdx
jbe 0x929d0
imulq $0x98, %rsi, %rcx
addq %rcx, %rax
movq %rsp, %rdi
movq %rax, %rsi
callq 0xe9a8
movslq %r12d, %rsi
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %rsi, %rdx
jbe 0x929d0
imulq $0x98, %rsi, %rcx
addq %rcx, %rax
movq %rsp, %rdi
movq %rax, %rsi
callq 0xe9a8
movslq %ebp, %rsi
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %rsi, %rdx
jbe 0x929d0
imulq $0x98, %rsi, %rcx
addq %rcx, %rax
movq %rsp, %rdi
movq %rax, %rsi
callq 0xe9a8
movslq 0x110(%rsp), %rsi
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %rsi, %rdx
jbe 0x929d0
imulq $0x98, %rsi, %rcx
addq %rcx, %rax
movq %rsp, %rdi
movq %rax, %rsi
callq 0xe9a8
movslq 0x118(%rsp), %rsi
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %rsi, %rdx
jbe 0x929d0
imulq $0x98, %rsi, %rcx
addq %rcx, %rax
movq %rsp, %rdi
movq %rax, %rsi
callq 0xe9a8
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, %r15
subq %rax, %r15
sarq $0x3, %r15
imulq %r13, %r15
cmpq %rax, %rcx
je 0x928c0
cmpq $0x1, %r15
movq %r15, %rcx
adcq $0x0, %rcx
addq $0x10, %rax
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
movupd -0x10(%rax), %xmm0
addpd %xmm0, %xmm2
addsd (%rax), %xmm1
addq $0x98, %rax
decq %rcx
jne 0x928a6
jmp 0x928c8
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
movapd %xmm2, 0x20(%rsp)
movsd %xmm1, 0x18(%rsp)
movq %rbx, %rdi
callq 0x51264
xorps %xmm1, %xmm1
cvtsi2sd %r15, %xmm1
movsd 0x18(%rsp), %xmm4
divsd %xmm1, %xmm4
movsd 0x50(%rsp), %xmm0
subsd %xmm0, %xmm4
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
movapd 0x20(%rsp), %xmm5
divpd %xmm1, %xmm5
movapd 0x40(%rsp), %xmm1
subpd %xmm1, %xmm5
movapd %xmm5, %xmm2
mulpd %xmm5, %xmm2
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
movapd %xmm5, %xmm3
mulsd %xmm5, %xmm3
addsd %xmm2, %xmm3
movapd %xmm4, %xmm2
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
sqrtsd %xmm2, %xmm2
movapd 0x30(%rsp), %xmm3
divsd %xmm2, %xmm3
mulsd %xmm3, %xmm4
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
mulpd %xmm5, %xmm3
addpd %xmm1, %xmm3
movupd %xmm3, (%rbx)
addsd %xmm0, %xmm4
movsd %xmm4, 0x10(%rbx)
movsd (%r14), %xmm0
movsd %xmm0, 0x30(%rbx)
movq %rsp, %rdi
callq 0xf2da
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x92996
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x929bb
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4470
movq %rbx, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbad1e(%rip), %rdi     # 0x14d6f5
xorl %eax, %eax
callq 0x4630
jmp 0x92a0a
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x92a1f
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x92a1f
movq %rax, %rbx
movq %rsp, %rdi
callq 0xf2da
leaq 0x40(%rsp), %rdi
callq 0x2f5e8
movq %rbx, %rdi
callq 0x4780
nop