// File: /workspace/github_cpp_makefile_star2_O3/nikosgalanis[P]Vectors-Similarity-Search-and-Clustering/programs/Clustering/../../algorithms/Clustering/clustering.h
// Function: Clustering<double>::initialization()
void initialization(void) {
		// chose a first index randomly
		std::random_device mch;
		std::default_random_engine generator(mch());
		std::uniform_int_distribution<int> distribution_int(0,n_points - 1);
		int index = distribution_int(generator);
		// this is our first centroid
		centroids.push_back(feature_vectors.at(index));
			// find the other centroids with the algorithm init++
			for (int t = 1; t < k; t++) {
				// define a distance vector
				vector<T> D(n_points, INT_MAX);
				// define a vector of the partial sums
				vector<T> P(n_points, 0);
				// for every point
				for (int i = 0; i < n_points; i++) {
					// check if it is centroid
					vector<T> curr = feature_vectors.at(i);
					if (std::find(centroids.begin(), centroids.end(), curr) == centroids.end()) {
						//compute D(i)
						for (int j = 0; j < t; j++) {
							T dist = metrics::ManhatanDistance(feature_vectors.at(i), centroids.at(j), space_dim);
							if (dist < D.at(i))
								D.at(i) = dist;
						}
					} else {
						// if it is a centroid, set its D value to 0
						D.at(i) = 0;
					}
					// compute the partial sums effectively
					if (i == 0)
						P.at(i) = pow(D.at(0), 2);
					else 
						P.at(i) = P.at(i - 1) + pow(D.at(i), 2);
				}
				//pick a uniformly distributed x
				std::uniform_real_distribution<double> distribution_real(0, P.at(n_points -1));
				double x = distribution_real(generator);

				// find its correct position
				int r_index = -1;
				int i = 0;
				for (i = 0; i < n_points; i++) {
					if (P.at(i) > (T)x) {
						r_index = i;
						break;
					}
				}
				// ensure that the point is not a csntroid
				while ((i - 1 > 0) && P.at(i) == P.at(i - 1)) {
					r_index--;
				}
				assert(r_index > 0);
				// now the r_index has a correct value, so its our new centroid
				centroids.push_back(feature_vectors.at(r_index));
			}
		}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1428, %rsp           # imm = 0x1428
