// File: nikosgalanis[P]Vectors-Similarity-Search-and-Clustering/programs/Hypercube/hypercube_main.cc
// Function: main
int main(int argc, char* argv[]) {
    // parsing the arguments

    char* input_file = NULL, *query_file = NULL, *output_file = NULL;
	int k, M, probes, n_neighbors, radius;
	double sum1 = 0, sum2 = 0;

	parse_hc_args(argc, argv, &input_file, &output_file, &query_file, &k, &M, &probes, &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 Hypercube results
	ofstream output;
	output.open(output_file);

    // default hypercube values
    uint64_t m = pow(2,32) - 5;
    uint32_t w = 20 * our_math::compute_w_value(feature_vectors, 1000);
	uint32_t c = 1; 

    int correct_computed = 0;

    int n_points = feature_vectors.size();
	int space_dimension = feature_vectors.at(0).size();

    // Initialize hypercube class
    Hypercube<double> hypercube_instant(k, m, M, probes, n_points, w, space_dimension, 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 Hypercube
    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 = hypercube_instant.kNearestNeighbour(query_vectors.at(i), n_neighbors);
		auto k_end = std::chrono::high_resolution_clock::now();

		duration<double> hc_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() ; bf_it++, knn_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 Hypercube
			output << "DistanceHypercube:" << 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 << "tHC: " << hc_time_span.count() << endl;
		output << "tTrue: " << bf_time_span.count() << endl;
		sum1 += hc_time_span.count();
		sum2 += bf_time_span.count();

		// RUn the Range Search algorithm
		list<pair<int, double>> range_search = hypercube_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 hc 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 $0x708, %rsp            # imm = 0x708
movl $0x0, 0x704(%rsp)
movl %edi, 0x700(%rsp)
movq %rsi, 0x6f8(%rsp)
movq $0x0, 0x6f0(%rsp)
movq $0x0, 0x6e8(%rsp)
movq $0x0, 0x6e0(%rsp)
movq $0x0, 0x6c0(%rsp)
movq $0x0, 0x6b8(%rsp)
movl 0x700(%rsp), %edi
movq 0x6f8(%rsp), %rsi
movq %rsp, %rax
leaq 0x6cc(%rsp), %rcx
movq %rcx, 0x18(%rax)
leaq 0x6d0(%rsp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x6d4(%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x6d8(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x6f0(%rsp), %rdx
leaq 0x6e0(%rsp), %rcx
leaq 0x6e8(%rsp), %r8
leaq 0x6dc(%rsp), %r9
callq 0x2b20
movq 0x6f0(%rsp), %rax
movq %rax, 0x1d0(%rsp)
leaq 0x67f(%rsp), %rdi
movq %rdi, 0x1d8(%rsp)
callq 0x23d0
movq 0x1d0(%rsp), %rsi
movq 0x1d8(%rsp), %rdx
leaq 0x680(%rsp), %rdi
callq 0x2270
jmp 0x52e7
leaq 0x6a0(%rsp), %rdi
leaq 0x680(%rsp), %rsi
callq 0x25a0
jmp 0x52fe
leaq 0x680(%rsp), %rdi
callq 0x2110
leaq 0x67f(%rsp), %rdi
callq 0x21f0
movq 0x6e8(%rsp), %rax
movq %rax, 0x1c0(%rsp)
leaq 0x62f(%rsp), %rdi
movq %rdi, 0x1c8(%rsp)
callq 0x23d0
movq 0x1c0(%rsp), %rsi
movq 0x1c8(%rsp), %rdx
leaq 0x630(%rsp), %rdi
callq 0x2270
jmp 0x535c
leaq 0x650(%rsp), %rdi
leaq 0x630(%rsp), %rsi
callq 0x25a0
jmp 0x5373
leaq 0x630(%rsp), %rdi
callq 0x2110
leaq 0x62f(%rsp), %rdi
callq 0x21f0
leaq 0x6a0(%rsp), %rdi
callq 0x4db0
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0x1bf(%rsp)
je 0x53c7
leaq 0x650(%rsp), %rdi
callq 0x4db0
cmpq $0x0, %rax
setne %al
movb %al, 0x1bf(%rsp)
movb 0x1bf(%rsp), %al
testb $0x1, %al
jne 0x53d4
jmp 0x53d9
jmp 0x548a
leaq 0xce5c(%rip), %rdi      # 0x1223c
leaq 0xce84(%rip), %rsi      # 0x1226b
movl $0x25, %edx
leaq 0xce9d(%rip), %rcx      # 0x12290
callq 0x2130
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
jmp 0x542f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
leaq 0x680(%rsp), %rdi
callq 0x2110
leaq 0x67f(%rsp), %rdi
callq 0x21f0
jmp 0x6341
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
jmp 0x5478
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
leaq 0x630(%rsp), %rdi
callq 0x2110
leaq 0x62f(%rsp), %rdi
callq 0x21f0
jmp 0x6334
leaq 0x428(%rsp), %rdi
callq 0x2380
jmp 0x5499
movq 0x6e0(%rsp), %rsi
leaq 0x428(%rsp), %rdi
movl $0x10, %edx
callq 0x2030
jmp 0x54b5
movl $0x2, %edi
movl $0x20, %esi
callq 0x6350
movsd %xmm0, 0x1b0(%rsp)
jmp 0x54cf
movsd 0x1b0(%rsp), %xmm0
movsd 0xcce0(%rip), %xmm1     # 0x121c0
addsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0xcccd(%rip), %xmm1     # 0x121c8
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x420(%rsp)
leaq 0x400(%rsp), %rdi
leaq 0x6a0(%rsp), %rsi
callq 0x6540
jmp 0x5529
leaq 0x400(%rsp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x6370
movsd %xmm0, 0x1a8(%rsp)
jmp 0x5546
movsd 0x1a8(%rsp), %xmm0
movsd 0xcc79(%rip), %xmm1     # 0x121d0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x194(%rsp)
leaq 0x400(%rsp), %rdi
callq 0x3570
movl 0x194(%rsp), %eax
movl %eax, 0x41c(%rsp)
movl $0x1, 0x3fc(%rsp)
movl $0x0, 0x3f8(%rsp)
leaq 0x6a0(%rsp), %rdi
movq %rdi, 0x198(%rsp)
callq 0x4db0
movq 0x198(%rsp), %rdi
movl %eax, 0x3f4(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x6640
movq %rax, 0x1a0(%rsp)
jmp 0x55cf
movq 0x1a0(%rsp), %rdi
callq 0x3f20
movl %eax, 0x3f0(%rsp)
movl 0x6dc(%rsp), %eax
movl %eax, 0x174(%rsp)
movq 0x420(%rsp), %rax
movq %rax, 0x178(%rsp)
movl 0x6d8(%rsp), %eax
movl %eax, 0x180(%rsp)
movl 0x6d4(%rsp), %eax
movl %eax, 0x184(%rsp)
movl 0x3f4(%rsp), %eax
movl %eax, 0x188(%rsp)
movl 0x41c(%rsp), %eax
movl %eax, 0x18c(%rsp)
movl 0x3f0(%rsp), %eax
movl %eax, 0x190(%rsp)
leaq 0x350(%rsp), %rdi
leaq 0x6a0(%rsp), %rsi
callq 0x6540
jmp 0x565e
movl 0x188(%rsp), %r9d
movl 0x184(%rsp), %r8d
movl 0x180(%rsp), %ecx
movq 0x178(%rsp), %rdx
movl 0x174(%rsp), %esi
movl 0x18c(%rsp), %edi
movl 0x190(%rsp), %r10d
movq %rsp, %rax
leaq 0x350(%rsp), %r11
movq %r11, 0x10(%rax)
movl %r10d, 0x8(%rax)
movl %edi, (%rax)
leaq 0x368(%rsp), %rdi
callq 0x6680
jmp 0x56b7
leaq 0x350(%rsp), %rdi
callq 0x3570
movl 0x3f4(%rsp), %eax
movl %eax, 0x16c(%rsp)
movl 0x3f0(%rsp), %eax
movl %eax, 0x170(%rsp)
leaq 0x318(%rsp), %rdi
leaq 0x6a0(%rsp), %rsi
callq 0x6540
jmp 0x56f7
movl 0x170(%rsp), %edx
movl 0x16c(%rsp), %esi
leaq 0x330(%rsp), %rdi
leaq 0x318(%rsp), %rcx
callq 0x6d20
jmp 0x571c
leaq 0x318(%rsp), %rdi
callq 0x3570
movq $0x0, 0x310(%rsp)
movq 0x310(%rsp), %rax
movq %rax, 0x160(%rsp)
leaq 0x650(%rsp), %rdi
callq 0x4db0
movq %rax, %rcx
movq 0x160(%rsp), %rax
cmpq %rcx, %rax
jae 0x60c8
leaq 0xcb3a(%rip), %rsi      # 0x122a7
leaq 0x428(%rsp), %rdi
callq 0x21c0
movq %rax, 0x158(%rsp)
jmp 0x5784
movq 0x158(%rsp), %rdi
movq 0x310(%rsp), %rsi
callq 0x2070
movq %rax, 0x150(%rsp)
jmp 0x57a3
movq 0x150(%rsp), %rdi
movq 0x14816(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x57b9
callq 0x2040
movq %rax, 0x308(%rsp)
movq 0x310(%rsp), %rsi
leaq 0x650(%rsp), %rdi
callq 0x6640
movq %rax, 0x148(%rsp)
jmp 0x57e5
movq 0x148(%rsp), %rsi
leaq 0x2d8(%rsp), %rdi
callq 0x4560
jmp 0x57fc
movl 0x6d0(%rsp), %ecx
leaq 0x2f0(%rsp), %rdi
leaq 0x368(%rsp), %rsi
leaq 0x2d8(%rsp), %rdx
callq 0x6d70
jmp 0x5822
leaq 0x2d8(%rsp), %rdi
callq 0x3510
callq 0x2040
movq %rax, 0x2d0(%rsp)
leaq 0x2d0(%rsp), %rdi
leaq 0x308(%rsp), %rsi
callq 0x7bf0
movq %rax, 0x140(%rsp)
jmp 0x585b
movq 0x140(%rsp), %rax
movq %rax, 0x2c0(%rsp)
leaq 0x2c0(%rsp), %rdi
callq 0x7bc0
movsd %xmm0, 0x138(%rsp)
jmp 0x5883
movsd 0x138(%rsp), %xmm0
movsd %xmm0, 0x2c8(%rsp)
callq 0x2040
movq %rax, 0x2b8(%rsp)
movq 0x310(%rsp), %rsi
leaq 0x650(%rsp), %rdi
callq 0x6640
movq %rax, 0x130(%rsp)
jmp 0x58c1
movq 0x130(%rsp), %rsi
leaq 0x288(%rsp), %rdi
callq 0x4560
jmp 0x58d8
movl 0x6d0(%rsp), %ecx
leaq 0x2a0(%rsp), %rdi
leaq 0x330(%rsp), %rsi
leaq 0x288(%rsp), %rdx
callq 0x7c40
jmp 0x58fe
leaq 0x288(%rsp), %rdi
callq 0x3510
callq 0x2040
movq %rax, 0x280(%rsp)
leaq 0x280(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0x7bf0
movq %rax, 0x128(%rsp)
jmp 0x5937
movq 0x128(%rsp), %rax
movq %rax, 0x270(%rsp)
leaq 0x270(%rsp), %rdi
callq 0x7bc0
movsd %xmm0, 0x120(%rsp)
jmp 0x595f
movsd 0x120(%rsp), %xmm0
movsd %xmm0, 0x278(%rsp)
movl $0x0, 0x26c(%rsp)
leaq 0x2f0(%rsp), %rdi
callq 0x81d0
movq %rax, 0x260(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0x81d0
movq %rax, 0x258(%rsp)
leaq 0x2f0(%rsp), %rdi
callq 0x8220
movq %rax, 0x250(%rsp)
leaq 0x260(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x8200
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x11f(%rsp)
jne 0x59e2
jmp 0x5a13
leaq 0x2a0(%rsp), %rdi
callq 0x8220
movq %rax, 0x248(%rsp)
leaq 0x258(%rsp), %rdi
leaq 0x248(%rsp), %rsi
callq 0x8200
movb %al, 0x11f(%rsp)
movb 0x11f(%rsp), %al
testb $0x1, %al
jne 0x5a23
jmp 0x5d85
movq 0x260(%rsp), %rax
movq %rax, 0x240(%rsp)
movq 0x258(%rsp), %rax
movq %rax, 0x238(%rsp)
leaq 0xc865(%rip), %rsi      # 0x122af
leaq 0x428(%rsp), %rdi
callq 0x21c0
movq %rax, 0x110(%rsp)
jmp 0x5a61
movq 0x110(%rsp), %rdi
movl 0x26c(%rsp), %esi
incl %esi
callq 0x23a0
movq %rax, 0x108(%rsp)
jmp 0x5a81
movq 0x108(%rsp), %rdi
leaq 0xc855(%rip), %rsi      # 0x122e5
callq 0x21c0
movq %rax, 0x100(%rsp)
jmp 0x5a9f
leaq 0x240(%rsp), %rdi
callq 0x8250
movq 0x100(%rsp), %rdi
movl (%rax), %esi
callq 0x23a0
movq %rax, 0xf8(%rsp)
jmp 0x5ac5
movq 0xf8(%rsp), %rdi
movq 0x144f4(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x5adb
leaq 0xc7df(%rip), %rsi      # 0x122c1
leaq 0x428(%rsp), %rdi
callq 0x21c0
movq %rax, 0xf0(%rsp)
jmp 0x5af9
leaq 0x240(%rsp), %rdi
callq 0x8250
movq 0xf0(%rsp), %rdi
movsd 0x8(%rax), %xmm0
callq 0x2400
movq %rax, 0xe8(%rsp)
jmp 0x5b22
movq 0xe8(%rsp), %rdi
movq 0x14497(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x5b38
leaq 0xc795(%rip), %rsi      # 0x122d4
leaq 0x428(%rsp), %rdi
callq 0x21c0
movq %rax, 0xe0(%rsp)
jmp 0x5b56
leaq 0x238(%rsp), %rdi
callq 0x8250
movq 0xe0(%rsp), %rdi
movsd 0x8(%rax), %xmm0
callq 0x2400
movq %rax, 0xd8(%rsp)
jmp 0x5b7f
movq 0xd8(%rsp), %rdi
movq 0x1443a(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x5b95
leaq 0x240(%rsp), %rdi
callq 0x8250
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0xd0(%rsp)
leaq 0x238(%rsp), %rdi
callq 0x8250
movsd 0xd0(%rsp), %xmm0
ucomisd 0x8(%rax), %xmm0
jne 0x5d41
jp 0x5d41
movl 0x3f8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3f8(%rsp)
jmp 0x5d41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
jmp 0x6327
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
jmp 0x631a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
leaq 0x400(%rsp), %rdi
callq 0x3570
jmp 0x631a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
leaq 0x350(%rsp), %rdi
callq 0x3570
jmp 0x631a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
jmp 0x630d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x3570
jmp 0x630d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
jmp 0x6300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
leaq 0x2d8(%rsp), %rdi
callq 0x3510
jmp 0x6300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
jmp 0x60b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
leaq 0x288(%rsp), %rdi
callq 0x3510
jmp 0x60b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
jmp 0x60a9
movl 0x26c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x26c(%rsp)
leaq 0x258(%rsp), %rdi
xorl %esi, %esi
callq 0x8270
movq %rax, 0x230(%rsp)
leaq 0x260(%rsp), %rdi
xorl %esi, %esi
callq 0x8270
movq %rax, 0x228(%rsp)
jmp 0x59a6
leaq 0xc556(%rip), %rsi      # 0x122e2
leaq 0x428(%rsp), %rdi
callq 0x21c0
movq %rax, 0xc8(%rsp)
jmp 0x5da3
leaq 0x2c8(%rsp), %rdi
callq 0x82a0
movsd %xmm0, 0xc0(%rsp)
jmp 0x5dbb
movsd 0xc0(%rsp), %xmm0
movq 0xc8(%rsp), %rdi
callq 0x2400
movq %rax, 0xb8(%rsp)
jmp 0x5ddb
movq 0xb8(%rsp), %rdi
movq 0x141de(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x5df1
leaq 0xc4f0(%rip), %rsi      # 0x122e8
leaq 0x428(%rsp), %rdi
callq 0x21c0
movq %rax, 0xb0(%rsp)
jmp 0x5e0f
leaq 0x278(%rsp), %rdi
callq 0x82a0
movsd %xmm0, 0xa8(%rsp)
jmp 0x5e27
movsd 0xa8(%rsp), %xmm0
movq 0xb0(%rsp), %rdi
callq 0x2400
movq %rax, 0xa0(%rsp)
jmp 0x5e47
movq 0xa0(%rsp), %rdi
movq 0x14172(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x5e5d
leaq 0x2c8(%rsp), %rdi
callq 0x82a0
movsd %xmm0, 0x98(%rsp)
jmp 0x5e75
movsd 0x98(%rsp), %xmm1
movsd 0x6c0(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x6c0(%rsp)
leaq 0x278(%rsp), %rdi
callq 0x82a0
movsd %xmm0, 0x90(%rsp)
jmp 0x5eac
movsd 0x90(%rsp), %xmm1
movsd 0x6b8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x6b8(%rsp)
movq 0x310(%rsp), %rsi
leaq 0x650(%rsp), %rdi
callq 0x6640
movq %rax, 0x88(%rsp)
jmp 0x5eea
movq 0x88(%rsp), %rsi
leaq 0x1f8(%rsp), %rdi
callq 0x4560
jmp 0x5f01
cvtsi2sdl 0x6cc(%rsp), %xmm0
movl 0x3fc(%rsp), %ecx
leaq 0x210(%rsp), %rdi
leaq 0x368(%rsp), %rsi
leaq 0x1f8(%rsp), %rdx
callq 0x82b0
jmp 0x5f30
leaq 0x1f8(%rsp), %rdi
callq 0x3510
leaq 0xc3ac(%rip), %rsi      # 0x122f0
leaq 0x428(%rsp), %rdi
callq 0x21c0
movq %rax, 0x80(%rsp)
jmp 0x5f5b
movq 0x80(%rsp), %rdi
movq 0x1405e(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x5f71
leaq 0x210(%rsp), %rdi
callq 0x81d0
movq %rax, 0x1f0(%rsp)
leaq 0x210(%rsp), %rdi
callq 0x8220
movq %rax, 0x1e8(%rsp)
leaq 0x1f0(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x8200
testb $0x1, %al
jne 0x5fb9
jmp 0x6053
leaq 0x1f0(%rsp), %rdi
callq 0x8250
movl (%rax), %esi
leaq 0x428(%rsp), %rdi
callq 0x23a0
movq %rax, 0x78(%rsp)
jmp 0x5fdc
movq 0x78(%rsp), %rdi
movq 0x13fe0(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x5fef
jmp 0x5ff1
leaq 0x1f0(%rsp), %rdi
xorl %esi, %esi
callq 0x8270
movq %rax, 0x1e0(%rsp)
jmp 0x5f86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
leaq 0x1f8(%rsp), %rdi
callq 0x3510
jmp 0x60a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x670(%rsp)
movl %eax, 0x66c(%rsp)
leaq 0x210(%rsp), %rdi
callq 0x89b0
jmp 0x60a9
leaq 0xc2a8(%rip), %rsi      # 0x12302
leaq 0x428(%rsp), %rdi
callq 0x21c0
jmp 0x6069
leaq 0x210(%rsp), %rdi
callq 0x89b0
leaq 0x2a0(%rsp), %rdi
callq 0x89b0
leaq 0x2f0(%rsp), %rdi
callq 0x89b0
movq 0x310(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x310(%rsp)
jmp 0x5735
leaq 0x2a0(%rsp), %rdi
callq 0x89b0
leaq 0x2f0(%rsp), %rdi
callq 0x89b0
jmp 0x6300
movq 0x13f09(%rip), %rdi     # 0x19fd8
leaq 0xc230(%rip), %rsi      # 0x12306
callq 0x21c0
movq %rax, 0x70(%rsp)
jmp 0x60e2
movsd 0x6c0(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
leaq 0x650(%rsp), %rdi
callq 0x4db0
movsd 0x60(%rsp), %xmm0
movq 0x70(%rsp), %rdi
movq %rax, %xmm1
movaps 0xc0eb(%rip), %xmm2     # 0x12200
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xc0ef(%rip), %xmm2     # 0x12210
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x2400
movq %rax, 0x68(%rsp)
jmp 0x6140
movq 0x68(%rsp), %rdi
movq 0x13e7c(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x6153
movq 0x13e7e(%rip), %rdi     # 0x19fd8
leaq 0xc1b3(%rip), %rsi      # 0x12314
callq 0x21c0
movq %rax, 0x58(%rsp)
jmp 0x616d
movsd 0x6b8(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
leaq 0x650(%rsp), %rdi
callq 0x4db0
movsd 0x48(%rsp), %xmm0
movq 0x58(%rsp), %rdi
movq %rax, %xmm1
movaps 0xc060(%rip), %xmm2     # 0x12200
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xc064(%rip), %xmm2     # 0x12210
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x2400
movq %rax, 0x50(%rsp)
jmp 0x61cb
movq 0x50(%rsp), %rdi
movq 0x13df1(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x61de
movq 0x13df3(%rip), %rdi     # 0x19fd8
leaq 0xc136(%rip), %rsi      # 0x12322
callq 0x21c0
movq %rax, 0x40(%rsp)
jmp 0x61f8
movq 0x40(%rsp), %rdi
movl 0x3f8(%rsp), %esi
callq 0x23a0
movq %rax, 0x38(%rsp)
jmp 0x6210
movq 0x38(%rsp), %rdi
leaq 0xc124(%rip), %rsi      # 0x12340
callq 0x21c0
movq %rax, 0x30(%rsp)
jmp 0x6228
movslq 0x6d0(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x650(%rsp), %rdi
callq 0x4db0
movq 0x20(%rsp), %rsi
movq 0x30(%rsp), %rdi
imulq %rax, %rsi
callq 0x2070
movq %rax, 0x28(%rsp)
jmp 0x625c
movq 0x28(%rsp), %rdi
movq 0x13d60(%rip), %rsi     # 0x19fc8
callq 0x21e0
jmp 0x626f
leaq 0x428(%rsp), %rdi
callq 0x22b0
jmp 0x627e
movq 0x6f0(%rsp), %rdi
callq 0x2210
movq 0x6e8(%rsp), %rdi
callq 0x2210
movq 0x6e0(%rsp), %rdi
callq 0x2210
movl $0x0, 0x704(%rsp)
leaq 0x330(%rsp), %rdi
callq 0x89c0
leaq 0x368(%rsp), %rdi
callq 0x89e0
leaq 0x428(%rsp), %rdi
callq 0x22e0
leaq 0x650(%rsp), %rdi
callq 0x3570
leaq 0x6a0(%rsp), %rdi
callq 0x3570
movl 0x704(%rsp), %eax
addq $0x708, %rsp            # imm = 0x708
retq
leaq 0x330(%rsp), %rdi
callq 0x89c0
leaq 0x368(%rsp), %rdi
callq 0x89e0
leaq 0x428(%rsp), %rdi
callq 0x22e0
leaq 0x650(%rsp), %rdi
callq 0x3570
leaq 0x6a0(%rsp), %rdi
callq 0x3570
movq 0x670(%rsp), %rdi
callq 0x23c0
nop