// File: /workspace/github_cpp_makefile_star2_O1/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 0x137fd
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x88(%rsi), %r13
movq %r13, %rdi
callq 0x40a0
testb %al, %al
je 0x13648
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 0x7720
leaq 0x55c3(%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 0x7720
leaq 0x5590(%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 0x13bca
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 0x13c22
movq %r15, %rdi
movq %r14, %rsi
callq 0x12d6a
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 0x13c71
movq %r15, %rdi
callq 0x1309c
movq %rax, %rbp
leaq 0x8(%rbx), %rax
movq %rax, 0x48(%rsp)
cmpq (%r12), %rbp
jae 0x13850
movq 0xc879(%rip), %rdi      # 0x1fff0
leaq 0x4e78(%rip), %rsi      # 0x185f6
movl $0x1d, %edx
callq 0x42f0
movq (%r12), %rsi
movq 0xc85d(%rip), %rdi      # 0x1fff0
callq 0x41a0
movq %rax, %rbx
leaq 0x5156(%rip), %rsi      # 0x188f8
movl $0x2f, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x41a0
movq %rax, %rbx
leaq 0x4e80(%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 0x13b77
movq 0xc7ec(%rip), %rbx      # 0x1fff0
leaq 0x4db9(%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 0x13971
movq 0xc793(%rip), %rdi      # 0x1fff0
leaq 0x4df5(%rip), %rsi      # 0x18659
movl $0x16, %edx
callq 0x42f0
movq (%r12), %rsi
movq 0xc777(%rip), %rdi      # 0x1fff0
callq 0x41a0
movq %rax, %r12
leaq 0x50a0(%rip), %rsi      # 0x18928
movl $0x22, %edx
movq %rax, %rdi
callq 0x42f0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x41a0
movq %rax, %r12
leaq 0x50a1(%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 0x13d7a
movq 0x218(%rbx), %rsi
movq 0x48(%rsp), %rdi
movl $0x10, %edx
callq 0x4270
movq 0x50(%rsp), %rdi
callq 0x40a0
testb %al, %al
je 0x13dd0
addq $0x18, %rbx
movq 0x8(%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x28(%r15,%rax)
jne 0x13b5d
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 0x1393c
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 0x13ccc
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 0x13d1f
movq (%r12), %rbx
movl $0x8, %edi
callq 0x42c0
movq %rax, %r15
movq %rax, %rdi
callq 0x174a0
movq %rbp, %rax
testq %rbx, %rbx
je 0x13b12
addq $0x18, 0x78(%rsp)
movabsq $0x7fffffffffffffff, %r13 # imm = 0x7FFFFFFFFFFFFFFF
movq %rbx, %xmm0
movq 0x4a88(%rip), %xmm2     # 0x184a0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x4a8c(%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 0x177c4
movq %rax, %r12
movq %rax, %r15
testq %rax, %rax
je 0x13a99
movq %r14, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x4190
decq %r15
jne 0x13a84
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 0x13a0b
movq %r14, %rdi
callq 0x4060
movq 0x48(%rsp), %rdi
callq 0x4060
movq (%r15), %rdi
testq %rdi, %rdi
je 0x13b32
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 0x13b77
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x13b77
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 0x13b93
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x13bb8
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 0xc41f(%rip), %rdi      # 0x1fff0
leaq 0x506d(%rip), %rsi      # 0x18c45
movl $0x21, %edx
callq 0x42f0
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0xc3f7(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4964(%rip), %rsi      # 0x1856c
movl $0xa, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
jmp 0x13cc2
movq 0xc3c7(%rip), %rdi      # 0x1fff0
leaq 0x5015(%rip), %rsi      # 0x18c45
movl $0x21, %edx
callq 0x42f0
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0xc3a5(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4a88(%rip), %rsi      # 0x186e2
movl $0xb, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
jmp 0x13cc2
movq 0xc378(%rip), %rdi      # 0x1fff0
leaq 0x48d1(%rip), %rsi      # 0x18550
movl $0x1b, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xc352(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x48bf(%rip), %rsi      # 0x1856c
movl $0xa, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
movl $0x2, %edi
callq 0x4320
movq 0xc31d(%rip), %rdi      # 0x1fff0
leaq 0x505f(%rip), %rsi      # 0x18d39
movl $0x21, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xc2f7(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4864(%rip), %rsi      # 0x1856c
movl $0xa, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
jmp 0x13cc2
movq 0xc2ca(%rip), %rdi      # 0x1fff0
leaq 0x500c(%rip), %rsi      # 0x18d39
movl $0x21, %edx
movq 0x78(%rsp), %rbx
callq 0x42f0
movq 0x218(%rbx), %rsi
movq 0x220(%rbx), %rdx
movq 0xc29f(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x4982(%rip), %rsi      # 0x186e2
movl $0xb, %edx
movq %rax, %rdi
callq 0x42f0
movq %r14, %rdi
callq 0x4130
jmp 0x13cc2
movq 0xc26f(%rip), %rdi      # 0x1fff0
leaq 0x47c8(%rip), %rsi      # 0x18550
movl $0x1b, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xc249(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x47b6(%rip), %rsi      # 0x1856c
movl $0xa, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
jmp 0x13cc2
movq 0xc219(%rip), %rdi      # 0x1fff0
leaq 0x4772(%rip), %rsi      # 0x18550
movl $0x1b, %edx
callq 0x42f0
movq 0x218(%rbx), %rsi
movq 0x220(%rbx), %rdx
movq 0xc1f3(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x48d6(%rip), %rsi      # 0x186e2
movl $0xb, %edx
movq %rax, %rdi
callq 0x42f0
movq %r14, %rdi
callq 0x4130
jmp 0x13cc2
movq %rax, %r14
cmpl $0x3, %edx
jne 0x14570
movq %r14, %rdi
callq 0x4110
movq 0xc1af(%rip), %rdi      # 0x1fff0
leaq 0x4879(%rip), %rsi      # 0x186c1
movl $0x20, %edx
callq 0x42f0
movq 0xc197(%rip), %rdi      # 0x1fff0
callq 0x4130
movl $0x4, %edi
callq 0x4320
movq %rax, %r14
callq 0x4480
jmp 0x14570
movq %rdx, %rbx
movq %rax, %r14
movl $0x8, %esi
movq %r15, %rdi
callq 0x42d0
jmp 0x13e90
movq %rdx, %rbx
movq %rax, %r14
cmpl $0x2, %ebx
jne 0x14554
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 0x7720
movq %r14, %rdi
callq 0x4110
movq 0xc123(%rip), %rdi      # 0x1fff0
leaq 0x4851(%rip), %rsi      # 0x18725
movl $0x7, %edx
callq 0x42f0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0xc101(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rdi
callq 0x4130
jmp 0x14515
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x13f1b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
callq 0x4480
jmp 0x14554
movq %rax, %r14
cmpl $0x1, %edx
jne 0x14570
movq %r14, %rdi
callq 0x4110
movq %rax, %r14
movq 0xc0ad(%rip), %rdi      # 0x1fff0
leaq 0x4e11(%rip), %rsi      # 0x18d5b
movl $0x1e, %edx
callq 0x42f0
movq 0x218(%rbx), %rsi
movq 0x220(%rbx), %rdx
movq 0xc087(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x4776(%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 0x13fe1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x13fe1
jmp 0x13fde
movq %rax, %r14
callq 0x4480
jmp 0x14570
movq %rax, %r14
cmpl $0x1, %edx
jne 0x14570
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbfe7(%rip), %rdi      # 0x1fff0
leaq 0x4d4b(%rip), %rsi      # 0x18d5b
movl $0x1e, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xbfc1(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x49bf(%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 0x140a6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x140a6
jmp 0x140a3
movq %rax, %r14
callq 0x4480
jmp 0x14570
movq %rax, %r14
cmpl $0x1, %edx
jne 0x14554
movq %r14, %rdi
callq 0x4110
movq %rax, %r14
movq 0xbf22(%rip), %rdi      # 0x1fff0
leaq 0x4c86(%rip), %rsi      # 0x18d5b
movl $0x1e, %edx
callq 0x42f0
movq 0x218(%rbx), %rsi
movq 0x220(%rbx), %rdx
movq 0xbefc(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x45eb(%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 0x1416c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x1416c
jmp 0x14169
movq %rax, %r14
callq 0x4480
jmp 0x14554
movq %rax, %r14
cmpl $0x1, %edx
jne 0x14554
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbe5c(%rip), %rdi      # 0x1fff0
leaq 0x4bc0(%rip), %rsi      # 0x18d5b
movl $0x1e, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xbe36(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x4834(%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 0x14231
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x14231
jmp 0x1422e
movq %rax, %r14
callq 0x4480
jmp 0x14554
jmp 0x14551
jmp 0x1454a
jmp 0x1454a
jmp 0x1454a
jmp 0x14251
movq %rax, %r14
jmp 0x1458c
movq %rax, %r14
cmpl $0x1, %edx
jne 0x14570
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbd79(%rip), %rdi      # 0x1fff0
leaq 0x45bb(%rip), %rsi      # 0x18839
movl $0x1c, %edx
callq 0x42f0
movq 0x218(%r15), %rsi
movq 0x220(%r15), %rdx
movq 0xbd53(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x4565(%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 0x14314
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x14314
jmp 0x14311
movq %rax, %r14
callq 0x4480
jmp 0x14570
movq %rax, %r14
cmpl $0x1, %edx
jne 0x14570
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbcb4(%rip), %rdi      # 0x1fff0
leaq 0x4924(%rip), %rsi      # 0x18c67
movl $0x1e, %edx
callq 0x42f0
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0xbc92(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x4381(%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 0x143d5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x143d5
jmp 0x143d2
movq %rax, %r14
callq 0x4480
jmp 0x14570
movq %rax, %r14
cmpl $0x1, %edx
jne 0x14570
movq %r14, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbbf3(%rip), %rdi      # 0x1fff0
leaq 0x4863(%rip), %rsi      # 0x18c67
movl $0x1e, %edx
callq 0x42f0
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0xbbcb(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x45c9(%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 0x1449c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x1449c
jmp 0x14499
movq %rax, %r14
callq 0x4480
jmp 0x14570
movq %rax, %r14
cmpl $0x2, %edx
jne 0x14554
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 0x7720
movq %r14, %rdi
callq 0x4110
movq 0xbb0a(%rip), %rdi      # 0x1fff0
leaq 0x4238(%rip), %rsi      # 0x18725
movl $0x7, %edx
callq 0x42f0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0xbae8(%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 0x14539
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
callq 0x4480
jmp 0x14554
movq %rax, %rdi
callq 0x7714
jmp 0x1454a
movq %rax, %r14
jmp 0x14570
jmp 0x14551
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x14570
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1458c
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x145b1
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %r14, %rdi
callq 0x44e0
nop