// File: Luthaf[P]zeopp/sphere_approx.cc
// Function: AtomCluster::sphere_spiral(double, double)
void AtomCluster::sphere_spiral(double n, double shift){
        double golden_angle = PI * (3.0-sqrt(5));

        for (int i = 0; i<n; i++){
                double theta = golden_angle * i;
                double z_shift = (1-(1/n))*(1-((2*i)/(n-1)));
                double z_sq = z_shift * z_shift;
                double radius = sqrt(1-z_sq);
                double x_shift = radius * cos(theta);
                double y_shift = radius * sin(theta);

                ATOM new_sphere = translate_sphere(center, shift * x_shift, shift * y_shift, shift * z_shift, 1, 1, 1);
                atom_vector.push_back(new_sphere);
        }
        atom_vector.push_back(center);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movl $0x5, %edi
callq 0x94d40
movsd 0xfd012(%rip), %xmm1    # 0x1f73c8
subsd %xmm0, %xmm1
movsd 0xfc26e(%rip), %xmm0    # 0x1f6630
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
cvtsi2sdl -0x24(%rbp), %xmm1
movsd -0x10(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xfa59d
movsd -0x20(%rbp), %xmm0
cvtsi2sdl -0x24(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x10(%rbp), %xmm2
movsd 0xf7c4a(%rip), %xmm0    # 0x1f2050
movaps %xmm0, %xmm3
divsd %xmm2, %xmm3
movaps %xmm0, %xmm1
subsd %xmm3, %xmm1
movl -0x24(%rbp), %eax
addl %eax, %eax
cvtsi2sd %eax, %xmm3
subsd %xmm0, %xmm2
divsd %xmm2, %xmm3
movaps %xmm0, %xmm2
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm1
movsd %xmm1, -0x38(%rbp)
movsd -0x38(%rbp), %xmm1
mulsd %xmm1, %xmm1
movsd %xmm1, -0x40(%rbp)
movsd -0x40(%rbp), %xmm1
subsd %xmm1, %xmm0
callq 0x53f0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x1b8(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x5970
movaps %xmm0, %xmm1
movsd -0x1b8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x1b0(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x5140
movq -0x1a0(%rbp), %rsi
movaps %xmm0, %xmm1
movsd -0x1b0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
addq $0xa0, %rsi
leaq -0x188(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0xf0d0
movq -0x1a0(%rbp), %rsi
movq -0x1a8(%rbp), %rdx
movsd -0x18(%rbp), %xmm2
movsd -0x50(%rbp), %xmm1
movaps %xmm2, %xmm0
mulsd %xmm1, %xmm0
movsd -0x58(%rbp), %xmm3
movaps %xmm2, %xmm1
mulsd %xmm3, %xmm1
movsd -0x38(%rbp), %xmm3
mulsd %xmm3, %xmm2
leaq -0xf0(%rbp), %rdi
movl $0x1, %r9d
movl %r9d, %ecx
movl %r9d, %r8d
callq 0xfa5d0
jmp 0xfa51b
leaq -0x188(%rbp), %rdi
callq 0xf200
movq -0x1a0(%rbp), %rdi
addq $0x138, %rdi            # imm = 0x138
leaq -0xf0(%rbp), %rsi
callq 0xf190
jmp 0xfa543
leaq -0xf0(%rbp), %rdi
callq 0xf200
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xfa3d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x190(%rbp)
movl %eax, -0x194(%rbp)
leaq -0x188(%rbp), %rdi
callq 0xf200
jmp 0xfa5c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x190(%rbp)
movl %eax, -0x194(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0xf200
jmp 0xfa5c3
movq -0x1a0(%rbp), %rsi
movq %rsi, %rdi
addq $0x138, %rdi            # imm = 0x138
addq $0xa0, %rsi
callq 0xf190
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq -0x190(%rbp), %rdi
callq 0x58f0
nop