// File: /workspace/github_cpp_makefile_star2_O1/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 $0x88, %rsp
movq %rdi, %rbx
movq %rdi, 0x8(%rdi)
movq %rdi, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0x20(%rsi), %rax
movq 0x20(%rsi), %r13
movq %rax, 0x10(%rsp)
cmpq %rax, %r13
je 0x564d
movq %rdx, %r15
movq %rsi, %r12
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
xorl %eax, %eax
leaq 0x58(%rsp), %rbp
leaq 0x40(%rsp), %r14
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x3810
leaq 0x10(%r13), %rdi
movq %rbp, %rsi
callq 0x5a90
movl %eax, %ebp
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x54a2
callq 0x2200
movq 0x38(%r12), %rax
movq 0x40(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
movq 0x8(%rsp), %rsi
cmpq %rsi, %rdx
jbe 0x5670
movq %r13, 0x18(%rsp)
leaq (%rsi,%rsi,2), %rcx
movslq %ebp, %rdx
leaq (%rdx,%rdx,2), %rsi
shlq $0x3, %rsi
addq (%rax,%rcx,8), %rsi
movq %r14, %rdi
callq 0x67a0
movq 0x40(%rsp), %rbp
cmpq %r14, %rbp
je 0x5612
movslq 0x10(%rbp), %rsi
movq 0x50(%r12), %rax
movq 0x58(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rsi, %rdx
jbe 0x5662
leaq (%rsi,%rsi,2), %rcx
leaq (%rax,%rcx,8), %rsi
leaq 0x28(%rsp), %rdi
callq 0x3810
leaq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0x3810
movslq 0x18(%r12), %rax
testq %rax, %rax
jle 0x5586
movq 0x28(%rsp), %rcx
xorpd %xmm2, %xmm2
movq 0x70(%rsp), %rdx
xorl %esi, %esi
movapd 0x1cb6(%rip), %xmm1     # 0x7220
movsd (%rcx,%rsi,8), %xmm0
subsd (%rdx,%rsi,8), %xmm0
andpd %xmm1, %xmm0
addsd %xmm0, %xmm2
incq %rsi
cmpq %rsi, %rax
jne 0x556a
jmp 0x558a
xorpd %xmm2, %xmm2
movsd %xmm2, (%rsp)
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x559e
callq 0x2200
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x55ad
callq 0x2200
movl 0x10(%rbp), %r13d
movq (%rbx), %rax
cmpq %rbx, %rax
je 0x55d0
cmpl %r13d, 0x10(%rax)
jne 0x55cb
movsd 0x18(%rax), %xmm0
ucomisd (%rsp), %xmm0
je 0x55d0
movq (%rax), %rax
jmp 0x55b4
cmpq %rbx, %rax
jne 0x5609
movsd (%rsp), %xmm0
ucomisd 0x20(%rsp), %xmm0
jae 0x5609
movl $0x20, %edi
callq 0x2220
movl %r13d, 0x10(%rax)
movsd (%rsp), %xmm0
movsd %xmm0, 0x18(%rax)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2060
incq 0x10(%rbx)
movq (%rbp), %rbp
jmp 0x54f4
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x562c
movq (%rdi), %r13
callq 0x2200
movq %r13, %rdi
cmpq %r14, %r13
jne 0x561c
movq 0x8(%rsp), %rax
incq %rax
movq 0x18(%rsp), %r13
movq (%r13), %r13
cmpq 0x10(%rsp), %r13
leaq 0x58(%rsp), %rbp
jne 0x5475
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cfc(%rip), %rdi      # 0x7365
xorl %eax, %eax
callq 0x22e0
leaq 0x1cee(%rip), %rdi      # 0x7365
xorl %eax, %eax
callq 0x22e0
jmp 0x5696
movq %rax, %r15
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x56bc
callq 0x2200
jmp 0x56bc
jmp 0x5696
movq %rax, %r15
jmp 0x56bc
jmp 0x569f
jmp 0x569f
movq %rax, %r15
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x56bc
movq (%rdi), %r12
callq 0x2200
movq %r12, %rdi
cmpq %r14, %r12
jne 0x56ac
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x56d4
movq (%rdi), %r14
callq 0x2200
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x56c4
movq %r15, %rdi
callq 0x23c0
movq %rax, %r15
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x56a2
callq 0x2200
jmp 0x56a2