// File: /workspace/github_cpp_makefile_star2_O2/nikosgalanis[P]Vectors-Similarity-Search-and-Clustering/programs/LSH/../../algorithms/Search/LSH/headers/lsh.h
// Function: LSH<double>::RangeSearch[abi:cxx11](std::vector<double, std::allocator<double>>, double, int)
list<pair<int,T>> RangeSearch(vector<T> query_vector, double radius, int c) {
					list<pair<int,T>> result;

					int i = 0;
					int visited = 0;
					// Traverse all the hash tables. aka 1 ... L
					for (std::list<lsh::AmplifiedHashFunction>::iterator it = amplified_hash_fns.begin(); 
						it != amplified_hash_fns.end(); it++) {
						// refer to the correct hash table in the vetor of hashes
						// find the bucket that the query hashes into
						int index = it->assign_to_bucket(query_vector);
						// access that specific bucket
						list<int> bucket = lsh_tables.at(i)[index];
						// get all the indexes of the vectors in the bucket
						for (std::list<int>::iterator bucket_it = bucket.begin(); bucket_it != bucket.end(); bucket_it++) {
							// increase the visited items
							visited++;
							
							// calculate the distance between the selected vector and our query vector
							T distance = metrics::ManhatanDistance(feature_vectors.at(*bucket_it), query_vector, space_dim);
							
							// create the new pair
							pair<int, T> new_pair = make_pair(*bucket_it, distance);

							// check if the pair is already on a list
							if (find(result.begin(), result.end(), new_pair) != result.end()) {
								continue;
							}

							// if the distance is smaller than the radius, push it in our result list
							if (distance < (T)(radius * c)) {
								result.push_back(new_pair);
							}
							// if (visited > 20 * L) {
							//     return result;
							// }
						}
						i++;
					}
					return result;
				}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, 0x18(%rsp)
movq %rdi, %rbx
movq %rdi, 0x8(%rdi)
movq %rdi, (%rdi)
andq $0x0, 0x10(%rdi)
leaq 0x20(%rsi), %rax
leaq 0x38(%rsi), %rdx
movq %rdx, 0x20(%rsp)
movq %rsi, %r14
leaq 0x50(%rsi), %r13
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x60(%rsp), %r15
leaq 0x90(%rsp), %rbp
leaq 0x78(%rsp), %r12
movq %rax, 0x28(%rsp)
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
cmpq 0x28(%rsp), %rax
je 0x45fb
movq %r15, %rdi
movq 0x18(%rsp), %rsi
callq 0x3152
movq 0x8(%rsp), %rax
leaq 0x10(%rax), %rdi
movq %r15, %rsi
callq 0x4a9e
movl %eax, (%rsp)
movq %r15, %rdi
callq 0x2f06
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x4a26
leaq 0x48(%rsp), %r15
movslq (%rsp), %rcx
imulq $0x18, %rcx, %rsi
addq (%rax), %rsi
movq %r15, %rdi
callq 0x5a44
movq (%r15), %r15
leaq 0x48(%rsp), %rax
cmpq %rax, %r15
je 0x45e2
movslq 0x10(%r15), %rsi
movq %r13, %rdi
callq 0x3af2
movq %rbp, %rdi
movq %rax, %rsi
callq 0x3152
movq %r12, %rdi
movq 0x18(%rsp), %rsi
callq 0x3152
movl 0x18(%r14), %edx
movq %rbp, %rdi
movq %r12, %rsi
callq 0x476f
movq %r12, %rdi
movsd %xmm0, (%rsp)
callq 0x2f06
movq %rbp, %rdi
callq 0x2f06
movl 0x10(%r15), %eax
movl %eax, 0x38(%rsp)
movsd (%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq (%rbx), %rdi
movq %rbx, %rsi
leaq 0x38(%rsp), %rdx
callq 0x5d77
cmpq %rbx, %rax
jne 0x453a
movsd (%rsp), %xmm0
ucomisd 0x30(%rsp), %xmm0
jae 0x453a
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
callq 0x47a6
jmp 0x453a
incq 0x10(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x5744
leaq 0x60(%rsp), %r15
jmp 0x44d2
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4621
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0x2f06
jmp 0x4658
movq %rax, %r14
jmp 0x4658
jmp 0x464b
movq %rax, %r14
jmp 0x463a
movq %rax, %r14
leaq 0x78(%rsp), %rdi
callq 0x2f06
leaq 0x90(%rsp), %rdi
callq 0x2f06
jmp 0x464e
jmp 0x464b
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x5744
movq %rbx, %rdi
callq 0x468c
movq %r14, %rdi
callq 0x2340