movq %rdi, %rbx
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
callq 0x65e0
movq %r14, %rdi
callq 0x2310
movl %eax, %ecx
leaq (%rcx,%rcx,2), %rcx
shrq $0x20, %rcx
movl %eax, %edx
subl %ecx, %edx
shrl %edx
addl %ecx, %edx
shrl $0x1e, %edx
movl %edx, %ecx
shll $0x1f, %ecx
orl %edx, %ecx
leal (%rax,%rcx), %edx
cmpl $0x1, %edx
adcl %eax, %ecx
leaq 0x60(%rsp), %rsi
movq %rcx, (%rsi)
movl 0x4(%rbx), %eax
decl %eax
leaq 0x80(%rsp), %rdi
movl $0x0, (%rdi)
movl %eax, 0x4(%rdi)
movq %rdi, %rdx
callq 0x79b8
movslq %eax, %rsi
movq 0x48(%rbx), %rax
movq 0x50(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %r13 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r13, %rdx
cmpq %rsi, %rdx
jbe 0x8898
leaq 0x30(%rbx), %rdi
leaq (%rsi,%rsi,2), %rcx
leaq (%rax,%rcx,8), %rsi
movq %rdi, 0x58(%rsp)
callq 0x362a
cmpl $0x2, (%rbx)
jl 0x87e3
movl $0x1, %r15d
leaq 0x10(%rsp), %r14
movslq 0x4(%rbx), %rsi
movabsq $0x41dfffffffc00000, %rax # imm = 0x41DFFFFFFFC00000
movq %rax, 0x10(%rsp)
leaq 0x40(%rsp), %rdi
movq %r14, %rdx
leaq 0x28(%rsp), %r12
movq %r12, %rcx
callq 0x6432
movslq 0x4(%rbx), %rsi
movq $0x0, 0x28(%rsp)
movq %r14, %rdi
movq %r12, %rdx
leaq 0x7(%rsp), %rcx
callq 0x6432
movl 0x4(%rbx), %eax
testl %eax, %eax
jle 0x86da
xorl %r12d, %r12d
leaq 0x28(%rsp), %r14
movq 0x48(%rbx), %rax
movq 0x50(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r12, %rdx
jbe 0x8824
leaq (%r12,%r12,2), %rbp
leaq (%rax,%rbp,8), %rsi
movq %r14, %rdi
callq 0x393a
movq 0x30(%rbx), %rdi
movq 0x38(%rbx), %rsi
movq %r14, %rdx
callq 0x946e
cmpq 0x38(%rbx), %rax
je 0x8529
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r12, %rdx
jbe 0x8855
movq $0x0, (%rax,%r12,8)
xorpd %xmm0, %xmm0
jmp 0x8637
xorl %r14d, %r14d
movq 0x48(%rbx), %rax
movq 0x50(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r12, %rdx
jbe 0x8802
leaq (%rax,%rbp,8), %rsi
leaq 0x68(%rsp), %rdi
callq 0x393a
movq 0x30(%rbx), %rax
movq 0x38(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r14, %rdx
jbe 0x8813
leaq (%r14,%r14,2), %rcx
leaq (%rax,%rcx,8), %rsi
leaq 0x88(%rsp), %rdi
callq 0x393a
movslq 0x8(%rbx), %rax
movq 0x88(%rsp), %rdi
xorpd %xmm2, %xmm2
testq %rax, %rax
jle 0x85c7
movq 0x68(%rsp), %rcx
xorl %edx, %edx
movapd 0x2c45(%rip), %xmm1     # 0xb1f0
movsd (%rcx,%rdx,8), %xmm0
subsd (%rdi,%rdx,8), %xmm0
andpd %xmm1, %xmm0
addsd %xmm0, %xmm2
incq %rdx
cmpq %rdx, %rax
jne 0x85ab
jmp 0x85cc
testq %rdi, %rdi
je 0x85dd
movsd %xmm2, 0x8(%rsp)
callq 0x2260
movsd 0x8(%rsp), %xmm2
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x85f8
movsd %xmm2, 0x8(%rsp)
callq 0x2260
movsd 0x8(%rsp), %xmm2
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r12, %rdx
jbe 0x8802
movsd (%rax,%r12,8), %xmm0
ucomisd %xmm0, %xmm2
jae 0x862b
movsd %xmm2, (%rax,%r12,8)
movapd %xmm2, %xmm0
incq %r14
cmpq %r15, %r14
jne 0x852c
testq %r12, %r12
je 0x868c
leaq -0x1(%r12), %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
cmpq %rdi, %rdx
leaq 0x28(%rsp), %r14
jbe 0x884d
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
jbe 0x8852
cmpq %r12, %rdx
jbe 0x8855
mulsd %xmm0, %xmm0
addsd -0x8(%rsi,%r12,8), %xmm0
movsd %xmm0, (%rsi,%r12,8)
jmp 0x86b6
cmpq %rax, %rcx
leaq 0x28(%rsp), %r14
je 0x8846
movq 0x10(%rsp), %rcx
cmpq %rcx, 0x18(%rsp)
je 0x8846
movsd (%rax), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, (%rcx)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x86c5
callq 0x2260
incq %r12
movslq 0x4(%rbx), %rax
cmpq %rax, %r12
jl 0x84b9
leaq 0x10(%rsp), %r14
decl %eax
movslq %eax, %rsi
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x8885
movsd (%rax,%rsi,8), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x664a
movl 0x4(%rbx), %eax
testl %eax, %eax
jle 0x8866
mulsd 0x8(%rsp), %xmm0
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x8835
ucomisd (%rcx,%rsi,8), %xmm0
jb 0x8753
incq %rsi
cmpq %rsi, %rax
jne 0x8732
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %eax, %esi
jmp 0x8755
movl %esi, %ecx
cmpl $0x2, %esi
jb 0x877e
movl %esi, %eax
movq 0x18(%rsp), %rdx
subq 0x10(%rsp), %rdx
sarq $0x3, %rdx
cmpq %rax, %rdx
jbe 0x8893
decl %esi
cmpq %rsi, %rdx
jbe 0x8838
testl %ecx, %ecx
jle 0x8866
movl %ecx, %esi
movq 0x48(%rbx), %rax
movq 0x50(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %rsi, %rdx
jbe 0x8838
leaq (%rsi,%rsi,2), %rcx
leaq (%rax,%rcx,8), %rsi
movq 0x58(%rsp), %rdi
callq 0x362a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x87c5
callq 0x2260
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x87d4
callq 0x2260
incq %r15
movslq (%rbx), %rax
cmpq %rax, %r15
jl 0x8461
leaq 0xa0(%rsp), %rdi
callq 0x2250
addq $0x1428, %rsp           # imm = 0x1428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b1c(%rip), %rdi      # 0xb325
movq %r12, %rsi
xorl %eax, %eax
callq 0x2370
leaq 0x2b0b(%rip), %rdi      # 0xb325
movq %r14, %rsi
xorl %eax, %eax
callq 0x2370
leaq 0x2afa(%rip), %rdi      # 0xb325
movq %r12, %rsi
xorl %eax, %eax
callq 0x2370
movq %rdx, %rsi
leaq 0x2ae6(%rip), %rdi      # 0xb325
xorl %eax, %eax
callq 0x2370
xorl %r12d, %r12d
xorl %edx, %edx
jmp 0x8855
movq %rdi, %r12
jmp 0x8855
movq %rcx, %rdx
leaq 0x2ac9(%rip), %rdi      # 0xb325
movq %r12, %rsi
xorl %eax, %eax
callq 0x2370
leaq 0x2e8f(%rip), %rdi      # 0xb6fc
leaq 0x2b50(%rip), %rsi      # 0xb3c4
leaq 0x2e8d(%rip), %rcx      # 0xb708
movl $0x10e, %edx            # imm = 0x10E
callq 0x21a0
leaq 0x2a99(%rip), %rdi      # 0xb325
xorl %eax, %eax
callq 0x2370
movq %rax, %rsi
jmp 0x8838
leaq 0x2a86(%rip), %rdi      # 0xb325
xorl %eax, %eax
callq 0x2370
jmp 0x8926
jmp 0x88b2
jmp 0x88b2
jmp 0x88c0
jmp 0x88c0
jmp 0x88c0
movq %rax, %rbx
jmp 0x8911
movq %rax, %rbx
jmp 0x8902
jmp 0x88c0
jmp 0x88c0
movq %rax, %rbx
jmp 0x88f3
jmp 0x88e1
jmp 0x88e1
jmp 0x88cd
jmp 0x88e1
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x88e4
callq 0x2260
jmp 0x88e4
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x88f3
callq 0x2260
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8902
callq 0x2260
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x8911
callq 0x2260
leaq 0xa0(%rsp), %rdi
callq 0x2250
movq %rbx, %rdi
callq 0x2450
movq %rax, %rdi
callq 0x369b