// File: 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
movq %rsp, %rbp
subq $0x540, %rsp            # imm = 0x540
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x238(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x1a5d3
movq 0x11a3d(%rip), %rdi     # 0x2bff0
leaq 0x8ff2(%rip), %rsi      # 0x235ac
callq 0x4310
movq %rax, %rdi
movq 0x119e7(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1bbb2
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
testb $0x1, %al
jne 0x1a5e6
jmp 0x1a5f0
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x238(%rbp), %rsi
addq $0x450, %rsi            # imm = 0x450
leaq 0x9622(%rip), %rdx      # 0x23c27
movq %rdx, -0x240(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x7920
movq -0x240(%rbp), %rdx
movq -0x10(%rbp), %rsi
addq $0x450, %rsi            # imm = 0x450
leaq -0x58(%rbp), %rdi
callq 0x7920
jmp 0x1a632
movq -0x238(%rbp), %rax
addq $0x240, %rax            # imm = 0x240
movq %rax, -0x248(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x4140
movq -0x248(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x42f0
jmp 0x1a665
movq -0x238(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
callq 0x45e0
movb %al, -0x249(%rbp)
jmp 0x1a680
movb -0x249(%rbp), %al
testb $0x1, %al
jne 0x1a7fa
jmp 0x1a690
movq 0x11959(%rip), %rdi     # 0x2bff0
leaq 0x958f(%rip), %rsi      # 0x23c2d
callq 0x4310
movq %rax, -0x258(%rbp)
jmp 0x1a6ac
movq -0x258(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x42e0
movq %rax, -0x260(%rbp)
jmp 0x1a6c5
movq -0x260(%rbp), %rdi
leaq 0x8e81(%rip), %rsi      # 0x23554
callq 0x4310
movq %rax, -0x268(%rbp)
jmp 0x1a6e1
movq -0x268(%rbp), %rdi
movq 0x118c1(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1a6f6
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1bbd0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1bbc7
movq -0x60(%rbp), %rdi
callq 0x4130
movq %rax, -0x70(%rbp)
movq 0x118af(%rip), %rdi     # 0x2bff0
leaq 0x9507(%rip), %rsi      # 0x23c4f
callq 0x4310
movq %rax, -0x270(%rbp)
jmp 0x1a756
movq -0x270(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x42e0
movq %rax, -0x278(%rbp)
jmp 0x1a76f
movq -0x278(%rbp), %rdi
leaq 0x9268(%rip), %rsi      # 0x239e5
callq 0x4310
movq %rax, -0x280(%rbp)
jmp 0x1a78b
movq -0x70(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x90(%rbp), %rdi
callq 0x1eeb0
jmp 0x1a7a5
movq -0x280(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42e0
movq %rax, -0x288(%rbp)
jmp 0x1a7c1
movq -0x288(%rbp), %rdi
movq 0x117f9(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x1a7d6
leaq -0x90(%rbp), %rdi
callq 0x46d8
leaq 0x9011(%rip), %rdi      # 0x237fa
callq 0x42a0
jmp 0x1a7f0
movl $0x1, %edi
callq 0x4400
jmp 0x1a82e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1a822
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1a829
jmp 0x1bbc7
movq -0x10(%rbp), %rax
addq $0x240, %rax            # imm = 0x240
movq %rax, -0x2a0(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4140
movq %rax, -0x298(%rbp)
movl $0x10, %edi
movl $0x20, %esi
callq 0x1ee70
movl %eax, -0x28c(%rbp)
jmp 0x1a866
movl -0x28c(%rbp), %edx
movq -0x298(%rbp), %rsi
movq -0x2a0(%rbp), %rdi
callq 0x42f0
jmp 0x1a881
movq -0x10(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
callq 0x45e0
movb %al, -0x2a1(%rbp)
jmp 0x1a899
movb -0x2a1(%rbp), %al
testb $0x1, %al
jne 0x1aa08
jmp 0x1a8a9
movq 0x11740(%rip), %rdi     # 0x2bff0
leaq 0x9376(%rip), %rsi      # 0x23c2d
callq 0x4310
movq %rax, -0x2b0(%rbp)
jmp 0x1a8c5
movq -0x2b0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x42e0
movq %rax, -0x2b8(%rbp)
jmp 0x1a8de
movq -0x2b8(%rbp), %rdi
leaq 0x8dde(%rip), %rsi      # 0x236ca
callq 0x4310
movq %rax, -0x2c0(%rbp)
jmp 0x1a8fa
movq -0x2c0(%rbp), %rdi
movq 0x116a8(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1a90f
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1bbc7
movq -0x60(%rbp), %rdi
callq 0x4130
movq %rax, -0x98(%rbp)
movq 0x116a4(%rip), %rdi     # 0x2bff0
leaq 0x92fc(%rip), %rsi      # 0x23c4f
callq 0x4310
movq %rax, -0x2c8(%rbp)
jmp 0x1a961
movq -0x2c8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x42e0
movq %rax, -0x2d0(%rbp)
jmp 0x1a97a
movq -0x2d0(%rbp), %rdi
leaq 0x8d4e(%rip), %rsi      # 0x236d6
callq 0x4310
movq %rax, -0x2d8(%rbp)
jmp 0x1a996
movq -0x98(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0xb8(%rbp), %rdi
callq 0x1eeb0
jmp 0x1a9b3
movq -0x2d8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x42e0
movq %rax, -0x2e0(%rbp)
jmp 0x1a9cf
movq -0x2e0(%rbp), %rdi
movq 0x115eb(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x1a9e4
leaq -0xb8(%rbp), %rdi
callq 0x46d8
leaq 0x8e03(%rip), %rdi      # 0x237fa
callq 0x42a0
jmp 0x1a9fe
movl $0x1, %edi
callq 0x4400
jmp 0x1aa3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1aa30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1aa37
jmp 0x1bbc7
movq -0x238(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x240, %rsi            # imm = 0x240
callq 0x19880
jmp 0x1aa55
movq -0x238(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x2e8(%rbp)
addq $0x218, %rdi            # imm = 0x218
callq 0x4140
movq -0x2e8(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x42f0
jmp 0x1aa8c
movq -0x238(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
movb %al, -0x2e9(%rbp)
jmp 0x1aaa4
movb -0x2e9(%rbp), %al
testb $0x1, %al
jne 0x1ac38
jmp 0x1aab4
movq 0x11535(%rip), %rdi     # 0x2bff0
leaq 0x8a76(%rip), %rsi      # 0x23538
callq 0x4310
movq %rax, -0x2f8(%rbp)
jmp 0x1aad0
movq -0x2f8(%rbp), %rdi
movq -0x238(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x300(%rbp)
jmp 0x1aaf3
movq -0x300(%rbp), %rdi
leaq 0x8a53(%rip), %rsi      # 0x23554
callq 0x4310
movq %rax, -0x308(%rbp)
jmp 0x1ab0f
movq -0x308(%rbp), %rdi
movq 0x11493(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1ab24
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1bbc7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1bbc7
movq -0x60(%rbp), %rdi
callq 0x4130
movq %rax, -0xc0(%rbp)
movq 0x1147e(%rip), %rdi     # 0x2bff0
leaq 0x8ca8(%rip), %rsi      # 0x23821
callq 0x4310
movq %rax, -0x310(%rbp)
jmp 0x1ab87
movq -0x310(%rbp), %rdi
movq -0x238(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x318(%rbp)
jmp 0x1abaa
movq -0x318(%rbp), %rdi
leaq 0x8c41(%rip), %rsi      # 0x237f9
callq 0x4310
movq %rax, -0x320(%rbp)
jmp 0x1abc6
movq -0xc0(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0xe0(%rbp), %rdi
callq 0x1eeb0
jmp 0x1abe3
movq -0x320(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x42e0
movq %rax, -0x328(%rbp)
jmp 0x1abff
movq -0x328(%rbp), %rdi
movq 0x113bb(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x1ac14
leaq -0xe0(%rbp), %rdi
callq 0x46d8
leaq 0x8bd3(%rip), %rdi      # 0x237fa
callq 0x42a0
jmp 0x1ac2e
movl $0x1, %edi
callq 0x4400
jmp 0x1ac6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1ac60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1ac67
jmp 0x1bbc7
movq -0x238(%rbp), %rdi
callq 0x19d70
movq %rax, -0x330(%rbp)
jmp 0x1ac81
movq -0x330(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1ad53
movq 0x11346(%rip), %rdi     # 0x2bff0
leaq 0x892d(%rip), %rsi      # 0x235de
callq 0x4310
movq %rax, -0x338(%rbp)
jmp 0x1acbf
movq -0x338(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x40d0
movq %rax, -0x340(%rbp)
jmp 0x1acdb
movq -0x340(%rbp), %rdi
leaq 0x8bf7(%rip), %rsi      # 0x238e0
callq 0x4310
movq %rax, -0x348(%rbp)
jmp 0x1acf7
movq -0x348(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x40d0
movq %rax, -0x350(%rbp)
jmp 0x1ad13
movq -0x350(%rbp), %rdi
leaq 0x890b(%rip), %rsi      # 0x2362c
callq 0x4310
movq %rax, -0x358(%rbp)
jmp 0x1ad2f
movq -0x358(%rbp), %rdi
movq 0x11273(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1ad44
movl $0x1, -0xec(%rbp)
jmp 0x1bba0
movq -0xe8(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x1b3a9
movq 0x11282(%rip), %rdi     # 0x2bff0
leaq 0x88cc(%rip), %rsi      # 0x23641
callq 0x4310
movq %rax, -0x360(%rbp)
jmp 0x1ad83
movq -0x360(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x40d0
movq %rax, -0x368(%rbp)
jmp 0x1ad9f
movq -0x368(%rbp), %rdi
leaq 0x8b63(%rip), %rsi      # 0x23910
callq 0x4310
movq %rax, -0x370(%rbp)
jmp 0x1adbb
movq -0x370(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x40d0
movq %rax, -0x378(%rbp)
jmp 0x1add7
movq -0x378(%rbp), %rdi
leaq 0x8b4e(%rip), %rsi      # 0x23933
callq 0x4310
movq %rax, -0x380(%rbp)
jmp 0x1adf3
movq -0x380(%rbp), %rdi
movq 0x111af(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1ae08
movq $0xa00000, -0x100(%rbp) # imm = 0xA00000
movl $0xa00000, %edi         # imm = 0xA00000
callq 0x4030
movq %rax, -0x388(%rbp)
jmp 0x1ae26
movq -0x388(%rbp), %rax
movq %rax, -0xf8(%rbp)
jmp 0x1aeb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl $0x3, %ecx
cmpl %ecx, %eax
jne 0x1bbc7
movq -0x60(%rbp), %rdi
callq 0x4130
movq %rax, -0x108(%rbp)
movq 0x11187(%rip), %rdi     # 0x2bff0
leaq 0x8839(%rip), %rsi      # 0x236a9
callq 0x4310
movq %rax, -0x390(%rbp)
jmp 0x1ae7e
movq -0x390(%rbp), %rdi
movq 0x11124(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1ae93
movl $0x4, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x4580
jmp 0x1aeb0
jmp 0x1bbc7
movq -0x238(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x398(%rbp)
addq $0x218, %rdi            # imm = 0x218
callq 0x4140
movq -0x398(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x42f0
jmp 0x1aeec
movq -0x238(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
movb %al, -0x399(%rbp)
jmp 0x1af04
movb -0x399(%rbp), %al
testb $0x1, %al
jne 0x1b087
jmp 0x1af14
movq 0x110d5(%rip), %rdi     # 0x2bff0
leaq 0x8616(%rip), %rsi      # 0x23538
callq 0x4310
movq %rax, -0x3a8(%rbp)
jmp 0x1af30
movq -0x3a8(%rbp), %rdi
movq -0x238(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x3b0(%rbp)
jmp 0x1af53
movq -0x3b0(%rbp), %rdi
leaq 0x85f3(%rip), %rsi      # 0x23554
callq 0x4310
movq %rax, -0x3b8(%rbp)
jmp 0x1af6f
movq -0x3b8(%rbp), %rdi
movq 0x11033(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1af84
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1bbc7
movq -0x60(%rbp), %rdi
callq 0x4130
movq %rax, -0x110(%rbp)
movq 0x1102f(%rip), %rdi     # 0x2bff0
leaq 0x8d7b(%rip), %rsi      # 0x23d43
callq 0x4310
movq %rax, -0x3c0(%rbp)
jmp 0x1afd6
movq -0x3c0(%rbp), %rdi
movq -0x238(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x3c8(%rbp)
jmp 0x1aff9
movq -0x3c8(%rbp), %rdi
leaq 0x89de(%rip), %rsi      # 0x239e5
callq 0x4310
movq %rax, -0x3d0(%rbp)
jmp 0x1b015
movq -0x110(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x130(%rbp), %rdi
callq 0x1eeb0
jmp 0x1b032
movq -0x3d0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x42e0
movq %rax, -0x3d8(%rbp)
jmp 0x1b04e
movq -0x3d8(%rbp), %rdi
movq 0x10f6c(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x1b063
leaq -0x130(%rbp), %rdi
callq 0x46d8
leaq 0x8784(%rip), %rdi      # 0x237fa
callq 0x42a0
jmp 0x1b07d
movl $0x1, %edi
callq 0x4400
jmp 0x1b0bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1b0af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1b0b6
jmp 0x1bbc7
movq -0x10(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x3e0(%rbp)
addq $0x218, %rdi            # imm = 0x218
callq 0x4140
movq -0x3e0(%rbp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0x42f0
jmp 0x1b0ef
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
movb %al, -0x3e1(%rbp)
jmp 0x1b104
movb -0x3e1(%rbp), %al
testb $0x1, %al
jne 0x1b281
jmp 0x1b114
movq 0x10ed5(%rip), %rdi     # 0x2bff0
leaq 0x8416(%rip), %rsi      # 0x23538
callq 0x4310
movq %rax, -0x3f0(%rbp)
jmp 0x1b130
movq -0x3f0(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x3f8(%rbp)
jmp 0x1b150
movq -0x3f8(%rbp), %rdi
leaq 0x856c(%rip), %rsi      # 0x236ca
callq 0x4310
movq %rax, -0x400(%rbp)
jmp 0x1b16c
movq -0x400(%rbp), %rdi
movq 0x10e36(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1b181
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1bbc7
movq -0x60(%rbp), %rdi
callq 0x4130
movq %rax, -0x138(%rbp)
movq 0x10e32(%rip), %rdi     # 0x2bff0
leaq 0x8b7e(%rip), %rsi      # 0x23d43
callq 0x4310
movq %rax, -0x408(%rbp)
jmp 0x1b1d3
movq -0x408(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x410(%rbp)
jmp 0x1b1f3
movq -0x410(%rbp), %rdi
leaq 0x84d5(%rip), %rsi      # 0x236d6
callq 0x4310
movq %rax, -0x418(%rbp)
jmp 0x1b20f
movq -0x138(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x158(%rbp), %rdi
callq 0x1eeb0
jmp 0x1b22c
movq -0x418(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x42e0
movq %rax, -0x420(%rbp)
jmp 0x1b248
movq -0x420(%rbp), %rdi
movq 0x10d72(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x1b25d
leaq -0x158(%rbp), %rdi
callq 0x46d8
leaq 0x858a(%rip), %rdi      # 0x237fa
callq 0x42a0
jmp 0x1b277
movl $0x1, %edi
callq 0x4400
jmp 0x1b2b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1b2a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1b2b0
jmp 0x1bbc7
jmp 0x1b2b7
movq -0x238(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rcx), %rcx
leaq 0x8(%rax,%rcx), %rdi
callq 0x4440
movb %al, -0x421(%rbp)
jmp 0x1b2d8
movb -0x421(%rbp), %al
testb $0x1, %al
jne 0x1b2e4
jmp 0x1b359
movq -0x238(%rbp), %rdi
addq $0x8, %rdi
movq -0xf8(%rbp), %rsi
movl $0xa00000, %edx         # imm = 0xA00000
callq 0x4450
jmp 0x1b302
movq -0x238(%rbp), %rdi
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x440(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x438(%rbp)
addq $0x8, %rdi
callq 0x46c0
movq %rax, -0x430(%rbp)
jmp 0x1b338
movq -0x430(%rbp), %rdx
movq -0x438(%rbp), %rsi
movq -0x440(%rbp), %rdi
callq 0x44a0
jmp 0x1b354
jmp 0x1b2b7
movq -0x238(%rbp), %rdi
addq $0x8, %rdi
callq 0x4060
jmp 0x1b36b
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x4060
jmp 0x1b37a
movq -0xf8(%rbp), %rax
movq %rax, -0x448(%rbp)
cmpq $0x0, %rax
je 0x1b39a
movq -0x448(%rbp), %rdi
callq 0x4480
movl $0x1, -0xec(%rbp)
jmp 0x1bba0
jmp 0x1b3ab
leaq -0x178(%rbp), %rdi
callq 0x44d0
movq -0x238(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x450(%rbp)
addq $0x218, %rdi            # imm = 0x218
callq 0x4140
movq -0x450(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x42f0
jmp 0x1b3ee
movq -0x238(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
movb %al, -0x451(%rbp)
jmp 0x1b406
movb -0x451(%rbp), %al
testb $0x1, %al
jne 0x1b589
jmp 0x1b416
movq 0x10bd3(%rip), %rdi     # 0x2bff0
leaq 0x88fd(%rip), %rsi      # 0x23d21
callq 0x4310
movq %rax, -0x460(%rbp)
jmp 0x1b432
movq -0x460(%rbp), %rdi
movq -0x238(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x468(%rbp)
jmp 0x1b455
movq -0x468(%rbp), %rdi
leaq 0x80f1(%rip), %rsi      # 0x23554
callq 0x4310
movq %rax, -0x470(%rbp)
jmp 0x1b471
movq -0x470(%rbp), %rdi
movq 0x10b31(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1b486
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1bbbb
movq -0x60(%rbp), %rdi
callq 0x4130
movq %rax, -0x180(%rbp)
movq 0x10b2d(%rip), %rdi     # 0x2bff0
leaq 0x8879(%rip), %rsi      # 0x23d43
callq 0x4310
movq %rax, -0x478(%rbp)
jmp 0x1b4d8
movq -0x478(%rbp), %rdi
movq -0x238(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x480(%rbp)
jmp 0x1b4fb
movq -0x480(%rbp), %rdi
leaq 0x84dc(%rip), %rsi      # 0x239e5
callq 0x4310
movq %rax, -0x488(%rbp)
jmp 0x1b517
movq -0x180(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x1a0(%rbp), %rdi
callq 0x1eeb0
jmp 0x1b534
movq -0x488(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x42e0
movq %rax, -0x490(%rbp)
jmp 0x1b550
movq -0x490(%rbp), %rdi
movq 0x10a6a(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x1b565
leaq -0x1a0(%rbp), %rdi
callq 0x46d8
leaq 0x8282(%rip), %rdi      # 0x237fa
callq 0x42a0
jmp 0x1b57f
movl $0x1, %edi
callq 0x4400
jmp 0x1b5bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1b5b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1b5b8
jmp 0x1bbbb
movq -0x10(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x4a8(%rbp)
addq $0x218, %rdi            # imm = 0x218
callq 0x4140
movq %rax, -0x4a0(%rbp)
movl $0x10, %edi
movl $0x20, %esi
callq 0x1ee70
movl %eax, -0x494(%rbp)
jmp 0x1b5f9
movl -0x494(%rbp), %edx
movq -0x4a0(%rbp), %rsi
movq -0x4a8(%rbp), %rdi
callq 0x42f0
jmp 0x1b614
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
movb %al, -0x4a9(%rbp)
jmp 0x1b629
movb -0x4a9(%rbp), %al
testb $0x1, %al
jne 0x1b7a6
jmp 0x1b639
movq 0x109b0(%rip), %rdi     # 0x2bff0
leaq 0x86da(%rip), %rsi      # 0x23d21
callq 0x4310
movq %rax, -0x4b8(%rbp)
jmp 0x1b655
movq -0x4b8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x4c0(%rbp)
jmp 0x1b675
movq -0x4c0(%rbp), %rdi
leaq 0x8047(%rip), %rsi      # 0x236ca
callq 0x4310
movq %rax, -0x4c8(%rbp)
jmp 0x1b691
movq -0x4c8(%rbp), %rdi
movq 0x10911(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1b6a6
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1bbbb
movq -0x60(%rbp), %rdi
callq 0x4130
movq %rax, -0x1a8(%rbp)
movq 0x1090d(%rip), %rdi     # 0x2bff0
leaq 0x8659(%rip), %rsi      # 0x23d43
callq 0x4310
movq %rax, -0x4d0(%rbp)
jmp 0x1b6f8
movq -0x4d0(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0x4d8(%rbp)
jmp 0x1b718
movq -0x4d8(%rbp), %rdi
leaq 0x7fb0(%rip), %rsi      # 0x236d6
callq 0x4310
movq %rax, -0x4e0(%rbp)
jmp 0x1b734
movq -0x1a8(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
callq 0x1eeb0
jmp 0x1b751
movq -0x4e0(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x42e0
movq %rax, -0x4e8(%rbp)
jmp 0x1b76d
movq -0x4e8(%rbp), %rdi
movq 0x1084d(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x1b782
leaq -0x1c8(%rbp), %rdi
callq 0x46d8
leaq 0x8065(%rip), %rdi      # 0x237fa
callq 0x42a0
jmp 0x1b79c
movl $0x1, %edi
callq 0x4400
jmp 0x1b7da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1b7ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1b7d5
jmp 0x1bbbb
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x1d0(%rbp)
movl $0x8, %edi
callq 0x4330
movq %rax, -0x4f0(%rbp)
jmp 0x1b7fb
movq -0x4f0(%rbp), %rdi
callq 0x22380
jmp 0x1b809
movq -0x4f0(%rbp), %rax
movq %rax, -0x1e0(%rbp)
jmp 0x1b8ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1b847
movq -0x4f0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x8, %esi
callq 0x4340
movl -0x64(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x1bbbb
movq -0x60(%rbp), %rdi
movq %rdi, -0x4f8(%rbp)
callq 0x4430
movq %rax, %rsi
leaq -0x200(%rbp), %rdi
callq 0x4150
jmp 0x1b878
movq -0x4f8(%rbp), %rdi
callq 0x4130
movq 0x10765(%rip), %rdi     # 0x2bff0
leaq 0x7e7b(%rip), %rsi      # 0x2370d
callq 0x4310
movq %rax, -0x500(%rbp)
jmp 0x1b8a0
movq -0x500(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x42e0
movq %rax, -0x508(%rbp)
jmp 0x1b8bc
movq -0x508(%rbp), %rdi
movq 0x106e6(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1b8d1
movl $0x5, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1b8fa
jmp 0x1bbbb
jmp 0x1b901
cmpq $0x0, -0x1d0(%rbp)
je 0x1bb38
movq -0x1e0(%rbp), %rdi
movq -0x1d0(%rbp), %xmm0
movaps 0x7b7b(%rip), %xmm2     # 0x234a0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x7b7f(%rip), %xmm1     # 0x234b0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm3
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm3, %xmm0
movsd %xmm0, -0x208(%rbp)
movq -0xe8(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0x210(%rbp)
leaq -0x208(%rbp), %rsi
leaq -0x210(%rbp), %rdx
callq 0x227a0
movq %rax, -0x510(%rbp)
jmp 0x1b987
movq -0x510(%rbp), %rax
movq %rax, -0x1d8(%rbp)
jmp 0x1ba5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x1bbbb
movq -0x60(%rbp), %rdi
movq %rdi, -0x518(%rbp)
callq 0x4430
movq %rax, %rsi
leaq -0x230(%rbp), %rdi
callq 0x4150
jmp 0x1b9d7
movq -0x518(%rbp), %rdi
callq 0x4130
movq 0x10606(%rip), %rdi     # 0x2bff0
leaq 0x7d1c(%rip), %rsi      # 0x2370d
callq 0x4310
movq %rax, -0x520(%rbp)
jmp 0x1b9ff
movq -0x520(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x42e0
movq %rax, -0x528(%rbp)
jmp 0x1ba1b
movq -0x528(%rbp), %rdi
movq 0x10587(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1ba30
movl $0x5, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1ba59
jmp 0x1bbbb
movq -0x1d8(%rbp), %rcx
addq $0x1, %rcx
movq -0xe8(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, -0x1d8(%rbp)
je 0x1bad6
movq -0x238(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x530(%rbp)
callq 0x1f390
movq -0x530(%rbp), %rdi
movq %rax, %rsi
movl $0xa, %edx
callq 0x41f0
jmp 0x1bab1
movq -0x1d8(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x1d8(%rbp)
jmp 0x1ba7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1bbbb
movq -0x238(%rbp), %rdi
addq $0x8, %rdi
leaq -0x178(%rbp), %rsi
callq 0x4080
jmp 0x1baef
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
leaq -0x178(%rbp), %rsi
callq 0x42e0
movq %rax, -0x538(%rbp)
jmp 0x1bb0c
movq -0x538(%rbp), %rdi
movq 0x10496(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1bb21
movq -0x1d0(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x1d0(%rbp)
jmp 0x1b901
movq -0x238(%rbp), %rdi
addq $0x8, %rdi
callq 0x4060
jmp 0x1bb4a
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x4060
jmp 0x1bb59
movq -0x1e0(%rbp), %rax
movq %rax, -0x540(%rbp)
cmpq $0x0, %rax
je 0x1bb8a
movq -0x540(%rbp), %rdi
callq 0x1ef60
movq -0x540(%rbp), %rdi
movl $0x8, %esi
callq 0x4340
leaq -0x178(%rbp), %rdi
callq 0x46d8
movl $0x0, -0xec(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x46d8
leaq -0x38(%rbp), %rdi
callq 0x46d8
addq $0x540, %rsp            # imm = 0x540
popq %rbp
retq
leaq -0x178(%rbp), %rdi
callq 0x46d8
leaq -0x58(%rbp), %rdi
callq 0x46d8
leaq -0x38(%rbp), %rdi
callq 0x46d8
movq -0x60(%rbp), %rdi
callq 0x4610
movq %rax, %rdi
callq 0x82c0
nopw (%rax,%rax)