// File: /workspace/github_cpp_makefile_star2_O3/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 $0x2d8, %rsp            # imm = 0x2D8
movq %r9, %r14
movq %r8, %rbx
movl %ecx, -0x5c(%rbp)
movq %rsi, %r13
movq %rdi, -0xb0(%rbp)
xorpd %xmm0, %xmm0
leaq -0x80(%rbp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rdx, -0x108(%rbp)
movl %edx, %esi
callq 0x81be
movq -0x80(%rbp), %r15
leaq -0x2f8(%rbp), %rdi
callq 0x3170
leaq -0xc0(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x140(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x120(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0xe0(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq -0xb0(%rbp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %edx
leaq -0xd0(%rbp), %rsi
movq -0xb0(%rbp), %rdi
callq 0x33d0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %edx
leaq -0x130(%rbp), %rsi
movq %r13, %rdi
callq 0x33d0
leaq -0x2e0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x32c0
leaq -0x2f8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x3280
movq (%rbx), %rdi
callq 0x8fda
movq -0xe8(%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 0x81f8
movq %r14, -0x158(%rbp)
movq -0x108(%rbp), %rcx
leal -0x1(%rcx), %eax
subl %ebx, %ecx
movl %eax, %eax
movq %rax, -0x110(%rbp)
movl %ecx, -0x60(%rbp)
movl %ecx, %eax
shlq $0x4, %rax
movq %rax, -0x160(%rbp)
xorpd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x30(%rbp)
leaq -0x2e0(%rbp), %r14
leaq -0x2f8(%rbp), %rbx
cmpq $0x0, -0xc8(%rbp)
je 0x6dd9
leaq -0x48(%rbp), %r12
movq %r12, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq %r14, %rdi
leaq -0x58(%rbp), %rsi
callq 0x32c0
movq -0x58(%rbp), %rdi
cmpq %r12, %rdi
je 0x6973
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x2f8(%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %esi, %esi
callq 0x3350
movq %r14, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x32c0
movq %rbx, %rdi
leaq -0x150(%rbp), %rsi
callq 0x3280
movq %rax, %rdi
leaq -0xfc(%rbp), %rsi
callq 0x3380
movq %rax, %rdi
leaq -0x170(%rbp), %rsi
callq 0x3140
movq %rax, %rdi
leaq -0x168(%rbp), %rsi
callq 0x3140
movq %r12, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq %r14, %rdi
leaq -0x58(%rbp), %rsi
callq 0x32c0
movq -0x58(%rbp), %rdi
cmpq %r12, %rdi
je 0x6a04
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x2f8(%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %esi, %esi
callq 0x3350
movq %r14, %rdi
leaq -0x130(%rbp), %rsi
callq 0x32c0
movq %rbx, %rdi
leaq -0xf0(%rbp), %rsi
callq 0x3280
movq %rax, %rdi
leaq -0xf8(%rbp), %rsi
callq 0x3380
movq %rax, %rdi
leaq -0xf4(%rbp), %rsi
callq 0x3130
movq %r13, %rbx
movq -0xe8(%rbp), %r12
movq -0x148(%rbp), %r13
cmpq %r12, %r13
movq %r12, %rdx
cmovbq %r13, %rdx
testq %rdx, %rdx
je 0x6a9a
movq -0x150(%rbp), %rsi
movq -0xf0(%rbp), %rdi
callq 0x3230
cmpq %r13, %r12
jne 0x6db6
testl %eax, %eax
je 0x6aa3
jmp 0x6db6
cmpq %r13, %r12
jne 0x6db6
movl -0xf8(%rbp), %eax
cmpl -0xfc(%rbp), %eax
jne 0x6db6
movl %eax, (%r15)
movl -0xf4(%rbp), %eax
testl %eax, %eax
js 0x6b5e
cvtsi2sd %eax, %xmm0
movsd -0x168(%rbp), %xmm1
movapd %xmm1, %xmm2
addsd %xmm1, %xmm2
movsd 0x3526(%rip), %xmm4     # 0xa008
movapd %xmm4, %xmm3
subsd %xmm1, %xmm3
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm3
addsd %xmm1, %xmm3
subsd %xmm3, %xmm0
movapd 0x354e(%rip), %xmm5     # 0xa050
andpd %xmm5, %xmm0
movsd 0x3522(%rip), %xmm6     # 0xa030
mulsd %xmm6, %xmm0
movsd -0x170(%rbp), %xmm1
movapd %xmm1, %xmm2
addsd %xmm1, %xmm2
subsd %xmm1, %xmm4
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm4
addsd %xmm1, %xmm4
subsd %xmm3, %xmm4
andpd %xmm5, %xmm4
mulsd %xmm6, %xmm4
movsd -0x38(%rbp), %xmm1
addsd %xmm4, %xmm1
movsd %xmm1, -0x38(%rbp)
movq -0xa8(%rbp), %rax
incl %eax
movq %rax, -0xa8(%rbp)
jmp 0x6b66
movsd 0x34d2(%rip), %xmm0     # 0xa038
movq %rbx, %r13
movsd %xmm0, 0x8(%r15)
leaq 0x10(%r15), %rcx
cmpq -0x78(%rbp), %rcx
leaq -0x2e0(%rbp), %r14
leaq -0x2f8(%rbp), %rbx
je 0x6b92
incl -0x30(%rbp)
movq %rcx, %r15
jmp 0x6d59
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
je 0x6bfe
leaq -0x10(%rax), %rdx
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorl %ecx, %ecx
movl -0x5c(%rbp), %ebx
movsd 0x18(%rdx), %xmm0
xorl %esi, %esi
movsd 0x3484(%rip), %xmm1     # 0xa040
ucomisd %xmm0, %xmm1
setbe %dil
ja 0x6bd4
movsd -0x30(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
movb %dil, %sil
addl %esi, %ecx
addq $0x10, %rdx
cmpq %r15, %rdx
jne 0x6bad
testl %ecx, %ecx
je 0x6c07
movl %ecx, %edx
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
jmp 0x6cb1
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movl $0x10, %edx
movq 0x73dd(%rip), %rdi      # 0xdff0
leaq 0x3837(%rip), %rsi      # 0xa451
callq 0x3250
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
movq 0x73bc(%rip), %rdi      # 0xdff0
callq 0x3250
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3fac(%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 0x37f2(%rip), %rsi      # 0xa462
callq 0x3250
movq -0x80(%rbp), %rax
movq -0x110(%rbp), %rcx
shlq $0x4, %rcx
movl (%rax,%rcx), %esi
movq %r15, %rdi
callq 0x3150
movl $0x18, %edx
movq %rax, %rdi
leaq 0x37c6(%rip), %rsi      # 0xa464
callq 0x3250
xorl %ecx, %ecx
movq -0x80(%rbp), %rax
movl -0x5c(%rbp), %ebx
movsd -0x30(%rbp), %xmm1
movl (%rax), %edx
movq -0x110(%rbp), %rsi
shlq $0x4, %rsi
movl (%rax,%rsi), %eax
movl %edx, -0x58(%rbp)
movl %eax, -0x54(%rbp)
movl %ecx, -0x50(%rbp)
movsd %xmm1, -0x48(%rbp)
movq -0x98(%rbp), %rsi
cmpq -0x90(%rbp), %rsi
movq -0x160(%rbp), %r15
je 0x6d01
movq -0x48(%rbp), %rax
movq %rax, 0x10(%rsi)
movupd -0x58(%rbp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, -0x98(%rbp)
jmp 0x6d11
leaq -0xa0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x89e6
cmpl $0x0, -0x60(%rbp)
je 0x6d42
movq -0x80(%rbp), %rax
movl %ebx, %ecx
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, %r15
jne 0x6d1f
movq %r15, %rax
movq -0x80(%rbp), %r15
addq %rax, %r15
movl -0x60(%rbp), %eax
movl %eax, -0x30(%rbp)
leaq -0x2f8(%rbp), %rbx
movq -0xb0(%rbp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %edx
movq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x33d0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %edx
movq %r13, %rdi
leaq -0x130(%rbp), %rsi
callq 0x33d0
jmp 0x6930
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq 0x722d(%rip), %rdi      # 0xdff0
leaq 0x358d(%rip), %rsi      # 0xa357
movl $0x20, %edx
callq 0x3250
jmp 0x715d
movl -0x30(%rbp), %edx
cmpl -0x60(%rbp), %edx
setbe %al
cmpl -0x108(%rbp), %edx
setae %cl
orb %al, %cl
jne 0x6f68
decl %edx
movl %edx, %r14d
je 0x6e69
movq -0x80(%rbp), %rax
movq %r14, %rcx
shlq $0x4, %rcx
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorl %edx, %edx
xorl %ebx, %ebx
movsd 0x8(%rax,%rdx), %xmm0
xorl %esi, %esi
movsd 0x321e(%rip), %xmm1     # 0xa040
ucomisd %xmm0, %xmm1
setbe %dil
ja 0x6e3a
movsd -0x30(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
movb %dil, %sil
addl %esi, %ebx
addq $0x10, %rdx
cmpq %rdx, %rcx
jne 0x6e12
testl %ebx, %ebx
je 0x6e72
movl %ebx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
jmp 0x6f0c
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x7177(%rip), %rdi      # 0xdff0
leaq 0x35d1(%rip), %rsi      # 0xa451
movl $0x10, %edx
callq 0x3250
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
movq 0x7151(%rip), %rdi      # 0xdff0
callq 0x3250
movq %rax, %rbx
leaq 0x3d49(%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 0x358f(%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
xorl %ebx, %ebx
leaq 0x3565(%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 %ebx, -0x50(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x98(%rbp), %rsi
cmpq -0x90(%rbp), %rsi
je 0x6f58
movq -0x48(%rbp), %rax
movq %rax, 0x10(%rsi)
movupd -0x58(%rbp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, -0x98(%rbp)
jmp 0x6f68
leaq -0xa0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x89e6
cmpl $0x0, -0xa8(%rbp)
movq -0x158(%rbp), %rbx
je 0x7142
movq 0x706d(%rip), %rdi      # 0xdff0
leaq 0x3540(%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 0x703e(%rip), %rdi      # 0xdff0
movsd %xmm0, -0x38(%rbp)
callq 0x3320
leaq 0x3bef(%rip), %rsi      # 0xabb2
movl $0x1, %edx
movq %rax, %rdi
callq 0x3250
testq %rbx, %rbx
je 0x701b
movsd (%rbx), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x700b(%rip), %rdi      # 0xdff0
leaq 0x3511(%rip), %rsi      # 0xa4fd
movl $0x11, %edx
callq 0x3250
movq 0x6ff3(%rip), %rdi      # 0xdff0
movsd -0x38(%rbp), %xmm0
callq 0x3320
leaq 0x3ba4(%rip), %rsi      # 0xabb2
movl $0x1, %edx
movq %rax, %rdi
callq 0x3250
movq 0x6fce(%rip), %rdi      # 0xdff0
leaq 0x3b89(%rip), %rsi      # 0xabb2
movl $0x1, %edx
callq 0x3250
movq -0xa0(%rbp), %rbx
cmpq -0x98(%rbp), %rbx
je 0x724c
leaq 0x329b(%rip), %r15      # 0xa2e9
leaq 0x3b5d(%rip), %r12      # 0xabb2
movsd 0x10(%rbx), %xmm0
movsd %xmm0, -0x30(%rbp)
movl 0x4(%rbx), %r14d
addl (%rbx), %r14d
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
movq 0x6f4d(%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 0x7055
jmp 0x715a
movq 0x6ea7(%rip), %rdi      # 0xdff0
leaq 0x332d(%rip), %rsi      # 0xa47d
movl $0x4c, %edx
callq 0x3250
xorl %r14d, %r14d
movq -0xa0(%rbp), %rbx
testq %rbx, %rbx
leaq -0xc0(%rbp), %r15
je 0x7182
movq -0x90(%rbp), %rsi
subq %rbx, %rsi
movq %rbx, %rdi
callq 0x3220
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x71a4
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0x71c6
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x150(%rbp), %rdi
leaq -0x140(%rbp), %rax
cmpq %rax, %rdi
je 0x71e8
movq -0x140(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0xd0(%rbp), %rdi
cmpq %r15, %rdi
je 0x7203
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x3220
movq 0x6da6(%rip), %rsi      # 0xdfb0
leaq -0x2f8(%rbp), %rdi
callq 0x3190
leaq -0x278(%rbp), %rdi
callq 0x30e0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x7237
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movl %r14d, %eax
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
jmp 0x7164
jmp 0x7292
jmp 0x7292
jmp 0x7268
jmp 0x725c
movq %rax, %r14
jmp 0x7357
jmp 0x7292
jmp 0x7292
movq %rax, %r14
leaq -0xc0(%rbp), %rbx
jmp 0x72b7
jmp 0x7276
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %r12, %rdi
je 0x7295
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3220
jmp 0x7295
jmp 0x7292
movq %rax, %r14
leaq -0xc0(%rbp), %rbx
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x72b7
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x72d9
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0x72fb
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0x150(%rbp), %rdi
leaq -0x140(%rbp), %rax
cmpq %rax, %rdi
je 0x731d
movq -0x140(%rbp), %rsi
incq %rsi
callq 0x3220
movq -0xd0(%rbp), %rdi
cmpq %rbx, %rdi
je 0x7338
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x3220
movq 0x6c71(%rip), %rsi      # 0xdfb0
leaq -0x2f8(%rbp), %rdi
callq 0x3190
leaq -0x278(%rbp), %rdi
callq 0x30e0
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x736c
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x3220
movq %r14, %rdi
callq 0x3390