// File: /workspace/github_cpp_makefile_star2_O3/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 0x5656
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 0x382a
leaq 0x10(%r13), %rdi
movq %rbp, %rsi
callq 0x5aa6
movl %eax, %ebp
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x5494
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 0x5679
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 0x67de
movq 0x40(%rsp), %rbp
cmpq %r14, %rbp
je 0x561c
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 0x566b
leaq (%rsi,%rsi,2), %rcx
leaq (%rax,%rcx,8), %rsi
leaq 0x28(%rsp), %rdi
callq 0x382a
leaq 0x70(%rsp), %rdi
movq %r15, %rsi
callq 0x382a
movslq 0x18(%r12), %rax
movq 0x70(%rsp), %rdi
xorpd %xmm2, %xmm2
testq %rax, %rax
jle 0x5578
movq 0x28(%rsp), %rcx
xorl %edx, %edx
movapd 0x1ca4(%rip), %xmm1     # 0x7200
movsd (%rcx,%rdx,8), %xmm0
subsd (%rdi,%rdx,8), %xmm0
andpd %xmm1, %xmm0
addsd %xmm0, %xmm2
incq %rdx
cmpq %rdx, %rax
jne 0x555c
jmp 0x557d
testq %rdi, %rdi
je 0x558c
movsd %xmm2, (%rsp)
callq 0x2200
movsd (%rsp), %xmm2
movsd %xmm2, (%rsp)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x55a0
callq 0x2200
movl 0x10(%rbp), %r13d
movq (%rbx), %rax
movq %rbx, %rcx
cmpq %rbx, %rax
je 0x55d1
cmpl %r13d, 0x10(%rax)
jne 0x55c1
movsd 0x18(%rax), %xmm0
ucomisd (%rsp), %xmm0
je 0x55ce
movq (%rax), %rax
cmpq %rbx, %rax
jne 0x55af
movq %rbx, %rcx
jmp 0x55d1
movq %rax, %rcx
cmpq %rbx, %rcx
jne 0x560a
movsd (%rsp), %xmm0
ucomisd 0x20(%rsp), %xmm0
jae 0x560a
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
cmpq %r14, %rbp
jne 0x54ef
movq 0x40(%rsp), %rbp
cmpq %r14, %rbp
je 0x5635
movq (%rbp), %r13
movq %rbp, %rdi
callq 0x2200
movq %r13, %rbp
cmpq %r14, %r13
jne 0x5621
movq 0x8(%rsp), %rax
incq %rax
movq 0x18(%rsp), %r13
movq (%r13), %r13
cmpq 0x10(%rsp), %r13
leaq 0x58(%rsp), %rbp
jne 0x5467
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cd3(%rip), %rdi      # 0x7345
xorl %eax, %eax
callq 0x22e0
leaq 0x1cc5(%rip), %rdi      # 0x7345
xorl %eax, %eax
callq 0x22e0
jmp 0x569f
movq %rax, %r15
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x56d9
callq 0x2200
jmp 0x56d9
jmp 0x569f
movq %rax, %r15
jmp 0x56d9
jmp 0x56bc
jmp 0x56bc
movq %rax, %r15
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x56bf
callq 0x2200
jmp 0x56bf
movq %rax, %r15
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x56d9
movq (%rdi), %r12
callq 0x2200
movq %r12, %rdi
cmpq %r14, %r12
jne 0x56c9
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x56f1
movq (%rdi), %r14
callq 0x2200
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x56e1
movq %r15, %rdi
callq 0x23c0
nop