// File: /workspace/github_cpp_makefile_star2_O2/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 0xfa2c
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
leaq 0x88(%rsi), %rbp
movq %rbp, %rdi
callq 0x40b0
testb %al, %al
je 0xf8e4
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movl $0x450, %ebx            # imm = 0x450
leaq (%rbx,%r13), %rsi
leaq 0x534b(%rip), %r14      # 0x14c3f
leaq 0x88(%rsp), %rdi
movq %r14, %rdx
callq 0x5e08
addq %r15, %rbx
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x5e08
leaq 0x240(%r13), %rdi
movq 0x88(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x4280
leaq 0x2c0(%r13), %rdi
callq 0x40b0
testb %al, %al
je 0xfd11
leaq 0x240(%r15), %rbx
movq 0x68(%rsp), %rsi
pushq $0x30
popq %rdx
movq %rbx, %rdi
callq 0x4280
leaq 0x2c0(%r15), %rdi
callq 0x40b0
testb %al, %al
je 0xfd4d
movq %r13, %rdi
movq %rbx, %rsi
callq 0xf1b0
movq %rbp, 0x38(%rsp)
movq %r15, %rbx
leaq 0x8(%r13), %r15
leaq 0x218(%r13), %rax
movq %rax, 0x8(%rsp)
movq 0x218(%r13), %rsi
pushq $0x8
popq %rdx
movq %r15, %rdi
callq 0x4280
leaq 0x88(%r13), %rbp
movq %rbp, %rdi
callq 0x40b0
testb %al, %al
je 0xfd86
movq %r13, %rdi
callq 0xf44c
movq %rax, %r14
leaq 0x8(%rbx), %rax
movq %rax, 0x30(%rsp)
cmpq (%r12), %r14
jae 0xfa58
movq 0xc612(%rip), %rdi      # 0x1bff0
leaq 0x4c11(%rip), %rsi      # 0x145f6
callq 0x42a0
movq (%r12), %rsi
movq %rax, %rdi
callq 0x41b0
leaq 0x4efb(%rip), %rsi      # 0x148f8
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
movq %r14, %rsi
callq 0x41b0
leaq 0x4c2d(%rip), %rsi      # 0x14644
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
jmp 0xfce8
movq 0xc5bd(%rip), %rdi      # 0x1bff0
leaq 0x4b8a(%rip), %rsi      # 0x145c4
callq 0x42a0
movq %rax, %rdi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4140
jne 0xfb44
movq 0xc58b(%rip), %rdi      # 0x1bff0
leaq 0x4bed(%rip), %rsi      # 0x14659
callq 0x42a0
movq (%r12), %rsi
movq %rax, %rdi
callq 0x41b0
leaq 0x4ea4(%rip), %rsi      # 0x14928
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
movq %r14, %rsi
callq 0x41b0
leaq 0x4ead(%rip), %rsi      # 0x1494b
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
movl $0xa00000, %edi         # imm = 0xA00000
callq 0x4030
movq %rax, %r14
movq 0x8(%rsp), %rax
movq (%rax), %rsi
pushq $0x8
popq %rdx
movq %r15, %rdi
callq 0x4280
movq %rbp, %rdi
callq 0x40b0
testb %al, %al
je 0xfe34
leaq 0x218(%rbx), %r12
movq 0x218(%rbx), %rsi
pushq $0x10
popq %rdx
movq 0x30(%rsp), %rdi
callq 0x4280
movq 0x38(%rsp), %rdi
callq 0x40b0
testb %al, %al
je 0xfe70
addq $0x18, %rbx
movq 0x8(%r13), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x28(%r13,%rax)
jne 0xfc92
movl $0xa00000, %edx         # imm = 0xA00000
movq %r15, %rdi
movq %r14, %rsi
callq 0x4340
movq 0x10(%r13), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4390
jmp 0xfb0f
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x8(%rsp), %rax
movq (%rax), %rsi
pushq $0x8
popq %rdx
movq %r15, %rdi
callq 0x4280
movq %rbp, %rdi
callq 0x40b0
testb %al, %al
je 0xfdc4
movq %rbx, %rbp
leaq 0x218(%rbx), %r13
movq 0x218(%rbx), %rsi
pushq $0x30
popq %rdx
movq 0x30(%rsp), %rdi
callq 0x4280
movq 0x38(%rsp), %rdi
callq 0x40b0
testb %al, %al
je 0xfdfd
movq (%r12), %rbx
pushq $0x8
popq %rdi
callq 0x42c0
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x12bf2
addq $0x18, %rbp
movq %rbp, 0x38(%rsp)
movabsq $0x7fffffffffffffff, %rbp # imm = 0x7FFFFFFFFFFFFFFF
pushq $0xa
popq %r12
movq %rbx, %r13
subq $0x1, %r13
jb 0xfcae
movq %rbx, %xmm0
movq 0x48ae(%rip), %xmm2     # 0x144a0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x48b2(%rip), %xmm3     # 0x144b0
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
movq %r14, %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, 0x60(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x12edc
movq %rax, %rbx
notq %rax
addq %rax, %r14
subq $0x1, %rbx
jb 0xfc66
movq %r15, %rdi
movq %rbp, %rsi
movl %r12d, %edx
callq 0x41a0
jmp 0xfc50
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4060
movq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x4270
movq %rax, %rdi
callq 0x4140
movq %r13, %rbx
jmp 0xfbdb
movq %r15, %rdi
callq 0x4050
movq 0x30(%rsp), %rdi
callq 0x4050
movq %r14, %rdi
callq 0x4370
jmp 0xfce8
movq %r15, %rdi
callq 0x4050
movq 0x30(%rsp), %rdi
callq 0x4050
movq 0x8(%rsp), %rbx
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xfcd3
movq (%rdi), %rax
callq *0x8(%rax)
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x42d0
leaq 0x10(%rsp), %rdi
callq 0x4558
leaq 0x68(%rsp), %rdi
callq 0x4558
leaq 0x88(%rsp), %rdi
callq 0x4558
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xc2d8(%rip), %rdi      # 0x1bff0
leaq 0x4f26(%rip), %rsi      # 0x14c45
callq 0x42a0
leaq 0x88(%rsp), %rsi
movq %rax, %rdi
callq 0x4270
leaq 0x4831(%rip), %rsi      # 0x1456c
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
jmp 0xfdbd
movq 0xc29c(%rip), %rdi      # 0x1bff0
leaq 0x4eea(%rip), %rsi      # 0x14c45
callq 0x42a0
leaq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x4270
leaq 0x496e(%rip), %rsi      # 0x146e2
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
jmp 0xfdbd
movq 0xc263(%rip), %rdi      # 0x1bff0
leaq 0x47bc(%rip), %rsi      # 0x14550
callq 0x42a0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x4270
leaq 0x47bf(%rip), %rsi      # 0x1456c
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
pushq $0x2
jmp 0x103f9
movq 0xc225(%rip), %rdi      # 0x1bff0
leaq 0x4f67(%rip), %rsi      # 0x14d39
callq 0x42a0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x4270
leaq 0x4781(%rip), %rsi      # 0x1456c
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
jmp 0xfdbd
movq 0xc1ec(%rip), %rdi      # 0x1bff0
leaq 0x4f2e(%rip), %rsi      # 0x14d39
callq 0x42a0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4270
leaq 0x48c0(%rip), %rsi      # 0x146e2
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
jmp 0xfdbd
movq 0xc1b5(%rip), %rdi      # 0x1bff0
leaq 0x470e(%rip), %rsi      # 0x14550
callq 0x42a0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x4270
leaq 0x4711(%rip), %rsi      # 0x1456c
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
jmp 0xfdbd
movq 0xc179(%rip), %rdi      # 0x1bff0
leaq 0x46d2(%rip), %rsi      # 0x14550
callq 0x42a0
movq %rax, %rdi
movq %r12, %rsi
callq 0x4270
leaq 0x484d(%rip), %rsi      # 0x146e2
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4140
jmp 0xfdbd
movq %rax, %rbx
cmpl $0x3, %edx
jne 0x1042f
movq %rbx, %rdi
callq 0x4110
movq 0xc12b(%rip), %rdi      # 0x1bff0
leaq 0x47f5(%rip), %rsi      # 0x146c1
callq 0x42a0
movq %rax, %rdi
callq 0x4140
pushq $0x4
jmp 0x103f9
movq %rax, %rbx
callq 0x4470
jmp 0x1042f
movq %rdx, %r14
movq %rax, %rbx
pushq $0x8
popq %rsi
movq 0x8(%rsp), %rdi
callq 0x42d0
jmp 0xff08
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x2, %r14d
jne 0x10425
movq %rbx, %rdi
callq 0x4330
leaq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x43b0
movq %rbx, %rdi
callq 0x4110
movq 0xc0ba(%rip), %rdi      # 0x1bff0
leaq 0x47e8(%rip), %rsi      # 0x14725
callq 0x42a0
leaq 0x40(%rsp), %rsi
movq %rax, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x4140
jmp 0x103f7
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x4558
callq 0x4470
jmp 0x10425
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x1042f
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xc05f(%rip), %rdi      # 0x1bff0
leaq 0x4dc3(%rip), %rsi      # 0x14d5b
callq 0x42a0
movq %rax, %rdi
movq %r12, %rsi
callq 0x4270
leaq 0x473f(%rip), %rsi      # 0x146ee
movq %rax, %rdi
callq 0x42a0
movq %rax, %r14
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x20(%rax)
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x41c0
jmp 0x10370
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4558
jmp 0xfffa
jmp 0xfff7
movq %rax, %rbx
callq 0x4470
jmp 0x1042f
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x1042f
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbfce(%rip), %rdi      # 0x1bff0
leaq 0x4d32(%rip), %rsi      # 0x14d5b
callq 0x42a0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x4270
leaq 0x49bb(%rip), %rsi      # 0x149fd
movq %rax, %rdi
callq 0x42a0
movq %rax, %r14
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x20(%rax)
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x41c0
jmp 0x10370
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4558
jmp 0x1008d
jmp 0x1008a
movq %rax, %rbx
callq 0x4470
jmp 0x1042f
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x10425
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbf3b(%rip), %rdi      # 0x1bff0
leaq 0x4c9f(%rip), %rsi      # 0x14d5b
callq 0x42a0
movq %rax, %rdi
movq %r13, %rsi
callq 0x4270
leaq 0x461b(%rip), %rsi      # 0x146ee
movq %rax, %rdi
callq 0x42a0
movq %rax, %r14
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x40(%rsp), %rdi
callq *0x20(%rax)
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x41c0
jmp 0x10198
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x4558
jmp 0x1011e
jmp 0x1011b
movq %rax, %rbx
callq 0x4470
jmp 0x10425
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x10425
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbeaa(%rip), %rdi      # 0x1bff0
leaq 0x4c0e(%rip), %rsi      # 0x14d5b
callq 0x42a0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x4270
leaq 0x4897(%rip), %rsi      # 0x149fd
movq %rax, %rdi
callq 0x42a0
movq %rax, %r14
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x40(%rsp), %rdi
callq *0x20(%rax)
leaq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x41c0
leaq 0x40(%rsp), %rdi
jmp 0x10375
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x4558
jmp 0x101b6
jmp 0x101b3
movq %rax, %rbx
callq 0x4470
jmp 0x10425
jmp 0x10422
jmp 0x1041b
jmp 0x1041b
movq %rax, %rbx
jmp 0x10439
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x1042f
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbdfb(%rip), %rdi      # 0x1bff0
leaq 0x463d(%rip), %rsi      # 0x14839
callq 0x42a0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x4270
leaq 0x45fc(%rip), %rsi      # 0x14811
movq %rax, %rdi
callq 0x42a0
movq %rax, %r14
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x20(%rax)
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x41c0
jmp 0x10370
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4558
jmp 0x10260
jmp 0x1025d
movq %rax, %rbx
callq 0x4470
jmp 0x1042f
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x1042f
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbd68(%rip), %rdi      # 0x1bff0
leaq 0x49d8(%rip), %rsi      # 0x14c67
callq 0x42a0
leaq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x4270
leaq 0x4446(%rip), %rsi      # 0x146ee
movq %rax, %rdi
callq 0x42a0
movq %rax, %r14
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x20(%rax)
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x41c0
jmp 0x10370
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4558
jmp 0x102f3
jmp 0x102f0
movq %rax, %rbx
callq 0x4470
jmp 0x1042f
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x1042f
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xbcd5(%rip), %rdi      # 0x1bff0
leaq 0x4945(%rip), %rsi      # 0x14c67
callq 0x42a0
leaq 0x88(%rsp), %rsi
movq %rax, %rdi
callq 0x4270
leaq 0x46bf(%rip), %rsi      # 0x149fd
movq %rax, %rdi
callq 0x42a0
movq %rax, %r14
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x20(%rax)
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x41c0
leaq 0x10(%rsp), %rdi
callq 0x4558
leaq 0x4491(%rip), %rdi      # 0x14812
callq 0x4250
pushq $0x1
jmp 0x103f9
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4558
jmp 0x1039e
jmp 0x1039b
movq %rax, %rbx
callq 0x4470
jmp 0x1042f
jmp 0x1041b
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x10425
movq %rbx, %rdi
callq 0x4330
leaq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x43b0
movq %rbx, %rdi
callq 0x4110
movq 0xbc1a(%rip), %rdi      # 0x1bff0
leaq 0x4348(%rip), %rsi      # 0x14725
callq 0x42a0
leaq 0x40(%rsp), %rsi
movq %rax, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x4140
pushq $0x5
popq %rdi
callq 0x4310
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x4558
callq 0x4470
jmp 0x10425
movq %rax, %rdi
callq 0x6194
movq %rax, %rbx
jmp 0x1042f
jmp 0x10422
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4558
leaq 0x68(%rsp), %rdi
callq 0x4558
leaq 0x88(%rsp), %rdi
callq 0x4558
movq %rbx, %rdi
callq 0x44d0