// File: /workspace/github_cpp_makefile_star2_O1/tplinderoth[P]introDist/introDist.cpp
// Function: comp2DistPopAvg(std::basic_fstream<char, std::char_traits<char>>&, std::basic_fstream<char, std::char_traits<char>>&, unsigned int, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, double const*)
int comp2DistPopAvg (std::fstream &freqfile, std::fstream &genofile, unsigned int window, unsigned int step, std::string* genofname, const double* distance) {

	/*
	 * this calculates the difference in the genetic distance between individual i and population2 in a region and
	 * the expected distance between individual i's population and population2 averaged across the genome
	 *
	 * D = d_R(i, P2) - d_G(Pi, P2)
	 * subscript G denotes average over the genome
	 * subscript R denotes average across region
	 *
	 * at site s:
	 * expected distance between individual i and population 2: E[d(i, P2)] = |g_i - E[g_p2]|/2
	 * expected difference between the distance of individuals i's population and population 2: d(Pi, P2) = |E[g_p1] - E[g_p2]|/2
	 *
	 * d_G(Pi, P2) = 1/N_G * sum_from=1_to=N_G |E[g_p1] - E[g_p2]|/2, where N_G is total number of sites analyzed
	 *
	 * d_R(i, P2) = 1/N_R * sum_from=1_to=N_R |g_i - E[g_p2]|/2, where N_R is the number of sites in the window
	 *
	 * assumes individual i is from population 1
	 *
	 */

	std::vector<sitedist> dist;
	dist.resize(window);
	std::vector<sitedist>::iterator distiter = dist.begin();
	unsigned int lastidx = window-1;
	unsigned int nsites = 0;
	unsigned int dr_nsites = 0;
	double windD = 0.0;
	unsigned int i = 0;
	unsigned int n = window-step;
	double dg = 0.0;
	unsigned int dg_nsites = 0;

	std::stringstream ss;

	std::string(fline);
	std::string(fchr);
	unsigned int fpos;
	double p1f;
	double p2f;

	std::string(gline);
	std::string(gchr);
	unsigned int gpos;
	int geno;

	getline(freqfile, fline);
	getline(genofile, gline);

	// estimate number of lines of input files to set up vector to hold distances
	ss.str(gline);
	ss >> gchr;
	unsigned int nlines = ceil(filesize(genofname->c_str())/(gchr.size()+2*sizeof(int)-1));
	std::vector<WindowInfo> windist;
	windist.reserve(nlines/step + 10);

	// calculate windows
	while (!fline.empty()) {

		// parse frequency file lines
		ss.str(std::string());
		ss.clear();
		ss.str(fline);
		ss >> fchr >> fpos >> p1f >> p2f;

		// parse genotype file lines
		ss.str(std::string());
		ss.clear();
		ss.str(gline);
		ss >> gchr >> gpos >> geno;

		// ensure that files are synched
		if (gchr.compare(fchr) != 0 || gpos != fpos) {
			std::cerr << "Positions in input files differ\n";
			return -1;
		}

		distiter->first = gpos;
		if (geno < 0) {
			// missing data
			distiter->second = -3.0;
		} else {
			// update window information
			distiter->second = expectIndPopDist(geno, p2f);
			// update genome-wide distance
			dg += expect2PopDist(p1f, p2f);
			++dg_nsites;
		}
		++distiter;
		++nsites;

		if (distiter == dist.end()) {

			// calculate window value
			windD = 0.0;
			dr_nsites = 0;
			for (distiter = dist.begin(); distiter != dist.end(); ++distiter) {
				if (distiter->second < -2.0) continue;
				windD += distiter->second;
				++dr_nsites;
			}
			if (dr_nsites > 0) {
				windD /= (double)dr_nsites;
			} else {
				std::cerr << "Warning: window " << gchr << " " << dist[0].first << "," << dist[lastidx].first << " has no sites with data\n";
			}
			windist.push_back(makeWinInfo(dist[0].first, dist[lastidx].first, dr_nsites, windD));

			// prepare vector for new values
			for (i = 0; i < n; ++i) {
				dist[i].first = dist[step+i].first;
				dist[i].second = dist[step+i].second;
			}

			nsites = n;
			distiter = dist.begin() + n;
		}

		getline(freqfile, fline);
		getline(genofile, gline);
	}

	// calculate last window
	if (nsites > n && nsites < window) {
		unsigned int lastwinidx = nsites-1;
		dr_nsites = 0;
		windD = 0.0;
		for (i=0; i < lastwinidx; ++i) {
			if (dist[i].second < -2.0) continue;
			windD += dist[i].second;
			++dr_nsites;
		}
		if (dr_nsites > 0) {
			windD /= (double)dr_nsites;
		} else {
			std::cerr << "Warning: window " << gchr << " " << dist[0].first << "," << dist[lastwinidx].first << " has no sites with data\n";
		}
		windist.push_back(makeWinInfo(dist[0].first, dist[lastwinidx].first, dr_nsites, windD));
	}

	// calculate and print distance statistic
	if (dg_nsites > 0) {
		dg /= (double)dg_nsites;
	} else {
		std::cerr << "There were no sites with complete data, cannot calculate distance statistic\n";
		return 0; // use better exception handling here
	}
	std::cerr << "\nCalculated average distance between populations: " << dg << "\n";

	if (distance) {
		// use provided distance
		dg = *distance;
		std::cerr << "\nUsing distance: " << dg <<  "\n";
	}
	std::cerr << "\n";

	unsigned int midpoint = 0;
	double Dstat = 0.0;
	for (std::vector<WindowInfo>::iterator winditer = windist.begin(); winditer != windist.end(); ++winditer) {
		Dstat = winditer->d - dg;
		midpoint = (winditer->start + winditer->stop)/2;
		std::cout << gchr << "\t" << winditer->start << "\t" << winditer->stop << "\t" << midpoint << "\t" << Dstat << "\t" << winditer->nsites << "\n";
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movq %r9, %r14
movq %r8, %rbx
movl %ecx, -0x5c(%rbp)
movq %rsi, %r12
movq %rdi, %r13
xorpd %xmm0, %xmm0
leaq -0x80(%rbp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rdx, -0x100(%rbp)
movl %edx, %esi
callq 0x81c6
movq -0x80(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x3170
leaq -0xe8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x118(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x138(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0xb8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %edx
leaq -0xf8(%rbp), %rsi
movq %r13, %rdi
callq 0x33d0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %edx
leaq -0x148(%rbp), %rsi
movq %r12, %rdi
callq 0x33d0
leaq -0x2d0(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x32c0
leaq -0x2e8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3280
movq (%rbx), %rdi
callq 0x8fdd
movq -0xc0(%rbp), %rcx
addq $0x7, %rcx
movq $0x0, -0xa8(%rbp)
xorl %edx, %edx
divq %rcx
xorpd %xmm0, %xmm0
leaq -0xa0(%rbp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
xorl %edx, %edx
movl -0x5c(%rbp), %ebx
divl %ebx
leal 0xa(%rax), %esi
callq 0x8200
movq %r14, -0x150(%rbp)
movq -0x100(%rbp), %rcx
leal -0x1(%rcx), %eax
subl %ebx, %ecx
movl %eax, %eax
movl %ecx, -0x60(%rbp)
movl %ecx, %r14d
shlq $0x4, %r14
xorpd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
shlq $0x4, %rax
movq %rax, -0x108(%rbp)
movl $0x0, -0x64(%rbp)
cmpq $0x0, -0xf0(%rbp)
je 0x6ebd
leaq -0x48(%rbp), %rbx
movq %rbx, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
leaq -0x2d0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x32c0
movq -0x58(%rbp), %rdi
cmpq %rbx, %rdi
je 0x6965
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x2e8(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x2e8(%rbp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x3350
leaq -0x2d0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x32c0
leaq -0x2e8(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x3280
movq %rax, %rdi
leaq -0xd4(%rbp), %rsi
callq 0x3380
movq %rax, %rdi
leaq -0x160(%rbp), %rsi
callq 0x3140
movq %rax, %rdi
leaq -0x158(%rbp), %rsi
callq 0x3140
movq %rbx, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
leaq -0x2d0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x32c0
movq -0x58(%rbp), %rdi
cmpq %rbx, %rdi
je 0x6a09
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x2e8(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x2e8(%rbp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x3350
leaq -0x2d0(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x32c0
leaq -0x2e8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3280
movq %rax, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3380
movq %rax, %rdi
leaq -0xcc(%rbp), %rsi
callq 0x3130
movq %r13, %r15
movq %r12, %rbx
movq -0xc0(%rbp), %r12
movq -0x120(%rbp), %r13
cmpq %r12, %r13
movq %r12, %rdx
cmovbq %r13, %rdx
testq %rdx, %rdx
je 0x6aa6
movq -0x128(%rbp), %rsi
movq -0xc8(%rbp), %rdi
callq 0x3230
testl %eax, %eax
sete %al
jmp 0x6aa8
movb $0x1, %al
movq -0x30(%rbp), %rcx
testb %al, %al
je 0x6db3
cmpq %r13, %r12
jne 0x6db3
movl -0xd0(%rbp), %eax
cmpl -0xd4(%rbp), %eax
jne 0x6db3
movl %eax, (%rcx)
movl -0xcc(%rbp), %eax
testl %eax, %eax
js 0x6b80
cvtsi2sd %eax, %xmm0
movsd -0x158(%rbp), %xmm1
movapd %xmm1, %xmm2
addsd %xmm1, %xmm2
movsd 0x350d(%rip), %xmm4     # 0xa008
movapd %xmm4, %xmm3
subsd %xmm1, %xmm3
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm3
addsd %xmm1, %xmm3
subsd %xmm3, %xmm0
movapd 0x3535(%rip), %xmm5     # 0xa050
andpd %xmm5, %xmm0
movsd 0x3509(%rip), %xmm6     # 0xa030
mulsd %xmm6, %xmm0
movsd %xmm0, 0x8(%rcx)
movsd -0x160(%rbp), %xmm0
movapd %xmm0, %xmm1
addsd %xmm0, %xmm1
movapd %xmm4, %xmm2
subsd %xmm0, %xmm2
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
subsd %xmm3, %xmm2
andpd %xmm5, %xmm2
mulsd %xmm6, %xmm2
movsd -0x38(%rbp), %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0xa8(%rbp), %rax
incl %eax
movq %rax, -0xa8(%rbp)
jmp 0x6b8e
movabsq $-0x3ff8000000000000, %rax # imm = 0xC008000000000000
movq %rax, 0x8(%rcx)
movq %rbx, %r12
movq %r15, %r13
addq $0x10, %rcx
movq -0x78(%rbp), %rax
cmpq %rax, %rcx
je 0x6bad
movq %rcx, -0x30(%rbp)
incl -0x64(%rbp)
jmp 0x6d60
movq -0x80(%rbp), %rcx
cmpq %rax, %rcx
je 0x6bf8
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorl %ebx, %ebx
movsd 0x8(%rcx), %xmm0
xorl %edx, %edx
movsd 0x3470(%rip), %xmm1     # 0xa040
ucomisd %xmm0, %xmm1
setbe %sil
ja 0x6be8
movsd -0x30(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
movb %sil, %dl
addl %edx, %ebx
addq $0x10, %rcx
cmpq %rax, %rcx
jne 0x6bc1
jmp 0x6c03
xorl %ebx, %ebx
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
testl %ebx, %ebx
je 0x6c24
movl %ebx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
jmp 0x6cbc
movl $0x10, %edx
movq 0x73c0(%rip), %rdi      # 0xdff0
leaq 0x381a(%rip), %rsi      # 0xa451
callq 0x3250
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq 0x739f(%rip), %rdi      # 0xdff0
callq 0x3250
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3f8f(%rip), %rsi      # 0xabf7
callq 0x3250
movq -0x80(%rbp), %rax
movl (%rax), %esi
movq %r15, %rdi
callq 0x3150
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x37d5(%rip), %rsi      # 0xa462
callq 0x3250
movq -0x80(%rbp), %rax
movq -0x108(%rbp), %rcx
movl (%rax,%rcx), %esi
movq %r15, %rdi
callq 0x3150
movl $0x18, %edx
movq %rax, %rdi
leaq 0x37ad(%rip), %rsi      # 0xa464
callq 0x3250
movq -0x80(%rbp), %rax
movl (%rax), %ecx
movq -0x108(%rbp), %rdx
movl (%rax,%rdx), %eax
movl %ecx, -0x58(%rbp)
movl %eax, -0x54(%rbp)
movl %ebx, -0x50(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x98(%rbp), %rsi
cmpq -0x90(%rbp), %rsi
je 0x6d0d
movq -0x48(%rbp), %rax
movq %rax, 0x10(%rsi)
movupd -0x58(%rbp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, -0x98(%rbp)
movl -0x5c(%rbp), %ecx
jmp 0x6d20
leaq -0xa0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x89ea
movl -0x5c(%rbp), %ecx
cmpl $0x0, -0x60(%rbp)
je 0x6d4f
movq -0x80(%rbp), %rax
xorl %edx, %edx
movl %ecx, %esi
shlq $0x4, %rsi
movl (%rax,%rsi), %edi
movl %edi, (%rax,%rdx)
movsd 0x8(%rax,%rsi), %xmm0
movsd %xmm0, 0x8(%rax,%rdx)
addq $0x10, %rdx
incl %ecx
cmpq %rdx, %r14
jne 0x6d2c
movq -0x80(%rbp), %rax
addq %r14, %rax
movq %rax, -0x30(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x64(%rbp)
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %edx
movq %r13, %rdi
leaq -0xf8(%rbp), %rsi
callq 0x33d0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %edx
movq %r12, %rdi
leaq -0x148(%rbp), %rsi
callq 0x33d0
jmp 0x691e
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq 0x7230(%rip), %rdi      # 0xdff0
leaq 0x3590(%rip), %rsi      # 0xa357
movl $0x20, %edx
callq 0x3250
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x6dec
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
leaq -0xe8(%rbp), %rbx
leaq -0x118(%rbp), %r14
je 0x6e1c
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x148(%rbp), %rdi
leaq -0x138(%rbp), %rax
cmpq %rax, %rdi
je 0x6e3e
movq -0x138(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x128(%rbp), %rdi
cmpq %r14, %rdi
je 0x6e59
movq -0x118(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0xf8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x6e74
movq -0xe8(%rbp), %rsi
incq %rsi
callq 0x3220
movq 0x7135(%rip), %rsi      # 0xdfb0
leaq -0x2e8(%rbp), %rdi
callq 0x3190
leaq -0x268(%rbp), %rdi
callq 0x30e0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x6ea8
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movl %r15d, %eax
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl -0x64(%rbp), %edx
cmpl -0x60(%rbp), %edx
setbe %al
cmpl -0x100(%rbp), %edx
setae %cl
orb %al, %cl
jne 0x7054
decl %edx
movl %edx, %r14d
je 0x6f30
movq -0x80(%rbp), %rax
movq %r14, %rcx
shlq $0x4, %rcx
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorl %edx, %edx
xorl %r15d, %r15d
movsd 0x8(%rax,%rdx), %xmm0
xorl %esi, %esi
movsd 0x3139(%rip), %xmm1     # 0xa040
ucomisd %xmm0, %xmm1
setbe %dil
ja 0x6f1f
movsd -0x30(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
movb %dil, %sil
addl %esi, %r15d
addq $0x10, %rdx
cmpq %rdx, %rcx
jne 0x6ef7
jmp 0x6f3c
xorl %r15d, %r15d
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
testl %r15d, %r15d
je 0x6f5f
movl %r15d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
jmp 0x6ff7
movq 0x708a(%rip), %rdi      # 0xdff0
leaq 0x34e4(%rip), %rsi      # 0xa451
movl $0x10, %edx
callq 0x3250
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq 0x7064(%rip), %rdi      # 0xdff0
callq 0x3250
movq %rax, %rbx
leaq 0x3c5c(%rip), %rsi      # 0xabf7
movl $0x1, %edx
movq %rax, %rdi
callq 0x3250
movq -0x80(%rbp), %rax
movl (%rax), %esi
movq %rbx, %rdi
callq 0x3150
movq %rax, %rbx
leaq 0x34a2(%rip), %rsi      # 0xa462
movl $0x1, %edx
movq %rax, %rdi
callq 0x3250
movq -0x80(%rbp), %rax
movq %r14, %rcx
shlq $0x4, %rcx
movl (%rax,%rcx), %esi
movq %rbx, %rdi
callq 0x3150
leaq 0x347a(%rip), %rsi      # 0xa464
movl $0x18, %edx
movq %rax, %rdi
callq 0x3250
movq -0x80(%rbp), %rax
movl (%rax), %ecx
shlq $0x4, %r14
movl (%rax,%r14), %eax
movl %ecx, -0x58(%rbp)
movl %eax, -0x54(%rbp)
movl %r15d, -0x50(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x98(%rbp), %rsi
cmpq -0x90(%rbp), %rsi
je 0x7044
movq -0x48(%rbp), %rax
movq %rax, 0x10(%rsi)
movupd -0x58(%rbp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, -0x98(%rbp)
jmp 0x7054
leaq -0xa0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x89ea
cmpl $0x0, -0xa8(%rbp)
movq -0x150(%rbp), %rbx
je 0x7237
movq 0x6f81(%rip), %rdi      # 0xdff0
leaq 0x3454(%rip), %rsi      # 0xa4ca
movl $0x32, %edx
callq 0x3250
movl -0xa8(%rbp), %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movsd -0x38(%rbp), %xmm0
divsd %xmm1, %xmm0
movq 0x6f52(%rip), %rdi      # 0xdff0
movsd %xmm0, -0x38(%rbp)
callq 0x3320
leaq 0x3b03(%rip), %rsi      # 0xabb2
movl $0x1, %edx
movq %rax, %rdi
callq 0x3250
testq %rbx, %rbx
je 0x7107
movsd (%rbx), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x6f1f(%rip), %rdi      # 0xdff0
leaq 0x3425(%rip), %rsi      # 0xa4fd
movl $0x11, %edx
callq 0x3250
movq 0x6f07(%rip), %rdi      # 0xdff0
movsd -0x38(%rbp), %xmm0
callq 0x3320
leaq 0x3ab8(%rip), %rsi      # 0xabb2
movl $0x1, %edx
movq %rax, %rdi
callq 0x3250
movq 0x6ee2(%rip), %rdi      # 0xdff0
leaq 0x3a9d(%rip), %rsi      # 0xabb2
movl $0x1, %edx
callq 0x3250
movq -0xa0(%rbp), %rbx
xorl %r15d, %r15d
cmpq -0x98(%rbp), %rbx
je 0x6dd1
leaq 0x31ac(%rip), %r15      # 0xa2e9
leaq 0x3a6e(%rip), %r12      # 0xabb2
movsd 0x10(%rbx), %xmm0
movsd %xmm0, -0x30(%rbp)
movl 0x4(%rbx), %r14d
addl (%rbx), %r14d
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq 0x6e5e(%rip), %rdi      # 0xdfc8
callq 0x3250
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3250
movl (%rbx), %esi
movq %r13, %rdi
callq 0x3150
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3250
movl 0x4(%rbx), %esi
movq %r13, %rdi
callq 0x3150
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3250
shrl %r14d
movl %r14d, %esi
movq %r13, %rdi
callq 0x3150
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3250
movsd -0x30(%rbp), %xmm0
subsd -0x38(%rbp), %xmm0
movq %r13, %rdi
callq 0x3320
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x3250
movl 0x8(%rbx), %esi
movq %r13, %rdi
callq 0x3150
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x3250
addq $0x18, %rbx
cmpq -0x98(%rbp), %rbx
jne 0x7144
xorl %r15d, %r15d
jmp 0x6dd1
xorl %r15d, %r15d
movq 0x6daf(%rip), %rdi      # 0xdff0
leaq 0x3235(%rip), %rsi      # 0xa47d
movl $0x4c, %edx
callq 0x3250
jmp 0x6dd1
jmp 0x729c
jmp 0x729c
jmp 0x726b
jmp 0x725f
movq %rax, %r14
jmp 0x7361
jmp 0x729c
jmp 0x729c
movq %rax, %r14
leaq -0xe8(%rbp), %rbx
leaq -0x118(%rbp), %r15
jmp 0x72c8
jmp 0x7280
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %rbx, %rdi
je 0x729f
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3220
jmp 0x729f
jmp 0x729c
movq %rax, %r14
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
leaq -0xe8(%rbp), %rbx
leaq -0x118(%rbp), %r15
je 0x72c8
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x72ea
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x148(%rbp), %rdi
leaq -0x138(%rbp), %rax
cmpq %rax, %rdi
je 0x730c
movq -0x138(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x128(%rbp), %rdi
cmpq %r15, %rdi
je 0x7327
movq -0x118(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0xf8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x7342
movq -0xe8(%rbp), %rsi
incq %rsi
callq 0x3220
movq 0x6c67(%rip), %rsi      # 0xdfb0
leaq -0x2e8(%rbp), %rdi
callq 0x3190
leaq -0x268(%rbp), %rdi
callq 0x30e0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x7376
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movq %r14, %rdi
callq 0x3390