// File: /workspace/github_cpp_makefile_star2_O3/tplinderoth[P]introDist/Dxyz.cpp
// Function: vcf2Dxyz(std::basic_ifstream<char, std::char_traits<char>>&, std::basic_ifstream<char, std::char_traits<char>>&, std::basic_ofstream<char, std::char_traits<char>>&, int, int, double, int)
int vcf2Dxyz (std::ifstream &poptab, std::ifstream &vcf, std::ofstream &outf, int winsize, int step, double minmaf, int infmt) {
		// set up population table map
		std::map <std::string, int> popmap;
		if (setPopTable(poptab, popmap) <= 0) {
			return -1;
		}

		// set up instream
		std::streambuf *inbuf = NULL;
		boost::iostreams::filtering_streambuf<boost::iostreams::input> zipbuf;
		zipbuf.push(boost::iostreams::gzip_decompressor());
		if (infmt == 0) {
			inbuf = vcf.rdbuf();
		}
		else if (infmt == 1) {
			zipbuf.push(vcf);
			inbuf = &zipbuf;
		} else if (infmt == 2) {
			inbuf = std::cin.rdbuf();
		}
		std::istream instream(inbuf);

		// set up outstream
		std::streambuf *outbuf = NULL;
		if (outf.is_open()) {
			outbuf = outf.rdbuf();
		} else {
			outbuf = std::cout.rdbuf();
		}
		std::ostream outstream(outbuf);

		// print header to output
		printHeader(outstream);

		// process VCF file
		std::string vcfline;

		// skip headers and set up vector to hold tokens
		while (getline(instream, vcfline)) {
			if (vcfline[0] != '#' || vcfline[1] != '#')
				break;
		}

		// find individual's positions in allele vector
		std::vector<int> source_idx; // this is the source pop index positions
		std::vector<int> sink_idx; // this is the sink pop index positions
		std::vector<int> outgroup_idx; // this is the outgroup index positions

		std::stringstream ss(vcfline);
		std::string tok;
		int idxpos [2];
		int c = -9;
		int c2 = 0;
		int pop;
		while (ss >> tok) {
			if (c >= 0) {
				if (popmap.find(tok) != popmap.end()) {
					pop = popmap.find(tok)->second;
					idxpos[0] = c2;
					idxpos[1] = c2+1;

					if (pop == 0) {
						source_idx.insert(source_idx.end(), idxpos, idxpos+2);
					} else if (pop == 1) {
						sink_idx.insert(sink_idx.end(), idxpos, idxpos+2);
					} else if (pop == 2) {
						outgroup_idx.insert(outgroup_idx.end(), idxpos, idxpos+2);
					} else {
						std::cerr << "Invalid population code: " << pop << "\n";
						return -1;
					}

				}
				c2 += 2;
			}
			++c;
		}
		unsigned int nind = c;
		int nfields = c+9;
		std::cerr << "Number of individuals in VCF: " << nind << "\n";

		// set up data structures to hold site information

		// matrix to hold Dxy values
		Matrix<double> dxy(winsize, 5); // 0:source-sink dxy, 1:source-out dxy, 2:position, 3:number sequences with data, 4: maf

		// vector to hold alleles
		std::vector<int> alleles;
		alleles.resize(nind*2);

		// loop through VCF sites
		int i = 0, j = 0;
		std::string seqid;
		std::string prevseq;
		int nsitedata; // tracks number of sites in a window with data
		double nseqdata_win; // tracks average number of sequences per site in a window with data
		double dxy_components [2]; // 0=Source-Sink Dxy, 1=Source-Outgroup Dxy
		double dxyz;
		double winstart = 0; // holds start position of last printed window
		while (getline(instream, vcfline)) {
		// assume vcf fields are [0]=CHROM, [1]=POS, [2]=ID, [3]=REF, [4]=ALT, [5]=QUAL, [6]=FILTER, [7]=INFO, [8]=FORMAT

			// parse site information
			ss.clear();
			ss.str(vcfline);
			ss >> seqid; // extract CHROM
			ss >> dxy(j,2); // extract POS
			i=2;
			while (ss >> tok) {
				if (i > 8) {
					// extract genotypes
					if(parseGenotype(tok, alleles) == alleles.end()) {
						return -1;
					}
				} else if (i == 8) {
					// ensure genotypes are present
					if (tok[0] != 'G' || tok[1] != 'T') {
						std::cerr << "No GT subfield for " << seqid << " " << dxy(j,2) << "\n";
						return -1;
					}
				}
				++i;
			}

			if (i < nfields) {
				std::cerr << "Input VCF appears truncated\n";
				return -1;
			}

			// calculate average number of pairwise differences for site
			dxyComponents(alleles, source_idx, sink_idx, outgroup_idx, dxy, j);
			++j;

			if (j == winsize || (!prevseq.empty() && prevseq != seqid)) {
				winstart=dxy(0,2);

				// calculate Dxyz window
				dxyz = calcDxyzWindow(dxy, dxy.nrow()-1, &nseqdata_win, &nsitedata, minmaf, dxy_components);

				// print window
				printWindow(outstream, dxyz, seqid, dxy(0,2), dxy(winsize-1,2), nseqdata_win, nsitedata, dxy_components);

				// slide dxy window
				j = slideWindow(dxy, winsize, step, j);
			}

			prevseq = seqid;
		}

		// process last window if necessary
		if (dxy(0,2) != winstart) {
			dxyz = calcDxyzWindow(dxy, j-1, &nseqdata_win, &nsitedata, minmaf, dxy_components);
			printWindow(outstream, dxyz, seqid, dxy(0,2), dxy(j-1,2), nseqdata_win, nsitedata, dxy_components);
		}

		return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5b8, %rsp            # imm = 0x5B8
movl %r9d, %ebp
movsd %xmm0, 0xc8(%rsp)
movl %r8d, 0x3c(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, %rbx
movq %rsi, %r14
leaq 0x180(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x178(%rsp), %rsi
callq 0x7e6a
testl %eax, %eax
jle 0x6e77
leaq 0x1a8(%rsp), %r12
movq %r12, %rdi
callq 0x8de8
leaq 0xf3d1(%rip), %rax      # 0x16170
movq %rax, 0x1a8(%rsp)
leaq 0xf442(%rip), %rax      # 0x161f0
movq %rax, 0x1e8(%rsp)
leaq 0x208(%rsp), %rdi
movl $0x1000, %edx           # imm = 0x1000
movl $0xf, %esi
callq 0x8880
movq 0x1f0(%rsp), %rdi
leaq 0x208(%rsp), %rsi
movq $-0x1, %rdx
movq $-0x1, %rcx
callq 0xacf2
leaq 0x298(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6e11
movq 0x298(%rsp), %rsi
incq %rsi
callq 0x6310
leaq 0x248(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6e32
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x6310
leaq 0x228(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6e53
movq 0x228(%rsp), %rsi
incq %rsi
callq 0x6310
leaq 0x210(%rsp), %rdi
callq 0x8ca8
cmpl $0x2, %ebp
je 0x6ea9
cmpl $0x1, %ebp
je 0x6e81
testl %ebp, %ebp
jne 0x6ec1
addq $0x10, %r14
movq %r14, %r12
jmp 0x6ec4
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x7641
leaq 0x208(%rsp), %rsi
movq %r14, (%rsi)
movq 0x1f0(%rsp), %rdi
movq $-0x1, %rdx
movq $-0x1, %rcx
callq 0xd394
jmp 0x6ec4
movq 0x10120(%rip), %rax     # 0x16fd0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq 0xe8(%rax,%rcx), %r12
jmp 0x6ec4
xorl %r12d, %r12d
leaq 0x390(%rsp), %rdi
movq %r12, %rsi
callq 0x65f0
leaq 0x70(%rbx), %rdi
callq 0x60c0
testb %al, %al
je 0x6ee7
addq $0x8, %rbx
jmp 0x6efd
movq 0x100b2(%rip), %rax     # 0x16fa0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq 0xe8(%rax,%rcx), %rbx
leaq 0x390(%rsp), %r14
leaq 0x4a8(%rsp), %rdi
movq %rbx, %rsi
callq 0x6140
leaq 0x4a8(%rsp), %rdi
callq 0x7ff5
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xe0(%rsp), %rbx
movq 0x390(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x62e0
movsbl %al, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x65e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x6f89
movq 0xe0(%rsp), %rax
cmpb $0x23, (%rax)
jne 0x6f89
cmpb $0x23, 0x1(%rax)
je 0x6f41
xorpd %xmm0, %xmm0
movapd %xmm0, 0xa0(%rsp)
xorl %r12d, %r12d
movq %r12, 0xb0(%rsp)
movq %r12, 0x90(%rsp)
movapd %xmm0, 0x80(%rsp)
movq %r12, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
leaq 0x208(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
movl $0x18, %edx
callq 0x6500
leaq 0x150(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0xfffffff7, %ebp       # imm = 0xFFFFFFF7
movl $0xffffffee, %ebx       # imm = 0xFFFFFFEE
leaq 0x140(%rsp), %r14
leaq 0x178(%rsp), %r13
leaq 0x208(%rsp), %rdi
movq %r14, %rsi
callq 0x63f0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x70e9
testl %ebp, %ebp
js 0x70df
movq %r13, %rdi
movq %r14, %rsi
callq 0xdf16
leaq 0x180(%rsp), %rcx
cmpq %rcx, %rax
je 0x70db
movq %r13, %rdi
movq %r14, %rsi
callq 0xdf16
movl 0x40(%rax), %r15d
movl %r12d, 0x8(%rsp)
leal 0x1(%r12), %eax
movl %eax, 0xc(%rsp)
cmpl $0x2, %r15d
je 0x70c2
cmpl $0x1, %r15d
je 0x70a1
testl %r15d, %r15d
jne 0x7662
movq 0xa8(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0xdfa0
jmp 0x70db
movq 0x88(%rsp), %rsi
leaq 0x80(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0xdfa0
jmp 0x70db
movq 0x68(%rsp), %rsi
leaq 0x60(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0xdfa0
addl $0x2, %r12d
incl %ebp
addl $0x2, %ebx
jmp 0x7008
movq 0xfef8(%rip), %rdi      # 0x16fe8
leaq 0x8310(%rip), %rsi      # 0xf407
movl $0x1e, %edx
callq 0x6390
movl %ebp, %esi
movq 0xfede(%rip), %rdi      # 0x16fe8
callq 0x6210
leaq 0x7f75(%rip), %rsi      # 0xf08b
movl $0x1, %edx
movq %rax, %rdi
callq 0x6390
movslq 0x18(%rsp), %rsi
leaq 0x20(%rsp), %rdi
movl $0x5, %edx
callq 0x89b8
leaq 0x390(%rsp), %r12
movq %r12, %r14
xorpd %xmm0, %xmm0
leaq 0x100(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl %ebx, %esi
callq 0x8ac4
addl $0x9, %ebp
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %r15d, %r15d
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x130(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
movq 0x18(%rsp), %rax
decl %eax
movl %eax, 0x38(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0xc0(%rsp)
leaq 0xe0(%rsp), %r12
leaq 0x140(%rsp), %rbx
leaq 0x100(%rsp), %r13
movq 0x390(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x62e0
movsbl %al, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x65e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x76a7
movq 0x208(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x208(%rsp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x6550
leaq 0x220(%rsp), %rdi
movq %r12, %rsi
callq 0x64a0
leaq 0x208(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x63f0
leaq 0x20(%rsp), %rdi
movl %r15d, %esi
movl $0x2, %edx
callq 0x8af6
leaq 0x208(%rsp), %rdi
movq %rax, %rsi
callq 0x6200
movl $0x2, %r12d
leaq 0x208(%rsp), %rdi
movq %rbx, %rsi
callq 0x63f0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x72c6
cmpl $0x9, %r12d
jb 0x72a0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x8032
movq 0x100df(%rip), %rax     # 0x17370
cmpq 0x108(%rsp), %rax
jne 0x72c1
jmp 0x7446
cmpl $0x8, %r12d
jne 0x72c1
movq 0x140(%rsp), %rax
cmpb $0x47, (%rax)
jne 0x7450
cmpb $0x54, 0x1(%rax)
jne 0x7450
incl %r12d
jmp 0x725b
cmpl %ebp, %r12d
jl 0x778e
movq %r13, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x80(%rsp), %rdx
leaq 0x60(%rsp), %rcx
leaq 0x20(%rsp), %r8
movl %r15d, %r9d
callq 0x8142
incl %r15d
cmpl 0x18(%rsp), %r15d
je 0x7330
movq 0x128(%rsp), %rdx
testq %rdx, %rdx
je 0x741f
cmpq 0x48(%rsp), %rdx
jne 0x7330
movq 0x40(%rsp), %rsi
movq 0x120(%rsp), %rdi
callq 0x6320
testl %eax, %eax
je 0x741f
leaq 0x20(%rsp), %r13
movq %r13, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x8af6
movsd (%rax), %xmm0
movsd %xmm0, 0xc0(%rsp)
movl 0x20(%rsp), %esi
decl %esi
movq %r13, %rdi
leaq 0xd8(%rsp), %r12
movq %r12, %rdx
leaq 0x4(%rsp), %rcx
movsd 0xc8(%rsp), %xmm0
leaq 0x160(%rsp), %r14
movq %r14, %r8
callq 0x8425
movsd %xmm0, 0xd0(%rsp)
movq %r13, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x8af6
cvttsd2si (%rax), %rax
movl %eax, 0x14(%rsp)
movq %r13, %rdi
movl 0x38(%rsp), %esi
movl $0x2, %edx
callq 0x8af6
cvttsd2si (%rax), %rax
movl %eax, 0x10(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0x4a8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x14(%rsp), %rcx
leaq 0x10(%rsp), %r8
movq %r12, %r9
pushq %r14
leaq 0x38(%rsp), %rax
pushq %rax
callq 0x8577
addq $0x10, %rsp
movq %r13, %rdi
movq 0x18(%rsp), %rsi
movl 0x3c(%rsp), %edx
movl %r15d, %ecx
callq 0x86e3
movl %eax, %r15d
leaq 0x100(%rsp), %r13
leaq 0x120(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x61a0
leaq 0xe0(%rsp), %r12
leaq 0x390(%rsp), %r14
jmp 0x71ba
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x74d0
movq 0xfb91(%rip), %rdi      # 0x16fe8
leaq 0x7fc8(%rip), %rsi      # 0xf426
movl $0x13, %edx
callq 0x6390
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0xfb6f(%rip), %rdi      # 0x16fe8
callq 0x6390
movq %rax, %rbx
leaq 0x7f9c(%rip), %rsi      # 0xf424
movl $0x1, %r14d
movl $0x1, %edx
movq %rax, %rdi
callq 0x6390
leaq 0x20(%rsp), %rdi
movl %r15d, %esi
movl $0x2, %edx
callq 0x8af6
movsd (%rax), %xmm0
movq %rbx, %rdi
callq 0x6510
movq %rax, %rdi
leaq 0x7bc8(%rip), %rsi      # 0xf08b
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %r14, %rdx
callq 0x6390
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0x74f5
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x7511
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x752e
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x6310
leaq 0x20(%rsp), %rdi
callq 0x8b50
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x755d
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0xf9fc(%rip), %rsi      # 0x16f60
leaq 0x208(%rsp), %rdi
callq 0x6260
leaq 0x288(%rsp), %rdi
callq 0x6100
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x7595
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x6310
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x75b2
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x6310
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x75cf
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6310
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x75f4
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x6310
leaq 0x4b0(%rsp), %rdi
callq 0x6100
movq 0xf9b0(%rip), %rax      # 0x16fb8
movq (%rax), %rcx
movq 0x8(%rax), %rax
leaq 0x3a0(%rsp), %rdi
movq %rcx, -0x10(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x390(%rsp,%rcx)
movq $0x0, -0x8(%rdi)
callq 0x6100
leaq 0x1a8(%rsp), %rdi
callq 0x8b9c
leaq 0x178(%rsp), %rdi
callq 0x8cda
movl %ebx, %eax
addq $0x5b8, %rsp            # imm = 0x5B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xf97f(%rip), %rdi      # 0x16fe8
leaq 0x7d7d(%rip), %rsi      # 0xf3ed
movl $0x19, %edx
callq 0x6390
movq 0xf967(%rip), %rdi      # 0x16fe8
movl %r15d, %esi
callq 0x6580
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x79f6(%rip), %rsi      # 0xf08b
movl $0x1, %edx
movq %rax, %rdi
callq 0x6390
jmp 0x7538
leaq 0x20(%rsp), %rdi
xorl %ebx, %ebx
xorl %esi, %esi
movl $0x2, %edx
callq 0x8af6
movsd (%rax), %xmm0
ucomisd 0xc0(%rsp), %xmm0
jne 0x76cf
jnp 0x74d0
decl %r15d
leaq 0x20(%rsp), %r13
leaq 0xd8(%rsp), %rdx
leaq 0x4(%rsp), %rcx
movq %r13, %rdi
movl %r15d, %esi
movsd 0xc8(%rsp), %xmm0
leaq 0x160(%rsp), %rbp
movq %rbp, %r8
callq 0x8425
leaq 0xd0(%rsp), %r12
movsd %xmm0, (%r12)
xorl %ebx, %ebx
movq %r13, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x8af6
cvttsd2si (%rax), %rax
leaq 0x14(%rsp), %r14
movl %eax, (%r14)
movq %r13, %rdi
movl %r15d, %esi
movl $0x2, %edx
callq 0x8af6
cvttsd2si (%rax), %rax
leaq 0x10(%rsp), %r8
movl %eax, (%r8)
leaq 0x4(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0x4a8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
movq %r12, %rsi
movq %r14, %rcx
leaq 0xd8(%rsp), %r9
pushq %rbp
leaq 0x38(%rsp), %rax
pushq %rax
callq 0x8577
addq $0x10, %rsp
jmp 0x74d0
movl $0x1c, %r14d
leaq 0x7c9f(%rip), %rsi      # 0xf43a
movq 0xf846(%rip), %rdi      # 0x16fe8
jmp 0x74c3
jmp 0x7817
jmp 0x77e8
jmp 0x7812
jmp 0x7817
movq %rax, %rbx
jmp 0x785b
jmp 0x7812
movq %rax, %rbx
jmp 0x78c8
movq %rax, %rbx
jmp 0x793e
movq %rax, %rbx
jmp 0x794b
jmp 0x77e8
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x8958
jmp 0x797e
movq %rax, %rbx
jmp 0x797e
jmp 0x77f2
movq %rax, %rbx
jmp 0x798b
jmp 0x7817
jmp 0x7812
jmp 0x7812
jmp 0x7812
jmp 0x7812
jmp 0x7812
jmp 0x7817
jmp 0x7812
movq %rax, %rbx
jmp 0x7919
movq %rax, %rbx
jmp 0x7882
movq %rax, %rbx
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0x783f
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x785b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x7878
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x6310
leaq 0x20(%rsp), %rdi
callq 0x8b50
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x78a7
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0xf6b2(%rip), %rsi      # 0x16f60
leaq 0x208(%rsp), %rdi
callq 0x6260
leaq 0x288(%rsp), %rdi
callq 0x6100
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x78df
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x6310
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x78fc
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x6310
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x7919
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6310
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x793e
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x6310
leaq 0x4b0(%rsp), %rdi
callq 0x6100
movq 0xf666(%rip), %rax      # 0x16fb8
movq (%rax), %rcx
movq 0x8(%rax), %rax
leaq 0x3a0(%rsp), %rdi
movq %rcx, -0x10(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x390(%rsp,%rcx)
movq $0x0, -0x8(%rdi)
callq 0x6100
leaq 0x1a8(%rsp), %rdi
callq 0x8b9c
leaq 0x178(%rsp), %rdi
callq 0x8cda
movq %rbx, %rdi
callq 0x6590