// File: /workspace/github_cpp_makefile_star2_O1/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 $0xf8, %rsp
movq %rdi, %r14
movslq 0x4(%rdi), %rsi
movq %rsp, %rbx
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
leaq 0x40(%rsp), %rdi
leaq 0x18(%rsp), %r15
movq %rbx, %rdx
movq %r15, %rcx
callq 0x578a
movq %r14, %rdi
callq 0x9822
mulsd 0x26a6(%rip), %xmm0     # 0xb1f8
movsd %xmm0, 0x38(%rsp)
leaq 0x10(%r14), %r12
movl $0x7ffffffe, 0x34(%rsp) # imm = 0x7FFFFFFE
movq %r12, 0x60(%rsp)
cmpl $0x0, (%r14)
jle 0x8f6d
xorl %r12d, %r12d
movq %rbx, 0x8(%rsp)
movq %rbx, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x60(%rsp), %r13
movq %r13, %rdi
leaq 0x270c(%rip), %rsi      # 0xb2a3
callq 0x20a0
testl %eax, %eax
je 0x8c8e
movq %r13, %rdi
leaq 0x2718(%rip), %rsi      # 0xb2c6
callq 0x20a0
testl %eax, %eax
jne 0x8dde
movq 0x30(%r14), %rax
movq 0x38(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %r12, %rdx
jbe 0x9149
movq 0x98(%r14), %r13
leaq (%r12,%r12,2), %rcx
leaq (%rax,%rcx,8), %rsi
leaq 0xc8(%rsp), %rbp
movq %rbp, %rdi
callq 0x3900
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movsd 0x38(%rsp), %xmm0
movl $0x1, %ecx
callq 0x9c96
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x8c32
movq (%rdi), %r15
callq 0x2260
movq %r15, %rdi
cmpq %rbx, %r15
jne 0x8c22
movq %rbx, 0x8(%rsp)
movq %rbx, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x18(%rsp), %rax
leaq 0x18(%rsp), %rcx
cmpq %rcx, %rax
je 0x8d98
movq %rax, (%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbx, (%rax)
movq (%rsp), %rax
movq %rbx, 0x8(%rax)
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rcx, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
leaq 0x28(%rsp), %rax
jmp 0x8da6
movq 0x30(%r14), %rax
movq 0x38(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %r12, %rdx
jbe 0x9138
movq 0x80(%r14), %r13
leaq (%r12,%r12,2), %rcx
leaq (%rax,%rcx,8), %rsi
leaq 0xe0(%rsp), %rbp
movq %rbp, %rdi
callq 0x3900
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movsd 0x38(%rsp), %xmm0
movl $0x1, %ecx
callq 0x99c2
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x8d05
movq (%rdi), %r15
callq 0x2260
movq %r15, %rdi
cmpq %rbx, %r15
jne 0x8cf5
movq %rbx, 0x8(%rsp)
movq %rbx, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x18(%rsp), %rax
leaq 0x18(%rsp), %rcx
cmpq %rcx, %rax
je 0x8d5a
movq %rax, (%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbx, (%rax)
movq (%rsp), %rax
movq %rbx, 0x8(%rax)
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rcx, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
leaq 0x28(%rsp), %rax
jmp 0x8d68
movq %rbx, 0x8(%rsp)
movq %rbx, (%rsp)
leaq 0x10(%rsp), %rax
movq $0x0, (%rax)
movq 0x18(%rsp), %rdi
cmpq %rcx, %rdi
je 0x8d8e
movq (%rdi), %r15
callq 0x2260
movq %r15, %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %r15
jne 0x8d79
movq 0xe0(%rsp), %rdi
jmp 0x8dd4
movq %rbx, 0x8(%rsp)
movq %rbx, (%rsp)
leaq 0x10(%rsp), %rax
movq $0x0, (%rax)
movq 0x18(%rsp), %rdi
cmpq %rcx, %rdi
je 0x8dcc
movq (%rdi), %r15
callq 0x2260
movq %r15, %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %r15
jne 0x8db7
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x8dde
callq 0x2260
movq (%rsp), %r15
cmpq %rbx, %r15
je 0x8f40
movslq 0x10(%r15), %rbp
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbp, %rdx
jbe 0x90f4
movslq (%rax,%rbp,4), %r13
cmpq $-0x1, %r13
je 0x8f31
movq 0x48(%r14), %rax
movq 0x50(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rbp, %rdx
jbe 0x9116
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
leaq (%rax,%rcx,8), %rsi
leaq 0x68(%rsp), %rdi
callq 0x3900
movq 0x30(%r14), %rax
movq 0x38(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %r13, %rdx
jbe 0x9105
leaq (,%r13,2), %rcx
addq %r13, %rcx
leaq (%rax,%rcx,8), %rsi
leaq 0xb0(%rsp), %rdi
callq 0x3900
movslq 0x8(%r14), %rax
testq %rax, %rax
jle 0x8ed8
movq 0x68(%rsp), %rcx
xorpd %xmm2, %xmm2
movq 0xb0(%rsp), %rdx
xorl %esi, %esi
movapd 0x2354(%rip), %xmm1     # 0xb210
movsd (%rcx,%rsi,8), %xmm0
subsd (%rdx,%rsi,8), %xmm0
andpd %xmm1, %xmm0
addsd %xmm0, %xmm2
incq %rsi
cmpq %rsi, %rax
jne 0x8ebc
jmp 0x8edc
xorpd %xmm2, %xmm2
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
movsd %xmm2, 0x58(%rsp)
je 0x8efa
callq 0x2260
movsd 0x58(%rsp), %xmm2
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x8f0f
callq 0x2260
movsd 0x58(%rsp), %xmm2
ucomisd 0x18(%r15), %xmm2
jbe 0x8f38
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbp, %rdx
jbe 0x9127
leaq (%rax,%rbp,4), %rax
movl %r12d, (%rax)
movq (%r15), %r15
jmp 0x8de2
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x8f59
movq (%rdi), %r15
callq 0x2260
movq %r15, %rdi
cmpq %rbx, %r15
jne 0x8f49
incq %r12
movslq (%r14), %rax
cmpq %rax, %r12
leaq 0x18(%rsp), %r15
jl 0x8b76
leaq 0x98(%rsp), %r12
movq %r12, %rdi
leaq 0x40(%rsp), %rsi
callq 0x54f6
movq %r14, %rdi
movq %r12, %rsi
callq 0xa1f0
movl %eax, %ebp
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x8fa1
callq 0x2260
movsd 0x38(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
cmpl 0x34(%rsp), %ebp
movl %ebp, 0x34(%rsp)
jne 0x8b69
cmpl $0x0, 0x4(%r14)
jle 0x90be
xorl %r15d, %r15d
leaq 0x80(%rsp), %r12
xorl %r13d, %r13d
xorl %ebx, %ebx
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x915a
cmpl $-0x1, (%rax,%r13,4)
jne 0x9067
movq 0x48(%r14), %rsi
movq 0x50(%r14), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq %r13, %rdx
jbe 0x915a
addq %r15, %rsi
movq %r12, %rdi
callq 0x3900
movq %r14, %rdi
movq %r12, %rsi
callq 0x969e
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x916b
movl %eax, (%rcx,%r13,4)
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x9067
callq 0x2260
movq 0x60(%r14), %rax
movq 0x68(%r14), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x915a
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x915a
movl (%rax,%r13,4), %eax
xorl %edx, %edx
cmpl (%rcx,%r13,4), %eax
setne %dl
addl %edx, %ebx
incq %r13
movslq 0x4(%r14), %rax
addq $0x18, %r15
cmpq %rax, %r13
jl 0x8fda
jmp 0x90c0
xorl %ebx, %ebx
addq $0x60, %r14
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x58fe
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x90e0
callq 0x2260
movl %ebx, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x224a(%rip), %rdi      # 0xb345
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2370
leaq 0x2239(%rip), %rdi      # 0xb345
movq %r13, %rsi
xorl %eax, %eax
callq 0x2370
leaq 0x2228(%rip), %rdi      # 0xb345
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2370
leaq 0x2217(%rip), %rdi      # 0xb345
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2370
leaq 0x2206(%rip), %rdi      # 0xb345
movq %r12, %rsi
xorl %eax, %eax
callq 0x2370
leaq 0x21f5(%rip), %rdi      # 0xb345
movq %r12, %rsi
xorl %eax, %eax
callq 0x2370
leaq 0x21e4(%rip), %rdi      # 0xb345
movq %r13, %rsi
xorl %eax, %eax
callq 0x2370
leaq 0x21d3(%rip), %rdi      # 0xb345
movq %r13, %rsi
xorl %eax, %eax
callq 0x2370
jmp 0x91aa
jmp 0x91aa
jmp 0x9182
movq %rax, %r14
movq 0x80(%rsp), %rdi
jmp 0x919c
jmp 0x91aa
movq %rax, %r14
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x9209
callq 0x2260
jmp 0x9209
jmp 0x91aa
movq %rax, %r14
jmp 0x9209
movq %rax, %r14
movq 0xc8(%rsp), %rdi
jmp 0x91e1
jmp 0x91ed
jmp 0x91ed
movq %rax, %r14
movq 0xe0(%rsp), %rdi
jmp 0x91e1
jmp 0x91ed
jmp 0x91ed
jmp 0x91ed
jmp 0x91ed
jmp 0x91ed
jmp 0x91d9
movq %rax, %r14
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x91f0
callq 0x2260
jmp 0x91f0
movq %rax, %r14
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x9209
movq (%rdi), %r15
callq 0x2260
movq %r15, %rdi
cmpq %rbx, %r15
jne 0x91f9
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x9218
callq 0x2260
movq %r14, %rdi
callq 0x2450