// File: /workspace/github_cpp_makefile_star2_O1/tplinderoth[P]introDist/introDist.cpp
// Function: comp2DistIndAvg(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 comp2DistIndAvg (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 genome-wide average distance between individual i and population2
	 *
	 * D = d_R(i, P2) - d_G(i, 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
	 *
	 * d_G(i, P2) = 1/N_G * sum_from=1_to=N_G |g_i - 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 += distiter->second;
			++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 genome-wide, average distance between individual and population2: " << 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 0x7a73
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 0x755b
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 0x75ff
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 0x769c
movq -0x128(%rbp), %rsi
movq -0xc8(%rbp), %rdi
callq 0x3230
testl %eax, %eax
sete %al
jmp 0x769e
movb $0x1, %al
movq -0x30(%rbp), %rcx
testb %al, %al
je 0x7969
cmpq %r13, %r12
jne 0x7969
movl -0xd0(%rbp), %eax
cmpl -0xd4(%rbp), %eax
jne 0x7969
movl %eax, (%rcx)
movl -0xcc(%rbp), %eax
testl %eax, %eax
js 0x7736
cvtsi2sd %eax, %xmm0
movsd -0x158(%rbp), %xmm1
movapd %xmm1, %xmm2
addsd %xmm1, %xmm2
movsd 0x291b(%rip), %xmm3     # 0xa008
subsd %xmm1, %xmm3
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm3
addsd %xmm1, %xmm3
subsd %xmm3, %xmm0
andpd 0x2947(%rip), %xmm0     # 0xa050
mulsd 0x291f(%rip), %xmm0     # 0xa030
movsd %xmm0, 0x8(%rcx)
movsd -0x38(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x38(%rbp)
movq -0xa8(%rbp), %rax
incl %eax
movq %rax, -0xa8(%rbp)
jmp 0x7744
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 0x7763
movq %rcx, -0x30(%rbp)
incl -0x64(%rbp)
jmp 0x7916
movq -0x80(%rbp), %rcx
cmpq %rax, %rcx
je 0x77ae
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorl %ebx, %ebx
movsd 0x8(%rcx), %xmm0
xorl %edx, %edx
movsd 0x28ba(%rip), %xmm1     # 0xa040
ucomisd %xmm0, %xmm1
setbe %sil
ja 0x779e
movsd -0x30(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
movb %sil, %dl
addl %edx, %ebx
addq $0x10, %rcx
cmpq %rax, %rcx
jne 0x7777
jmp 0x77b9
xorl %ebx, %ebx
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
testl %ebx, %ebx
je 0x77da
movl %ebx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
jmp 0x7872
movl $0x10, %edx
movq 0x680a(%rip), %rdi      # 0xdff0
leaq 0x2c64(%rip), %rsi      # 0xa451
callq 0x3250
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq 0x67e9(%rip), %rdi      # 0xdff0
callq 0x3250
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x33d9(%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 0x2c1f(%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 0x2bf7(%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 0x78c3
movq -0x48(%rbp), %rax
movq %rax, 0x10(%rsi)
movupd -0x58(%rbp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, -0x98(%rbp)
movl -0x5c(%rbp), %ecx
jmp 0x78d6
leaq -0xa0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x89ea
movl -0x5c(%rbp), %ecx
cmpl $0x0, -0x60(%rbp)
je 0x7905
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 0x78e2
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 0x7514
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq 0x667a(%rip), %rdi      # 0xdff0
leaq 0x29da(%rip), %rsi      # 0xa357
movl $0x20, %edx
callq 0x3250
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x79a2
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 0x79d2
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x148(%rbp), %rdi
leaq -0x138(%rbp), %rax
cmpq %rax, %rdi
je 0x79f4
movq -0x138(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x128(%rbp), %rdi
cmpq %r14, %rdi
je 0x7a0f
movq -0x118(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0xf8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x7a2a
movq -0xe8(%rbp), %rsi
incq %rsi
callq 0x3220
movq 0x657f(%rip), %rsi      # 0xdfb0
leaq -0x2e8(%rbp), %rdi
callq 0x3190
leaq -0x268(%rbp), %rdi
callq 0x30e0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x7a5e
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 0x7c0a
decl %edx
movl %edx, %r14d
je 0x7ae6
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 0x2583(%rip), %xmm1     # 0xa040
ucomisd %xmm0, %xmm1
setbe %dil
ja 0x7ad5
movsd -0x30(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
movb %dil, %sil
addl %esi, %r15d
addq $0x10, %rdx
cmpq %rdx, %rcx
jne 0x7aad
jmp 0x7af2
xorl %r15d, %r15d
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
testl %r15d, %r15d
je 0x7b15
movl %r15d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
jmp 0x7bad
movq 0x64d4(%rip), %rdi      # 0xdff0
leaq 0x292e(%rip), %rsi      # 0xa451
movl $0x10, %edx
callq 0x3250
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq 0x64ae(%rip), %rdi      # 0xdff0
callq 0x3250
movq %rax, %rbx
leaq 0x30a6(%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 0x28ec(%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 0x28c4(%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 0x7bfa
movq -0x48(%rbp), %rax
movq %rax, 0x10(%rsi)
movupd -0x58(%rbp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, -0x98(%rbp)
jmp 0x7c0a
leaq -0xa0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x89ea
cmpl $0x0, -0xa8(%rbp)
movq -0x150(%rbp), %rbx
je 0x7ded
movq 0x63cb(%rip), %rdi      # 0xdff0
leaq 0x28e3(%rip), %rsi      # 0xa50f
movl $0x4e, %edx
callq 0x3250
movl -0xa8(%rbp), %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movsd -0x38(%rbp), %xmm0
divsd %xmm1, %xmm0
movq 0x639c(%rip), %rdi      # 0xdff0
movsd %xmm0, -0x38(%rbp)
callq 0x3320
leaq 0x2f4d(%rip), %rsi      # 0xabb2
movl $0x1, %edx
movq %rax, %rdi
callq 0x3250
testq %rbx, %rbx
je 0x7cbd
movsd (%rbx), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x6369(%rip), %rdi      # 0xdff0
leaq 0x286f(%rip), %rsi      # 0xa4fd
movl $0x11, %edx
callq 0x3250
movq 0x6351(%rip), %rdi      # 0xdff0
movsd -0x38(%rbp), %xmm0
callq 0x3320
leaq 0x2f02(%rip), %rsi      # 0xabb2
movl $0x1, %edx
movq %rax, %rdi
callq 0x3250
movq 0x632c(%rip), %rdi      # 0xdff0
leaq 0x2ee7(%rip), %rsi      # 0xabb2
movl $0x1, %edx
callq 0x3250
movq -0xa0(%rbp), %rbx
xorl %r15d, %r15d
cmpq -0x98(%rbp), %rbx
je 0x7987
leaq 0x25f6(%rip), %r15      # 0xa2e9
leaq 0x2eb8(%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 0x62a8(%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 0x7cfa
xorl %r15d, %r15d
jmp 0x7987
xorl %r15d, %r15d
movq 0x61f9(%rip), %rdi      # 0xdff0
leaq 0x267f(%rip), %rsi      # 0xa47d
movl $0x4c, %edx
callq 0x3250
jmp 0x7987
jmp 0x7e52
jmp 0x7e52
jmp 0x7e21
jmp 0x7e15
movq %rax, %r14
jmp 0x7f17
jmp 0x7e52
jmp 0x7e52
movq %rax, %r14
leaq -0xe8(%rbp), %rbx
leaq -0x118(%rbp), %r15
jmp 0x7e7e
jmp 0x7e36
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %rbx, %rdi
je 0x7e55
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3220
jmp 0x7e55
jmp 0x7e52
movq %rax, %r14
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
leaq -0xe8(%rbp), %rbx
leaq -0x118(%rbp), %r15
je 0x7e7e
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x7ea0
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x148(%rbp), %rdi
leaq -0x138(%rbp), %rax
cmpq %rax, %rdi
je 0x7ec2
movq -0x138(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x128(%rbp), %rdi
cmpq %r15, %rdi
je 0x7edd
movq -0x118(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0xf8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x7ef8
movq -0xe8(%rbp), %rsi
incq %rsi
callq 0x3220
movq 0x60b1(%rip), %rsi      # 0xdfb0
leaq -0x2e8(%rbp), %rdi
callq 0x3190
leaq -0x268(%rbp), %rdi
callq 0x30e0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x7f2c
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movq %r14, %rdi
callq 0x3390