// File: /workspace/github_cpp_makefile_star2_O3/tonymugen[P]sampleSNPs/varfiles.cpp
// Function: sampFiles::TpedFileI::sample(sampFiles::TpedFileO&, unsigned long const&)
void TpedFileI::sample(TpedFileO &out, const uint64_t &n){

	if (n == 0) {
		cerr << "WARNING: zero SNPs requested. Nothing to be done." << endl;
		return;
	}
	// start by figuring out the number of SNPs in the .bed file
	if (out._varFile.is_open()) {
		out.close();
	}

	string inFam  = _fileStub + ".tfam";
	string outFam = out._fileStub + ".tfam";

	try {
		_tfamFile.open(inFam.c_str(), ios::in);
		if (!_tfamFile.is_open()) {
			cerr << "ERROR: failed to open .tfam file " << inFam << " for input" << endl;
			exit(2);
		}

	} catch (system_error &error) {
		cerr << "ERROR: cannot open .tfam file " << inFam << " for input: " << error.code().message() << flush;
		perror(" ");
		exit(1);
	}

	try {
		out._tfamFile.open(outFam.c_str(), ios::out | ios::trunc);
		if (!out._tfamFile.is_open()) {
			cerr << "ERROR: failed to open .tfam file " << outFam << " for output" << endl;
			exit(2);
		}

	} catch (system_error &error) {
		cerr << "ERROR: cannot open .tfam file " << outFam << " for output: " << error.code().message() << flush;
		perror(" ");
		exit(1);
	}

	// Copy the .tfam file
	_famCopy(out._tfamFile);
	// Calculate number of SNPs in the input TPED file
	try {
		_varFile.open(_fileName.c_str(), ios::in);
		if (!_varFile.is_open()) {
			cerr << "ERROR: failed to open file " << _fileName << " for input" << endl;
			exit(2);
		}

	} catch (system_error &error) {
		cerr << "ERROR: cannot open BED file " << _fileName << ": " << error.code().message() << flush;
		perror(" ");
		exit(1);
	}

	uint64_t N = _numLines(); // Number of SNPs

	// Test for potential problems
	if (N < n) {
		cerr << "ERROR: requested a sample of " << n << " SNPs that is greater than the number of SNPs (" << N << ") in the input file." << endl;
		return;
	} else if (N == n) {
		cerr << "WARNING: sample size (" << n << ") the same as the number of SNPs (" << N << ") in the input file. Simply copying the files." << endl;
		char *buf;
		const size_t bufSize = BUF_SIZE;
		try {
			buf = new char[bufSize];
		} catch (bad_alloc&) {
			cerr << "ERROR: failed to allocate buffer" << endl;
			exit(4);
		}

		// Copy .tped
		try {
			_varFile.open(_fileName.c_str(), ios::in);
			if (!_varFile.is_open()) {
				cerr << "ERROR: failed to open file " << _fileName << " for input" << endl;
				exit(2);
			}
		} catch (system_error &error) {
			cerr << "ERROR: cannot open .tped file " << _fileName << " for input: " << error.code().message() << flush;
			perror(" ");
			exit(1);
		}
		try {
			out._varFile.open(out._fileName.c_str(), ios::out);
			if (!out._varFile.is_open()) {
				cerr << "ERROR: failed to open file " << out._fileName << " for output" << endl;
				exit(2);
			}

		} catch (system_error &error) {
			cerr << "ERROR: cannot open .tped file " << out._fileName << " for output: " << error.code().message() << flush;
			perror(" ");
			exit(1);
		}
		while (_varFile) {
			_varFile.read(buf, bufSize);
			out._varFile.write(buf, _varFile.gcount());
		}
		_varFile.close();
		out._varFile.close();
		delete [] buf;
		return;
	}

	// Passed all the tests, proceed to sampling
	string tpedLine;

	try {
		_varFile.open(_fileName.c_str(), ios::in);
		if (!_varFile.is_open()) {
			cerr << "ERROR: failed to open .tped file " << _fileName << " for input" << endl;
			exit(2);
		}

	} catch (system_error &error) {
		cerr << "ERROR: cannot open .tped file " << _fileName << " for input: " << error.code().message() << flush;
		perror(" ");
		exit(1);
	}
	try {
		out._varFile.open(out._fileName.c_str(), ios::out| ios::trunc);
		if (!out._varFile.is_open()) {
			cerr << "ERROR: failed to open .tped file " << out._fileName << " for output" << endl;
			exit(2);
		}

	} catch (system_error &error) {
		cerr << "ERROR: cannot open .tped file " << out._fileName << " for output: " << error.code().message() << flush;
		perror(" ");
		exit(1);
	}

	uint64_t nloc = n; // local copy of n
	uint64_t S;
	RanDraw *snpSamp;  // so that I can catch RanDraw constructor exceptions
	try {
		snpSamp = new RanDraw();
	} catch (string error) {
		cerr << "ERROR: " << error << endl;
		exit(5);
	}
	while (nloc) {
		try {
			S = snpSamp->vitter(nloc, N); // sample the number of SNPs to skip
		} catch (string error) {
			cerr << "ERROR: " << error << endl;
			exit(5);
		}
		N -= S + 1;
		while (S) { // skipping S lines in the tped file
			_varFile.ignore(numeric_limits<streamsize>::max(), '\n');
			S--;
		}
		getline(_varFile, tpedLine);
		out._varFile << tpedLine << endl;
		nloc--;

	}
	_varFile.close();
	out._varFile.close();
	delete snpSamp;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
cmpq $0x0, (%rdx)
je 0x13653
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x88(%rsi), %r13
movq %r13, %rdi
callq 0x40a0
testb %al, %al
je 0x1349e
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x450(%r15), %rsi
movq 0x458(%r15), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %r14
movq %r14, %rdi
callq 0x76e4
leaq 0x576d(%rip), %rsi      # 0x18c3f
movq %r14, %rdi
callq 0x4530
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x450(%rbx), %rsi
movq 0x458(%rbx), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x76e4
leaq 0x573a(%rip), %rsi      # 0x18c3f
leaq 0x58(%rsp), %rdi
callq 0x4530
leaq 0x240(%r15), %rdi
movq 0x80(%rsp), %rsi
movl $0x8, %edx
callq 0x4270
leaq 0x2c0(%r15), %rdi
callq 0x40a0
testb %al, %al
je 0x13a20
leaq 0x240(%rbx), %r14
movq 0x58(%rsp), %rsi
movq %r14, %rdi
movl $0x30, %edx
callq 0x4270
leaq 0x2c0(%rbx), %rdi
callq 0x40a0
testb %al, %al
je 0x13a78
movq %r15, %rdi
movq %r14, %rsi
callq 0x12bca
movq %r13, 0x50(%rsp)
leaq 0x8(%r15), %r14
movq 0x218(%r15), %rsi
movq %r14, %rdi
movl $0x8, %edx
callq 0x4270
leaq 0x88(%r15), %r13
movq %r13, %rdi
callq 0x40a0
testb %al, %al
je 0x13ac7
movq %r15, %rdi
callq 0x12ef2
movq %rax, %rbp
leaq 0x8(%rbx), %rax
movq %rax, 0x48(%rsp)
cmpq (%r12), %rbp
jae 0x136a6
movq 0xca23(%rip), %rdi      # 0x1fff0
leaq 0x5022(%rip), %rsi      # 0x185f6
movl $0x1d, %edx
callq 0x42f0
movq (%r12), %rsi
movq 0xca07(%rip), %rdi      # 0x1fff0
callq 0x41a0
movq %rax, %rbx
leaq 0x5300(%rip), %rsi      # 0x188f8
movl $0x2f, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x41a0
movq %rax, %rbx
leaq 0x502a(%rip), %rsi      # 0x18644
movl $0x14, %edx
movq %rax, %rdi
callq 0x42f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
jmp 0x139cd
movq 0xc996(%rip), %rbx      # 0x1fff0
leaq 0x4f63(%rip), %rsi      # 0x185c4
movl $0x31, %edx
movq %rbx, %rdi
callq 0x42f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x41b0
jne 0x137c7
movq 0xc93d(%rip), %rdi      # 0x1fff0
leaq 0x4f9f(%rip), %rsi      # 0x18659
movl $0x16, %edx
callq 0x42f0
movq (%r12), %rsi
movq 0xc921(%rip), %rdi      # 0x1fff0
callq 0x41a0
movq %rax, %r12
leaq 0x524a(%rip), %rsi      # 0x18928
movl $0x22, %edx
movq %rax, %rdi
callq 0x42f0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x41a0
movq %rax, %r12
leaq 0x524b(%rip), %rsi      # 0x1894b
movl $0x2e, %edx
movq %rax, %rdi
callq 0x42f0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movl $0xa00000, %edi         # imm = 0xA00000
callq 0x4030
movq %rax, %r12
movq 0x218(%r15), %rsi
movq %r14, %rdi
movl $0x8, %edx
callq 0x4270
movq %r13, %rdi
callq 0x40a0
testb %al, %al
je 0x13bd0
movq 0x218(%rbx), %rsi
movq 0x48(%rsp), %rdi
movl $0x10, %edx
callq 0x4270
movq 0x50(%rsp), %rdi
callq 0x40a0
testb %al, %al
je 0x13c26
addq $0x18, %rbx
movq 0x8(%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x28(%r15,%rax)
jne 0x139b3
movl $0xa00000, %edx         # imm = 0xA00000
movq %r14, %rdi
movq %r12, %rsi
callq 0x4350
movq 0x10(%r15), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4390
jmp 0x13792
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x218(%r15), %rsi
movq %r14, %rdi
movl $0x8, %edx
callq 0x4270
movq %r13, %rdi
callq 0x40a0
testb %al, %al
je 0x13b22
movq 0x218(%rbx), %rsi
movq 0x48(%rsp), %rdi
movl $0x30, %edx
callq 0x4270
movq 0x50(%rsp), %rdi
movq %rbx, 0x78(%rsp)
callq 0x40a0
testb %al, %al
je 0x13b75
movq (%r12), %rbx
movl $0x8, %edi
callq 0x42c0
movq %rax, %r15
movq %rax, %rdi
callq 0x172de
movq %rbp, %rax
testq %rbx, %rbx
je 0x13968
addq $0x18, 0x78(%rsp)
movabsq $0x7fffffffffffffff, %r13 # imm = 0x7FFFFFFFFFFFFFFF
movq %rbx, %xmm0
movq 0x4c32(%rip), %xmm2     # 0x184a0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x4c36(%rip), %xmm3     # 0x184b0
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
movq %rax, 0x50(%rsp)
movq %rax, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0xa0(%rsp)
movq %r15, %rbp
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x175fe
movq %rax, %r12
movq %rax, %r15
testq %rax, %rax
je 0x138ef
movq %r14, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x4190
decq %r15
jne 0x138da
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %edx
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0x4500
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x78(%rsp), %rdi
callq 0x42f0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r15, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
notq %r12
movq 0x50(%rsp), %rax
addq %r12, %rax
decq %rbx
movq %rbp, %r15
jne 0x13861
movq %r14, %rdi
callq 0x4060
movq 0x48(%rsp), %rdi
callq 0x4060
movq (%r15), %rdi
testq %rdi, %rdi
je 0x13988
movq (%rdi), %rax
callq *0x8(%rax)
movl $0x8, %esi
movq %r15, %rdi
callq 0x42d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x139cd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x139cd
movq %r14, %rdi
callq 0x4060
movq 0x48(%rsp), %rdi
callq 0x4060
movq %r12, %rdi
callq 0x4380
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x139e9
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x13a0e
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xc5c9(%rip), %rdi      # 0x1fff0
leaq 0x5217(%rip), %rsi      # 0x18c45
movl $0x21, %edx
callq 0x42f0
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0xc5a1(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4b0e(%rip), %rsi      # 0x1856c
movl $0xa, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
jmp 0x13b18
movq 0xc571(%rip), %rdi      # 0x1fff0
leaq 0x51bf(%rip), %rsi      # 0x18c45
movl $0x21, %edx
callq 0x42f0
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0xc54f(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4c32(%rip), %rsi      # 0x186e2
movl $0xb, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
jmp 0x13b18
movq 0xc522(%rip), %rdi      # 0x1fff0
leaq 0x4a7b(%rip), %rsi      # 0x18550
movl $0x1b, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xc4fc(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4a69(%rip), %rsi      # 0x1856c
movl $0xa, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
movl $0x2, %edi
callq 0x4320
movq 0xc4c7(%rip), %rdi      # 0x1fff0
leaq 0x5209(%rip), %rsi      # 0x18d39
movl $0x21, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xc4a1(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4a0e(%rip), %rsi      # 0x1856c
movl $0xa, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
jmp 0x13b18
movq 0xc474(%rip), %rdi      # 0x1fff0
leaq 0x51b6(%rip), %rsi      # 0x18d39
movl $0x21, %edx
movq 0x78(%rsp), %rbx
callq 0x42f0
movq 0x218(%rbx), %rsi
movq 0x220(%rbx), %rdx
movq 0xc449(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x4b2c(%rip), %rsi      # 0x186e2
movl $0xb, %edx
movq %rax, %rdi
callq 0x42f0
movq %r14, %rdi
callq 0x4130
jmp 0x13b18
movq 0xc419(%rip), %rdi      # 0x1fff0
leaq 0x4972(%rip), %rsi      # 0x18550
movl $0x1b, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xc3f3(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4960(%rip), %rsi      # 0x1856c
movl $0xa, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
jmp 0x13b18
movq 0xc3c3(%rip), %rdi      # 0x1fff0
leaq 0x491c(%rip), %rsi      # 0x18550
movl $0x1b, %edx
callq 0x42f0
movq 0x218(%rbx), %rsi
movq 0x220(%rbx), %rdx
movq 0xc39d(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x4a80(%rip), %rsi      # 0x186e2
movl $0xb, %edx
movq %rax, %rdi
callq 0x42f0
movq %r14, %rdi
callq 0x4130
jmp 0x13b18
movq %rax, %r14
cmpl $0x3, %edx
jne 0x143c6
movq %r14, %rdi
callq 0x4110
movq 0xc359(%rip), %rdi      # 0x1fff0
leaq 0x4a23(%rip), %rsi      # 0x186c1
movl $0x20, %edx
callq 0x42f0
movq 0xc341(%rip), %rdi      # 0x1fff0
callq 0x4130
movl $0x4, %edi
callq 0x4320
movq %rax, %r14
callq 0x4480
jmp 0x143c6
movq %rdx, %rbx
movq %rax, %r14
movl $0x8, %esi
movq %r15, %rdi
callq 0x42d0
jmp 0x13ce6
movq %rdx, %rbx
movq %rax, %r14
cmpl $0x2, %ebx
jne 0x143aa
movq %r14, %rdi
callq 0x4340
leaq 0x38(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x76e4
movq %r14, %rdi
callq 0x4110
movq 0xc2cd(%rip), %rdi      # 0x1fff0
leaq 0x49fb(%rip), %rsi      # 0x18725
movl $0x7, %edx
callq 0x42f0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0xc2ab(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rdi
callq 0x4130
jmp 0x1436b
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x13d71
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
callq 0x4480
jmp 0x143aa
movq %rax, %r14
cmpl $0x1, %edx
jne 0x143c6
movq %r14, %rdi
callq 0x4110
movq %rax, %r14
movq 0xc257(%rip), %rdi      # 0x1fff0
leaq 0x4fbb(%rip), %rsi      # 0x18d5b
movl $0x1e, %edx
callq 0x42f0
movq 0x218(%rbx), %rsi
movq 0x220(%rbx), %rdx
movq 0xc231(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4920(%rip), %rsi      # 0x186ee
movl $0xd, %edx
movq %rax, %rdi
callq 0x42f0
movq 0x18(%r14), %rsi
movl 0x10(%r14), %edx
movq (%rsi), %rax
leaq 0x8(%rsp), %rdi
callq *0x20(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x42f0
movq %rax, %rdi
callq 0x41b0
leaq 0x8(%rsp), %rdi
callq 0x4a6b
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13e37
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x13e37
jmp 0x13e34
movq %rax, %r14
callq 0x4480
jmp 0x143c6
movq %rax, %r14
cmpl $0x1, %edx
jne 0x143c6
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xc191(%rip), %rdi      # 0x1fff0
leaq 0x4ef5(%rip), %rsi      # 0x18d5b
movl $0x1e, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xc16b(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x4b69(%rip), %rsi      # 0x189fd
movl $0xc, %edx
movq %rax, %rdi
callq 0x42f0
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x8(%rsp), %rdi
callq *0x20(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x42f0
movq %rax, %rdi
callq 0x41b0
leaq 0x8(%rsp), %rdi
callq 0x4a51
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13efc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x13efc
jmp 0x13ef9
movq %rax, %r14
callq 0x4480
jmp 0x143c6
movq %rax, %r14
cmpl $0x1, %edx
jne 0x143aa
movq %r14, %rdi
callq 0x4110
movq %rax, %r14
movq 0xc0cc(%rip), %rdi      # 0x1fff0
leaq 0x4e30(%rip), %rsi      # 0x18d5b
movl $0x1e, %edx
callq 0x42f0
movq 0x218(%rbx), %rsi
movq 0x220(%rbx), %rdx
movq 0xc0a6(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4795(%rip), %rsi      # 0x186ee
movl $0xd, %edx
movq %rax, %rdi
callq 0x42f0
movq 0x18(%r14), %rsi
movl 0x10(%r14), %edx
movq (%rsi), %rax
leaq 0x28(%rsp), %rdi
callq *0x20(%rax)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x42f0
movq %rax, %rdi
callq 0x41b0
leaq 0x28(%rsp), %rdi
callq 0x4a37
movq %rax, %r14
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x13fc2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x13fc2
jmp 0x13fbf
movq %rax, %r14
callq 0x4480
jmp 0x143aa
movq %rax, %r14
cmpl $0x1, %edx
jne 0x143aa
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xc006(%rip), %rdi      # 0x1fff0
leaq 0x4d6a(%rip), %rsi      # 0x18d5b
movl $0x1e, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xbfe0(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x49de(%rip), %rsi      # 0x189fd
movl $0xc, %edx
movq %rax, %rdi
callq 0x42f0
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x28(%rsp), %rdi
callq *0x20(%rax)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r14, %rdi
callq 0x42f0
movq %rax, %rdi
callq 0x41b0
leaq 0x28(%rsp), %rdi
callq 0x4a1d
movq %rax, %r14
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x14087
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x14087
jmp 0x14084
movq %rax, %r14
callq 0x4480
jmp 0x143aa
jmp 0x143a7
jmp 0x143a0
jmp 0x143a0
jmp 0x143a0
jmp 0x140a7
movq %rax, %r14
jmp 0x143e2
movq %rax, %r14
cmpl $0x1, %edx
jne 0x143c6
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbf23(%rip), %rdi      # 0x1fff0
leaq 0x4765(%rip), %rsi      # 0x18839
movl $0x1c, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xbefd(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x470f(%rip), %rsi      # 0x18811
movl $0x2, %edx
movq %rax, %rdi
callq 0x42f0
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x8(%rsp), %rdi
callq *0x20(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x42f0
movq %rax, %rdi
callq 0x41b0
leaq 0x8(%rsp), %rdi
callq 0x4a03
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1416a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x1416a
jmp 0x14167
movq %rax, %r14
callq 0x4480
jmp 0x143c6
movq %rax, %r14
cmpl $0x1, %edx
jne 0x143c6
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbe5e(%rip), %rdi      # 0x1fff0
leaq 0x4ace(%rip), %rsi      # 0x18c67
movl $0x1e, %edx
callq 0x42f0
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0xbe3c(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x452b(%rip), %rsi      # 0x186ee
movl $0xd, %edx
movq %rax, %rdi
callq 0x42f0
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x8(%rsp), %rdi
callq *0x20(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x42f0
movq %rax, %rdi
callq 0x41b0
leaq 0x8(%rsp), %rdi
callq 0x49e9
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1422b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x1422b
jmp 0x14228
movq %rax, %r14
callq 0x4480
jmp 0x143c6
movq %rax, %r14
cmpl $0x1, %edx
jne 0x143c6
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbd9d(%rip), %rdi      # 0x1fff0
leaq 0x4a0d(%rip), %rsi      # 0x18c67
movl $0x1e, %edx
callq 0x42f0
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0xbd75(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x4773(%rip), %rsi      # 0x189fd
movl $0xc, %edx
movq %rax, %rdi
callq 0x42f0
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x8(%rsp), %rdi
callq *0x20(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x42f0
movq %rax, %rdi
callq 0x41b0
leaq 0x8(%rsp), %rdi
callq 0x49cf
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x142f2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x142f2
jmp 0x142ef
movq %rax, %r14
callq 0x4480
jmp 0x143c6
movq %rax, %r14
cmpl $0x2, %edx
jne 0x143aa
movq %r14, %rdi
callq 0x4340
leaq 0x38(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x76e4
movq %r14, %rdi
callq 0x4110
movq 0xbcb4(%rip), %rdi      # 0x1fff0
leaq 0x43e2(%rip), %rsi      # 0x18725
movl $0x7, %edx
callq 0x42f0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0xbc92(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rdi
callq 0x4130
movl $0x5, %edi
callq 0x4320
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1438f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
callq 0x4480
jmp 0x143aa
movq %rax, %rdi
callq 0x76d8
jmp 0x143a0
movq %rax, %r14
jmp 0x143c6
jmp 0x143a7
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x143c6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x143e2
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x14407
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %r14, %rdi
callq 0x44e0
nop