// File: /workspace/github_cpp_makefile_star2_O2/nikosgalanis[P]Vectors-Similarity-Search-and-Clustering/programs/Clustering/../../algorithms/Clustering/clustering.h
// Function: Clustering<double>::reverse_assignment()
int reverse_assignment(void) {
			// keep a vector of the new assignments
			vector<int> new_assigned(n_points, -1);
			// initial radius
			T radius = min_dist_between_centroids() / 2;
			// keep track of the changes
			int changes = 0;
			// set a threshold in order to break the loop
			int prev_unassigned = INT_MAX;
			// keep track of unassinged points
			int unassinged = INT_MAX - 1;
			// break the loop when all the balls contain no new vectors
			while (unassinged != prev_unassigned) {
				// do a range search query for every centroid
				for (int i = 0; i < k; i++) {
					list<pair<int, T>> result;
					// the type of range search depends on what the user wants
					if (assignment_method == "reverse_LSH")
						result = lsh_instant->RangeSearch(centroids.at(i), radius, 1);
					else if (assignment_method == "reverse_Hypercube")
						result = hc_instant->RangeSearch(centroids.at(i), radius, 1);

					// iterate all the results
					typename std::list<std::pair<int,T>>::iterator pair_it;
					for (pair_it = result.begin(); pair_it !=result.end(); pair_it++) {
						// get the current vector
						int curr_vec = pair_it->first;

						// if it is still unassigned
						if (new_assigned.at(curr_vec) == -1) {
							// temporarly assign it to this centroid
							new_assigned.at(curr_vec) = i;
						}
						// if it has been already assigned
						else {
							// chcek if its distance from the current centroid, is less than the previous' one
							int prev_assigned = new_assigned.at(curr_vec); 
							T prev_dist = metrics::ManhatanDistance(feature_vectors.at(curr_vec), centroids.at(prev_assigned), space_dim);
							T new_dist = pair_it->second;
							// if it is, it is closest to the current centroid, thus change the asssigned value in the temp vector
							if (new_dist < prev_dist)
								new_assigned.at(curr_vec) = i;
						}
					}
				}

				// update the unassigned vectors count
				prev_unassigned = unassinged;
				unassinged = count_unassigned(new_assigned);
				// update the radius
				radius *= 2;
			}

			// update the untracked vectors, and check for new changes
			for (int i = 0; i < n_points; i++) {
				// for each one not tracked, use direct assignment
				if (new_assigned.at(i) == UNASSIGNED)
					new_assigned.at(i) = nearest_centroid(feature_vectors.at(i));
				// check for changes
				if (assigned_centroid.at(i) != new_assigned.at(i))
					changes++;
			}

			// update the assigned vector
			assigned_centroid = new_assigned;
			return changes;
		}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %r15
