// File: nikosgalanis[P]Vectors-Similarity-Search-and-Clustering/programs/LSH/lsh_main.cc
// Function: main
int main(int argc, char* argv[]) {
	// first step: parse the arguments
	char* input_file = NULL, *query_file = NULL, *output_file = NULL;
	int k, L, n_neighbors, radius;
	double sum1 = 0, sum2 = 0;
	
	// parse the comand line arguments given
	parse_lsh_args(argc, argv, &input_file, &output_file, &query_file,
	&k, &L, &n_neighbors, &radius);
	// parse the dataset in order to get a vector of our feature vector
	vector<vector<double>> feature_vectors = parse_input(input_file);

	// parse the query set in order to find all of the queries that the user wants to ask
	vector<vector<double>> query_vectors = parse_input(query_file);

	// make sure that there is at least one element in the dataset and the queryset
	assert(feature_vectors.size() && query_vectors.size());
	
	// create the output file that we are going to use to print the LSH results
	ofstream output;
	output.open(output_file);

	// lsh initialization values that we've learned from our dataset
	int n_points = feature_vectors.size();
	int space_dimension = feature_vectors.at(1).size();

	// defalt lsh values, that we've learned for theory
	uint64_t m = pow(2,32) - 5;
	uint32_t M = 256;
	uint32_t w = our_math::compute_w_value(feature_vectors, 1000);
	uint32_t c = 1; 
	int correct_computed = 0;
	// initialize our LSH class with the deature vectors and the aprropriate given values
	LSH<double> lsh_instant(L, m, M, n_points, k, space_dimension, w, feature_vectors);

	// initialize our brute force class, in order to find the true distance of the query and its neighbors
	BruteForce<double> bf_instant(n_points, space_dimension, feature_vectors);

	// run all the queries with LSH
	for (uint64_t i = 0; i < query_vectors.size(); i++) {
		// output the query number in the file
		output << "Query: " << i << endl;

		auto k_start = std::chrono::high_resolution_clock::now();
		// run the k-nearest neighbor algorithm, in order to obtain n neighbors
		list<pair<int,double>> kNNs = lsh_instant.kNearestNeighbour(query_vectors.at(i), n_neighbors);
		auto k_end = std::chrono::high_resolution_clock::now();

		duration<double> knn_time_span = duration_cast<duration<double>>(k_end - k_start);  
		
		auto b_start = std::chrono::high_resolution_clock::now();
		// run the brute force algorithm, in order to obtain the true nearest neighbors
		list<pair<int, double>> kBF = bf_instant.kNeighboursBF(query_vectors.at(i), n_neighbors);
		auto b_end = std::chrono::high_resolution_clock::now();

		duration<double> bf_time_span = duration_cast<duration<double>>(b_end - b_start);  

		// denote the number of neighbor we are dealing with
		int k_value = 0;

		// itterate the list of results of the knn
		list<pair<int,double>>::iterator knn_it = kNNs.begin();
		list<pair<int,double>>::iterator bf_it = kBF.begin();

		for (; knn_it != kNNs.end() && bf_it != kBF.end() ; knn_it++, bf_it++) {
			// hold the results of the knn here
			auto knn_tuple = knn_it;
			auto bf_tuple = bf_it;
			// output the findings of kNN
			output << "Nearest neighbor-" << k_value + 1 << ": " << knn_tuple->first << endl;
			// by the LSH
			output << "DistanceLSH:" << knn_tuple->second << endl;
			// and by brute force
			output << "DistanceTrue:" << bf_tuple->second << endl;
			if (knn_tuple->second == bf_tuple->second) {
				correct_computed++;
			}

			k_value++;
		}
		
		// Print the time elapsed while computing the neighbors with kNN and BF
		output << "tLSH: " << knn_time_span.count() << endl;
		output << "tTrue: " << bf_time_span.count() << endl;
		sum1 += knn_time_span.count();
		sum2 += bf_time_span.count();

		// RUn the Range Search algorithm
		list<pair<int, double>> range_search = lsh_instant.RangeSearch(query_vectors.at(i), radius, c);

		// print in the output file all of our findings
		output << "R-near neighbors:" << endl;
		for (list<pair<int,double>>::iterator it = range_search.begin(); it != range_search.end(); it++) {
			output << it->first << endl;
		}
		
		output << "\n\n\n";
	}
	cout << "mean lsh time " << sum1 / query_vectors.size() << endl;
	cout << "mean bf time " << sum2 / query_vectors.size() << endl;
	cout << "corectly computed neighbours " << correct_computed  << " out of " << n_neighbors * query_vectors.size() << endl;

	output.close();
	
	free(input_file);
	free(query_file);
	free(output_file);

	return 0;
}