movslq 0x4(%rdi), %rsi
leaq 0x58(%rsp), %r12
orl $-0x1, (%r12)
leaq 0x40(%rsp), %rdi
leaq 0xa0(%rsp), %rcx
movq %r12, %rdx
callq 0x48a0
movq %r15, %rdi
callq 0x81aa
mulsd 0x285d(%rip), %xmm0     # 0xa1d8
movsd %xmm0, 0x10(%rsp)
leaq 0x10(%r15), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%r15), %rax
movq %rax, 0x20(%rsp)
leaq 0x48(%r15), %rax
movq %rax, 0x28(%rsp)
movl $0x7fffffff, 0xc(%rsp)  # imm = 0x7FFFFFFF
movl $0x7ffffffe, %ebx       # imm = 0x7FFFFFFE
leaq 0x40(%rsp), %rbp
leaq 0x70(%rsp), %r13
movq %r15, 0x18(%rsp)
movl 0xc(%rsp), %eax
cmpl %eax, %ebx
je 0x7c11
movl %ebx, 0xc(%rsp)
xorl %ecx, %ecx
movslq (%r15), %rax
movq %rcx, (%rsp)
cmpq %rax, %rcx
jge 0x7bdc
movq %r12, 0x60(%rsp)
movq %r12, 0x58(%rsp)
andq $0x0, 0x68(%rsp)
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
leaq 0x285a(%rip), %rsi      # 0xa253
callq 0x49b7
testb %al, %al
je 0x7a6b
movq 0x80(%r15), %r15
movq 0x20(%rsp), %rdi
movq (%rsp), %rsi
callq 0x4200
leaq 0x100(%rsp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x31d2
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movsd 0x10(%rsp), %xmm0
pushq $0x1
popq %rcx
callq 0x8296
movq %r12, %rdi
movq %r14, %rsi
callq 0x8908
movq %r14, %rdi
callq 0x8942
movq %r13, %rdi
callq 0x2f86
leaq 0x70(%rsp), %r13
jmp 0x7ae0
movq %rbx, %rdi
leaq 0x2801(%rip), %rsi      # 0xa276
callq 0x49b7
testb %al, %al
je 0x7ae0
movq 0x98(%r15), %r15
movq 0x20(%rsp), %rdi
movq (%rsp), %rsi
callq 0x4200
leaq 0xe8(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x31d2
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movsd 0x10(%rsp), %xmm0
pushq $0x1
popq %rcx
callq 0x8498
movq %r12, %rdi
movq %r14, %rsi
callq 0x8908
movq %r14, %rdi
callq 0x8942
movq %rbx, %rdi
callq 0x2f86
movq %r12, %r14
movq (%r12), %r12
cmpq %r14, %r12
je 0x7bc0
movslq 0x10(%r12), %r15
movq %rbp, %rdi
movq %r15, %rsi
callq 0x606e
cmpl $-0x1, (%rax)
je 0x7baa
movq %rbp, %rdi
movq %r15, %rsi
callq 0x606e
movslq (%rax), %r13
movq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x4200
leaq 0x88(%rsp), %rdi
movq %rax, %rsi
callq 0x31d2
movq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x4200
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x31d2
movq 0x18(%rsp), %rax
movl 0x8(%rax), %edx
leaq 0x88(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x7f34
movq %rbx, %rdi
movsd %xmm0, 0x38(%rsp)
callq 0x2f86
movq %r13, %rdi
callq 0x2f86
movsd 0x38(%rsp), %xmm0
ucomisd 0x18(%r12), %xmm0
leaq 0x70(%rsp), %r13
jbe 0x7ae3
movq %rbp, %rdi
movq %r15, %rsi
callq 0x606e
jmp 0x7bb5
movq %rbp, %rdi
movq %r15, %rsi
callq 0x606e
movq (%rsp), %rcx
movl %ecx, (%rax)
jmp 0x7ae3
movq %r14, %r12
movq %r14, %rdi
callq 0x8942
movq (%rsp), %rcx
incq %rcx
movq 0x18(%rsp), %r15
jmp 0x79ca
movq %r13, %rdi
movq %rbp, %rsi
callq 0x46c2
movq %r15, %rdi
movq %r13, %rsi
callq 0x87ee
movl %eax, %ebx
movq %r13, %rdi
callq 0x4888
movsd 0x10(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x79b8
leaq 0x60(%r15), %r14
xorl %r15d, %r15d
leaq 0x40(%rsp), %r12
leaq 0xb8(%rsp), %r13
xorl %ebx, %ebx
movq 0x18(%rsp), %rax
movslq 0x4(%rax), %rax
cmpq %rax, %r15
jge 0x7ca7
movq %r12, %rdi
movq %r15, %rsi
callq 0x606e
cmpl $-0x1, (%rax)
jne 0x7c81
movq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x4200
movq %r13, %rdi
movq %rax, %rsi
callq 0x31d2
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x80b0
movl %eax, %ebp
movq %r12, %rdi
movq %r15, %rsi
callq 0x606e
movl %ebp, (%rax)
movq %r13, %rdi
callq 0x2f86
movq %r14, %rdi
movq %r15, %rsi
callq 0x606e
movl (%rax), %ebp
movq %r12, %rdi
movq %r15, %rsi
callq 0x606e
xorl %ecx, %ecx
cmpl (%rax), %ebp
setne %cl
addl %ecx, %ebx
incq %r15
jmp 0x7c27
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x48f6
leaq 0x40(%rsp), %rdi
callq 0x4888
movl %ebx, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7cf9
jmp 0x7cf9
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x2f86
jmp 0x7d53
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4888
jmp 0x7d53
jmp 0x7cf9
movq %rax, %rbx
jmp 0x7d53
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
jmp 0x7d3f
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0x7d3f
jmp 0x7d46
jmp 0x7d46
jmp 0x7d46
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x2f86
jmp 0x7d37
jmp 0x7d46
jmp 0x7d46
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x2f86
jmp 0x7d49
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x8942
leaq 0x40(%rsp), %rdi
callq 0x4888
movq %rbx, %rdi
callq 0x23b0
nop