// Assembly:
subq $0x6d8, %rsp            # imm = 0x6D8
movl $0x0, 0x6d4(%rsp)
movl %edi, 0x6d0(%rsp)
movq %rsi, 0x6c8(%rsp)
movq $0x0, 0x6c0(%rsp)
movq $0x0, 0x6b8(%rsp)
movq $0x0, 0x6b0(%rsp)
movq $0x0, 0x698(%rsp)
movq $0x0, 0x690(%rsp)
movl 0x6d0(%rsp), %edi
movq 0x6c8(%rsp), %rsi
movq %rsp, %rax
leaq 0x6a0(%rsp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x6a4(%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x6a8(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x6c0(%rsp), %rdx
leaq 0x6b0(%rsp), %rcx
leaq 0x6b8(%rsp), %r8
leaq 0x6ac(%rsp), %r9
callq 0x27f0
movq 0x6c0(%rsp), %rax
movq %rax, 0x1c8(%rsp)
leaq 0x657(%rsp), %rdi
movq %rdi, 0x1d0(%rsp)
callq 0x2380
movq 0x1c8(%rsp), %rsi
movq 0x1d0(%rsp), %rdx
leaq 0x658(%rsp), %rdi
callq 0x2230
jmp 0x527b
leaq 0x678(%rsp), %rdi
leaq 0x658(%rsp), %rsi
callq 0x2540
jmp 0x5292
leaq 0x658(%rsp), %rdi
callq 0x2120
leaq 0x657(%rsp), %rdi
callq 0x21e0
movq 0x6b8(%rsp), %rax
movq %rax, 0x1b8(%rsp)
leaq 0x607(%rsp), %rdi
movq %rdi, 0x1c0(%rsp)
callq 0x2380
movq 0x1b8(%rsp), %rsi
movq 0x1c0(%rsp), %rdx
leaq 0x608(%rsp), %rdi
callq 0x2230
jmp 0x52f0
leaq 0x628(%rsp), %rdi
leaq 0x608(%rsp), %rsi
callq 0x2540
jmp 0x5307
leaq 0x608(%rsp), %rdi
callq 0x2120
leaq 0x607(%rsp), %rdi
callq 0x21e0
leaq 0x678(%rsp), %rdi
callq 0x4d50
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0x1b7(%rsp)
je 0x535b
leaq 0x628(%rsp), %rdi
callq 0x4d50
cmpq $0x0, %rax
setne %al
movb %al, 0x1b7(%rsp)
movb 0x1b7(%rsp), %al
testb $0x1, %al
jne 0x5368
jmp 0x536d
jmp 0x541e
leaq 0xaeb4(%rip), %rdi      # 0x10228
leaq 0xaedc(%rip), %rsi      # 0x10257
movl $0x25, %edx
leaq 0xaee9(%rip), %rcx      # 0x10270
callq 0x2140
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
jmp 0x53c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
leaq 0x658(%rsp), %rdi
callq 0x2120
leaq 0x657(%rsp), %rdi
callq 0x21e0
jmp 0x62cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
jmp 0x540c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
leaq 0x608(%rsp), %rdi
callq 0x2120
leaq 0x607(%rsp), %rdi
callq 0x21e0
jmp 0x62c2
leaq 0x400(%rsp), %rdi
callq 0x2330
jmp 0x542d
movq 0x6b0(%rsp), %rsi
leaq 0x400(%rsp), %rdi
movl $0x10, %edx
callq 0x2030
jmp 0x5449
leaq 0x678(%rsp), %rdi
movq %rdi, 0x1a0(%rsp)
callq 0x4d50
movq 0x1a0(%rsp), %rdi
movl %eax, 0x3fc(%rsp)
movl $0x1, %esi
callq 0x62e0
movq %rax, 0x1a8(%rsp)
jmp 0x5481
movq 0x1a8(%rsp), %rdi
callq 0x3ec0
movl %eax, 0x3f8(%rsp)
movl $0x2, %edi
movl $0x20, %esi
callq 0x6320
movsd %xmm0, 0x198(%rsp)
jmp 0x54af
movsd 0x198(%rsp), %xmm0
movsd 0xad00(%rip), %xmm1     # 0x101c0
addsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0xaced(%rip), %xmm1     # 0x101c8
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x3f0(%rsp)
movl $0x100, 0x3ec(%rsp) # imm = 0x100
leaq 0x3d0(%rsp), %rdi
leaq 0x678(%rsp), %rsi
callq 0x6510
jmp 0x5514
leaq 0x3d0(%rsp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x6340
movsd %xmm0, 0x190(%rsp)
jmp 0x5531
movsd 0x190(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x168(%rsp)
leaq 0x3d0(%rsp), %rdi
callq 0x3510
movl 0x168(%rsp), %eax
movl %eax, 0x3e8(%rsp)
movl $0x1, 0x3cc(%rsp)
movl $0x0, 0x3c8(%rsp)
movl 0x6a8(%rsp), %eax
movl %eax, 0x16c(%rsp)
movq 0x3f0(%rsp), %rax
movq %rax, 0x170(%rsp)
movl 0x3ec(%rsp), %eax
movl %eax, 0x17c(%rsp)
movl 0x3fc(%rsp), %eax
movl %eax, 0x180(%rsp)
movl 0x6ac(%rsp), %eax
movl %eax, 0x184(%rsp)
movl 0x3f8(%rsp), %eax
movl %eax, 0x188(%rsp)
movl 0x3e8(%rsp), %eax
movl %eax, 0x18c(%rsp)
leaq 0x348(%rsp), %rdi
leaq 0x678(%rsp), %rsi
callq 0x6510
jmp 0x55f2
movl 0x184(%rsp), %r9d
movl 0x180(%rsp), %r8d
movl 0x17c(%rsp), %ecx
movq 0x170(%rsp), %rdx
movl 0x16c(%rsp), %esi
movl 0x188(%rsp), %edi
movl 0x18c(%rsp), %r10d
movq %rsp, %rax
leaq 0x348(%rsp), %r11
movq %r11, 0x10(%rax)
movl %r10d, 0x8(%rax)
movl %edi, (%rax)
leaq 0x360(%rsp), %rdi
callq 0x6610
jmp 0x564b
leaq 0x348(%rsp), %rdi
callq 0x3510
movl 0x3fc(%rsp), %eax
movl %eax, 0x160(%rsp)
movl 0x3f8(%rsp), %eax
movl %eax, 0x164(%rsp)
leaq 0x310(%rsp), %rdi
leaq 0x678(%rsp), %rsi
callq 0x6510
jmp 0x568b
movl 0x164(%rsp), %edx
movl 0x160(%rsp), %esi
leaq 0x328(%rsp), %rdi
leaq 0x310(%rsp), %rcx
callq 0x6cb0
jmp 0x56b0
leaq 0x310(%rsp), %rdi
callq 0x3510
movq $0x0, 0x308(%rsp)
movq 0x308(%rsp), %rax
movq %rax, 0x158(%rsp)
leaq 0x628(%rsp), %rdi
callq 0x4d50
movq %rax, %rcx
movq 0x158(%rsp), %rax
cmpq %rcx, %rax
jae 0x6056
leaq 0xab86(%rip), %rsi      # 0x10287
leaq 0x400(%rsp), %rdi
callq 0x21b0
movq %rax, 0x150(%rsp)
jmp 0x5718
movq 0x150(%rsp), %rdi
movq 0x308(%rsp), %rsi
callq 0x2070
movq %rax, 0x148(%rsp)
jmp 0x5737
movq 0x148(%rsp), %rdi
movq 0x11882(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x574d
callq 0x2040
movq %rax, 0x300(%rsp)
movq 0x308(%rsp), %rsi
leaq 0x628(%rsp), %rdi
callq 0x62e0
movq %rax, 0x140(%rsp)
jmp 0x5779
movq 0x140(%rsp), %rsi
leaq 0x2d0(%rsp), %rdi
callq 0x4500
jmp 0x5790
movl 0x6a4(%rsp), %ecx
leaq 0x2e8(%rsp), %rdi
leaq 0x360(%rsp), %rsi
leaq 0x2d0(%rsp), %rdx
callq 0x6d00
jmp 0x57b6
leaq 0x2d0(%rsp), %rdi
callq 0x34b0
callq 0x2040
movq %rax, 0x2c8(%rsp)
leaq 0x2c8(%rsp), %rdi
leaq 0x300(%rsp), %rsi
callq 0x74a0
movq %rax, 0x138(%rsp)
jmp 0x57ef
movq 0x138(%rsp), %rax
movq %rax, 0x2b8(%rsp)
leaq 0x2b8(%rsp), %rdi
callq 0x7470
movsd %xmm0, 0x130(%rsp)
jmp 0x5817
movsd 0x130(%rsp), %xmm0
movsd %xmm0, 0x2c0(%rsp)
callq 0x2040
movq %rax, 0x2b0(%rsp)
movq 0x308(%rsp), %rsi
leaq 0x628(%rsp), %rdi
callq 0x62e0
movq %rax, 0x128(%rsp)
jmp 0x5855
movq 0x128(%rsp), %rsi
leaq 0x280(%rsp), %rdi
callq 0x4500
jmp 0x586c
movl 0x6a4(%rsp), %ecx
leaq 0x298(%rsp), %rdi
leaq 0x328(%rsp), %rsi
leaq 0x280(%rsp), %rdx
callq 0x74f0
jmp 0x5892
leaq 0x280(%rsp), %rdi
callq 0x34b0
callq 0x2040
movq %rax, 0x278(%rsp)
leaq 0x278(%rsp), %rdi
leaq 0x2b0(%rsp), %rsi
callq 0x74a0
movq %rax, 0x120(%rsp)
jmp 0x58cb
movq 0x120(%rsp), %rax
movq %rax, 0x268(%rsp)
leaq 0x268(%rsp), %rdi
callq 0x7470
movsd %xmm0, 0x118(%rsp)
jmp 0x58f3
movsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x270(%rsp)
movl $0x0, 0x264(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0x7a80
movq %rax, 0x258(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x7a80
movq %rax, 0x250(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0x7ad0
movq %rax, 0x248(%rsp)
leaq 0x258(%rsp), %rdi
leaq 0x248(%rsp), %rsi
callq 0x7ab0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x117(%rsp)
jne 0x5976
jmp 0x59a7
leaq 0x298(%rsp), %rdi
callq 0x7ad0
movq %rax, 0x240(%rsp)
leaq 0x250(%rsp), %rdi
leaq 0x240(%rsp), %rsi
callq 0x7ab0
movb %al, 0x117(%rsp)
movb 0x117(%rsp), %al
testb $0x1, %al
jne 0x59b7
jmp 0x5d19
movq 0x258(%rsp), %rax
movq %rax, 0x238(%rsp)
movq 0x250(%rsp), %rax
movq %rax, 0x230(%rsp)
leaq 0xa8b1(%rip), %rsi      # 0x1028f
leaq 0x400(%rsp), %rdi
callq 0x21b0
movq %rax, 0x108(%rsp)
jmp 0x59f5
movq 0x108(%rsp), %rdi
movl 0x264(%rsp), %esi
incl %esi
callq 0x2350
movq %rax, 0x100(%rsp)
jmp 0x5a15
movq 0x100(%rsp), %rdi
leaq 0xa89c(%rip), %rsi      # 0x102c0
callq 0x21b0
movq %rax, 0xf8(%rsp)
jmp 0x5a33
leaq 0x238(%rsp), %rdi
callq 0x7b00
movq 0xf8(%rsp), %rdi
movl (%rax), %esi
callq 0x2350
movq %rax, 0xf0(%rsp)
jmp 0x5a59
movq 0xf0(%rsp), %rdi
movq 0x11560(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x5a6f
leaq 0xa82b(%rip), %rsi      # 0x102a1
leaq 0x400(%rsp), %rdi
callq 0x21b0
movq %rax, 0xe8(%rsp)
jmp 0x5a8d
leaq 0x238(%rsp), %rdi
callq 0x7b00
movq 0xe8(%rsp), %rdi
movsd 0x8(%rax), %xmm0
callq 0x23b0
movq %rax, 0xe0(%rsp)
jmp 0x5ab6
movq 0xe0(%rsp), %rdi
movq 0x11503(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x5acc
leaq 0xa7db(%rip), %rsi      # 0x102ae
leaq 0x400(%rsp), %rdi
callq 0x21b0
movq %rax, 0xd8(%rsp)
jmp 0x5aea
leaq 0x230(%rsp), %rdi
callq 0x7b00
movq 0xd8(%rsp), %rdi
movsd 0x8(%rax), %xmm0
callq 0x23b0
movq %rax, 0xd0(%rsp)
jmp 0x5b13
movq 0xd0(%rsp), %rdi
movq 0x114a6(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x5b29
leaq 0x238(%rsp), %rdi
callq 0x7b00
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0xc8(%rsp)
leaq 0x230(%rsp), %rdi
callq 0x7b00
movsd 0xc8(%rsp), %xmm0
ucomisd 0x8(%rax), %xmm0
jne 0x5cd5
jp 0x5cd5
movl 0x3c8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c8(%rsp)
jmp 0x5cd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
jmp 0x62b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
jmp 0x62a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
leaq 0x3d0(%rsp), %rdi
callq 0x3510
jmp 0x62a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
leaq 0x348(%rsp), %rdi
callq 0x3510
jmp 0x62a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
jmp 0x629b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
leaq 0x310(%rsp), %rdi
callq 0x3510
jmp 0x629b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
jmp 0x628e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
leaq 0x2d0(%rsp), %rdi
callq 0x34b0
jmp 0x628e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
jmp 0x6044
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
leaq 0x280(%rsp), %rdi
callq 0x34b0
jmp 0x6044
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
jmp 0x6037
movl 0x264(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x264(%rsp)
leaq 0x258(%rsp), %rdi
xorl %esi, %esi
callq 0x7b20
movq %rax, 0x228(%rsp)
leaq 0x250(%rsp), %rdi
xorl %esi, %esi
callq 0x7b20
movq %rax, 0x220(%rsp)
jmp 0x593a
leaq 0xa59c(%rip), %rsi      # 0x102bc
leaq 0x400(%rsp), %rdi
callq 0x21b0
movq %rax, 0xc0(%rsp)
jmp 0x5d37
leaq 0x2c0(%rsp), %rdi
callq 0x7b50
movsd %xmm0, 0xb8(%rsp)
jmp 0x5d4f
movsd 0xb8(%rsp), %xmm0
movq 0xc0(%rsp), %rdi
callq 0x23b0
movq %rax, 0xb0(%rsp)
jmp 0x5d6f
movq 0xb0(%rsp), %rdi
movq 0x1124a(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x5d85
leaq 0xa537(%rip), %rsi      # 0x102c3
leaq 0x400(%rsp), %rdi
callq 0x21b0
movq %rax, 0xa8(%rsp)
jmp 0x5da3
leaq 0x270(%rsp), %rdi
callq 0x7b50
movsd %xmm0, 0xa0(%rsp)
jmp 0x5dbb
movsd 0xa0(%rsp), %xmm0
movq 0xa8(%rsp), %rdi
callq 0x23b0
movq %rax, 0x98(%rsp)
jmp 0x5ddb
movq 0x98(%rsp), %rdi
movq 0x111de(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x5df1
leaq 0x2c0(%rsp), %rdi
callq 0x7b50
movsd %xmm0, 0x90(%rsp)
jmp 0x5e09
movsd 0x90(%rsp), %xmm1
movsd 0x698(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x698(%rsp)
leaq 0x270(%rsp), %rdi
callq 0x7b50
movsd %xmm0, 0x88(%rsp)
jmp 0x5e40
movsd 0x88(%rsp), %xmm1
movsd 0x690(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x690(%rsp)
movq 0x308(%rsp), %rsi
leaq 0x628(%rsp), %rdi
callq 0x62e0
movq %rax, 0x80(%rsp)
jmp 0x5e7e
movq 0x80(%rsp), %rsi
leaq 0x1f0(%rsp), %rdi
callq 0x4500
jmp 0x5e95
cvtsi2sdl 0x6a0(%rsp), %xmm0
movl 0x3cc(%rsp), %ecx
leaq 0x208(%rsp), %rdi
leaq 0x360(%rsp), %rsi
leaq 0x1f0(%rsp), %rdx
callq 0x7b60
jmp 0x5ec4
leaq 0x1f0(%rsp), %rdi
callq 0x34b0
leaq 0xa3f3(%rip), %rsi      # 0x102cb
leaq 0x400(%rsp), %rdi
callq 0x21b0
movq %rax, 0x78(%rsp)
jmp 0x5eec
movq 0x78(%rsp), %rdi
movq 0x110d0(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x5eff
leaq 0x208(%rsp), %rdi
callq 0x7a80
movq %rax, 0x1e8(%rsp)
leaq 0x208(%rsp), %rdi
callq 0x7ad0
movq %rax, 0x1e0(%rsp)
leaq 0x1e8(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x7ab0
testb $0x1, %al
jne 0x5f47
jmp 0x5fe1
leaq 0x1e8(%rsp), %rdi
callq 0x7b00
movl (%rax), %esi
leaq 0x400(%rsp), %rdi
callq 0x2350
movq %rax, 0x70(%rsp)
jmp 0x5f6a
movq 0x70(%rsp), %rdi
movq 0x11052(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x5f7d
jmp 0x5f7f
leaq 0x1e8(%rsp), %rdi
xorl %esi, %esi
callq 0x7b20
movq %rax, 0x1d8(%rsp)
jmp 0x5f14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0x34b0
jmp 0x6037
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x648(%rsp)
movl %eax, 0x644(%rsp)
leaq 0x208(%rsp), %rdi
callq 0x8000
jmp 0x6037
leaq 0xa2f5(%rip), %rsi      # 0x102dd
leaq 0x400(%rsp), %rdi
callq 0x21b0
jmp 0x5ff7
leaq 0x208(%rsp), %rdi
callq 0x8000
leaq 0x298(%rsp), %rdi
callq 0x8000
leaq 0x2e8(%rsp), %rdi
callq 0x8000
movq 0x308(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x308(%rsp)
jmp 0x56c9
leaq 0x298(%rsp), %rdi
callq 0x8000
leaq 0x2e8(%rsp), %rdi
callq 0x8000
jmp 0x628e
movq 0x10f7b(%rip), %rdi     # 0x16fd8
leaq 0xa27d(%rip), %rsi      # 0x102e1
callq 0x21b0
movq %rax, 0x68(%rsp)
jmp 0x6070
movsd 0x698(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
leaq 0x628(%rsp), %rdi
callq 0x4d50
movsd 0x58(%rsp), %xmm0
movq 0x68(%rsp), %rdi
movq %rax, %xmm1
movaps 0xa14d(%rip), %xmm2     # 0x101f0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xa151(%rip), %xmm2     # 0x10200
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x23b0
movq %rax, 0x60(%rsp)
jmp 0x60ce
movq 0x60(%rsp), %rdi
movq 0x10eee(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x60e1
movq 0x10ef0(%rip), %rdi     # 0x16fd8
leaq 0xa201(%rip), %rsi      # 0x102f0
callq 0x21b0
movq %rax, 0x50(%rsp)
jmp 0x60fb
movsd 0x690(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
leaq 0x628(%rsp), %rdi
callq 0x4d50
movsd 0x40(%rsp), %xmm0
movq 0x50(%rsp), %rdi
movq %rax, %xmm1
movaps 0xa0c2(%rip), %xmm2     # 0x101f0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xa0c6(%rip), %xmm2     # 0x10200
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x23b0
movq %rax, 0x48(%rsp)
jmp 0x6159
movq 0x48(%rsp), %rdi
movq 0x10e63(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x616c
movq 0x10e65(%rip), %rdi     # 0x16fd8
leaq 0xa184(%rip), %rsi      # 0x102fe
callq 0x21b0
movq %rax, 0x38(%rsp)
jmp 0x6186
movq 0x38(%rsp), %rdi
movl 0x3c8(%rsp), %esi
callq 0x2350
movq %rax, 0x30(%rsp)
jmp 0x619e
movq 0x30(%rsp), %rdi
leaq 0xa172(%rip), %rsi      # 0x1031c
callq 0x21b0
movq %rax, 0x28(%rsp)
jmp 0x61b6
movslq 0x6a4(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x628(%rsp), %rdi
callq 0x4d50
movq 0x18(%rsp), %rsi
movq 0x28(%rsp), %rdi
imulq %rax, %rsi
callq 0x2070
movq %rax, 0x20(%rsp)
jmp 0x61ea
movq 0x20(%rsp), %rdi
movq 0x10dd2(%rip), %rsi     # 0x16fc8
callq 0x21d0
jmp 0x61fd
leaq 0x400(%rsp), %rdi
callq 0x2260
jmp 0x620c
movq 0x6c0(%rsp), %rdi
callq 0x2200
movq 0x6b8(%rsp), %rdi
callq 0x2200
movq 0x6b0(%rsp), %rdi
callq 0x2200
movl $0x0, 0x6d4(%rsp)
leaq 0x328(%rsp), %rdi
callq 0x8010
leaq 0x360(%rsp), %rdi
callq 0x8030
leaq 0x400(%rsp), %rdi
callq 0x2290
leaq 0x628(%rsp), %rdi
callq 0x3510
leaq 0x678(%rsp), %rdi
callq 0x3510
movl 0x6d4(%rsp), %eax
addq $0x6d8, %rsp            # imm = 0x6D8
retq
leaq 0x328(%rsp), %rdi
callq 0x8010
leaq 0x360(%rsp), %rdi
callq 0x8030
leaq 0x400(%rsp), %rdi
callq 0x2290
leaq 0x628(%rsp), %rdi
callq 0x3510
leaq 0x678(%rsp), %rdi
callq 0x3510
movq 0x648(%rsp), %rdi
callq 0x2370
nopl (%rax)