// File: /workspace/github_cpp_makefile_star2_O1/tonymugen[P]sampleSNPs/varfiles.cpp
// Function: sampFiles::BedFileI::sampleLD(sampFiles::PopIndex const&, unsigned long const&)
void BedFileI::sampleLD(const PopIndex &popID, const uint64_t &n){
	if (n == 0) {
		cerr << "WARNING: zero SNPs requested. Nothing to be done." << endl;
		return;
	}
    if (_varFile.is_open()) {
        _varFile.close();
    }
	if (!_bimFile.is_open()) {
		try {
			string bimName = _fileStub + ".bim";
			_bimFile.open(bimName.c_str(), ios::in);
			if (!_bimFile.is_open()) {
				cerr << "ERROR: failed to open .bim file " << bimName << " for input" << endl;
				exit(2);
			}

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

	uint64_t N = _numLines(); // have to do this first to set _nCols properly
	if (_nCols != popID.size()) {
		cerr << "Sample size the population index (" << popID.size() << ") not equal to sample size (" << _nCols << ") in the .fam file" << endl;
		exit(5);
	}
	const uint64_t Nbed = (_nCols/4UL) + static_cast<uint64_t>( (_nCols%4UL) > 0UL ); // 4 SNPs/byte plus padding in BED
    uint64_t nSamp      = 2 * n; // n is the number of pairs

    try { // has to be here, because _numLines() closes the file
        _varFile.open(_fileName.c_str(), ios::in | ios::binary);
		if (!_varFile.is_open()) {
			cerr << "ERROR: failed to open .bed file " << _fileName << " for input" << endl;
			exit(2);
		}

        // check the magic bytes and SNP-major status
        char magic[3];
        _varFile.read(magic, 3);
        if ( (magic[0] != static_cast<char>(0x6C)) || (magic[1] != static_cast<char>(0x1B)) ) {
            cerr << "ERROR: binary file " << _fileName << " not recognized as BED" << endl;
            exit(2);
        } else if (magic[2] != static_cast<char>(0x01)){
            cerr << "ERROR: binary file " << _fileName << " not SNP-major. Run a newer version of plink to fix it." << endl;
            exit(3);
        }
    } catch (system_error &error) {
        cerr << "ERROR: cannot open BED file " << _fileName << ": " << error.code().message() << flush;
        perror(" ");
        exit(1);
    }

	const string outName = _fileStub + "_LD.tsv";
	if (nSamp > N) {
		cerr << "ERROR: requested a sample of " << nSamp << " SNPs that is greater than the number of SNPs (" << N << ") in the input file." << endl;
		return;
	} else if (nSamp == N) {
		cerr << "WARNING: the number of sampled SNPs the same as the total number of SNPs in the file. LD will be between neighboring loci." << endl;
		// use neighboring loci
		char *locus1  = new char[Nbed];
		char *locus2  = new char[Nbed];
		uint64_t cumS = 0; // cumulative position in the file
		vector<double> rSq(popID.popNumber());
		vector<double> Dprime(popID.popNumber());
		vector<double> cnt1(popID.popNumber());
		vector<double> cnt2(popID.popNumber());
		string chrID;   // chromosome ID
		uint64_t pos1;  // position of locus1
		uint64_t pos2;  // position of locus2
		string bimLine; // line in the .bim file
		string field;   // single field in the .bim file
		stringstream lineStream;

		ofstream outFile(outName);
		outFile << "ChrID\tpos1\tpos2\tDistance"  << flush;
		for (unsigned short iPop = 1; iPop <= popID.popNumber(); iPop++) {
			outFile << "\trSq_" << iPop << "\tDprime_" << iPop << "\tn1_" << iPop << "\tn2_" << iPop << flush;
		}
		outFile << endl;

		while (nSamp) {
			// first locus in the pair
			_varFile.seekg(cumS*Nbed + 3); // seekg() index is base-0
			_varFile.read(locus1, Nbed);
			getline(_bimFile, bimLine);
			cumS++;
			nSamp--;

			lineStream.str(bimLine); // replaces whatever was there from before
			lineStream >> field;
			chrID = field;
			lineStream >> field >> field >> field;
			pos1 = atoi(field.c_str());

			// second locus
			_varFile.seekg(cumS*Nbed + 3);
			_varFile.read(locus2, Nbed);
			getline(_bimFile, bimLine);
			cumS++;
			nSamp--;

			lineStream.str(bimLine);
			lineStream >> field;
			if (chrID != field) { // if the chromosome number changes, we discard this pair and continue
				continue;
			}
			lineStream >> field >> field >> field;
			pos2 = atoi(field.c_str());
			if (pos2 <= pos1) {
				cerr << "WARNING: second SNP position (" << pos2 << ") no larger than the first (" << pos1 << ") on chromosome " << chrID << ". Skipping this pair without re-trying." << endl;
				continue;
			}
			_ld(locus1, locus2, popID, rSq, Dprime, cnt1, cnt2);
			outFile << chrID << "\t" << pos1 << "\t" << pos2 << "\t" << pos2 - pos1 << flush;
			for (size_t iPop = 0; iPop < popID.popNumber(); iPop++) {
				outFile <<  "\t" << rSq[iPop] << "\t" << Dprime[iPop] << "\t" << cnt1[iPop] << "\t" << cnt2[iPop] << flush;
			}
			outFile << endl;
		}

		delete [] locus1;
		delete [] locus2;
		_varFile.close();
		_bimFile.close();
		outFile.close();
        return;
	}
	// sample loci and calculate LD
	char *locus1  = new char[Nbed];
	char *locus2  = new char[Nbed];
	uint64_t cumS = 0; // cumulative position in the file
	uint64_t S;
	vector<double> rSq(popID.popNumber());
	vector<double> Dprime(popID.popNumber());
	vector<double> cnt1(popID.popNumber());
	vector<double> cnt2(popID.popNumber());
	string chrID;   // chromosome ID
	uint64_t pos1;  // position of locus1
	uint64_t pos2;  // position of locus2
	string bimLine; // line in the .bim file
	string field;   // single field in the .bim file
	stringstream lineStream;

	ofstream outFile(outName);
	outFile << "ChrID\tpos1\tpos2\tDistance"  << flush;
	for (unsigned short iPop = 1; iPop <= popID.popNumber(); iPop++) {
		outFile << "\trSq_" << iPop << "\tDprime_" << iPop << "\tn1_" << iPop << "\tn2_" << iPop << flush;
	}
	outFile << endl;

	RanDraw *snpSamp;  // so that I can catch RanDraw constructor exceptions
	try {
		snpSamp = new RanDraw();
	} catch (string error) {
		cerr << "ERROR: " << error << endl;
		exit(5);
	}

	while (nSamp) {
		// first locus in the pair
		try {
			S = snpSamp->vitter(nSamp, N); // sample the number of SNPs to skip; keep track of the running total
		} catch (string error) {
			cerr << "ERROR: " << error << endl;
			exit(5);
		}
		cumS += S;
		N    -= S + 1;
		_varFile.seekg(cumS*Nbed + 3); // seekg() index is base-0
		_varFile.read(locus1, Nbed);
		cumS++;                        // step up cumS because seekg() will not change it (unlike the getline() that automatially advances)
		while (S) { // skipping S lines in the bim file
			_bimFile.ignore(numeric_limits<streamsize>::max(), '\n');
 			S--;
		}
		getline(_bimFile, bimLine);
		lineStream.str(bimLine); // replaces whatever was there from before
		lineStream >> field;
		chrID = field;
		lineStream >> field >> field >> field;
		pos1 = atoi(field.c_str());
		nSamp--;

		// second locus
		try {
			S = snpSamp->vitter(nSamp, N);
		} catch (string error) {
			cerr << "ERROR: " << error << endl;
			exit(5);
		}
		cumS += S;
		N    -= S + 1;
		_varFile.seekg(cumS*Nbed + 3);
		_varFile.read(locus2, Nbed);
		cumS++;
		while (S) {
			_bimFile.ignore(numeric_limits<streamsize>::max(), '\n');
			S--;
		}
		getline(_bimFile, bimLine);

		lineStream.str(bimLine);
		lineStream >> field;
		if (chrID != field) { // if the chromosome number changes, we discard this pair and start over
			nSamp++;          // back up so that we end up with the correct number of pairs regardless of how many chromosome boundaries we cross
			continue;
		}
		lineStream >> field >> field >> field;
		pos2 = atoi(field.c_str());
		if (pos2 <= pos1) {
			cerr << "WARNING: second SNP position (" << pos2 << ") no larger than the first (" << pos1 << ") on chromosome " << chrID << ". Skipping this pair without re-trying." << endl;
			nSamp--; // will not re-try in this case
			continue;
		}
		_ld(locus1, locus2, popID, rSq, Dprime, cnt1, cnt2);
		outFile << chrID << "\t" << pos1 << "\t" << pos2 << "\t" << pos2 - pos1 << flush;
		for (size_t iPop = 0; iPop < popID.popNumber(); iPop++) {
			outFile <<  "\t" << rSq[iPop] << "\t" << Dprime[iPop] << "\t" << cnt1[iPop] << "\t" << cnt2[iPop] << flush;
		}
		outFile << endl;
		nSamp--;
	}

	delete [] locus1;
	delete [] locus2;
	_varFile.close();
	_bimFile.close();
	outFile.close();

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x508, %rsp            # imm = 0x508
cmpq $0x0, (%rdx)
je 0xed1a
movq %rdx, %r13
movq %rdi, %r12
movq %rsi, 0x50(%rsp)
leaq 0x8(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x88(%rdi), %rbx
movq %rbx, %rdi
callq 0x40a0
testb %al, %al
je 0xeaf0
movq 0x10(%rsp), %rdi
callq 0x4060
leaq 0x458(%r12), %r14
leaq 0x4d8(%r12), %rbp
movq %rbp, %rdi
callq 0x40a0
testb %al, %al
jne 0xeb92
leaq 0x180(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x668(%r12), %rsi
movq 0x670(%r12), %rdx
addq %rsi, %rdx
leaq 0x170(%rsp), %rdi
callq 0x7720
leaq 0x9cf1(%rip), %rsi      # 0x18834
leaq 0x170(%rsp), %rdi
callq 0x4530
movq 0x170(%rsp), %rsi
movq %r14, %rdi
movl $0x8, %edx
callq 0x4270
movq %rbp, %rdi
callq 0x40a0
testb %al, %al
je 0x10168
movq 0x170(%rsp), %rdi
cmpq %r15, %rdi
je 0xeb92
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %r12, %rdi
callq 0x8f46
movq %rax, 0x18(%rsp)
movq 0x238(%r12), %rax
movq 0x50(%rsp), %rbp
cmpq 0x18(%rbp), %rax
jne 0xfffc
movq %rax, %rcx
shrq $0x2, %rcx
andl $0x3, %eax
cmpq $0x1, %rax
sbbq $-0x1, %rcx
movq %rcx, 0x20(%rsp)
movq (%r13), %r15
movq 0x218(%r12), %rsi
movq 0x10(%rsp), %rdi
movl $0xc, %edx
callq 0x4270
movq %rbx, %rdi
callq 0x40a0
testb %al, %al
je 0x1005b
leaq 0x170(%rsp), %rsi
movl $0x3, %edx
movq 0x10(%rsp), %rdi
callq 0x4350
cmpb $0x6c, 0x170(%rsp)
jne 0x100b3
cmpb $0x1b, 0x171(%rsp)
jne 0x100b3
cmpb $0x1, 0x172(%rsp)
jne 0x1010b
leaq 0x130(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x668(%r12), %rsi
movq 0x670(%r12), %rdx
addq %rsi, %rdx
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
callq 0x7720
leaq 0x9d9b(%rip), %rsi      # 0x18a0a
movq %rbx, %rdi
callq 0x4530
addq %r15, %r15
movq %r15, 0x78(%rsp)
cmpq 0x18(%rsp), %r15
jbe 0xed6d
movq 0x1135f(%rip), %rdi     # 0x1fff0
leaq 0x995e(%rip), %rsi      # 0x185f6
movl $0x1d, %edx
callq 0x42f0
movq 0x11347(%rip), %rdi     # 0x1fff0
movq 0x78(%rsp), %rsi
callq 0x41a0
movq %rax, %rbx
leaq 0x9c3b(%rip), %rsi      # 0x188f8
movl $0x2f, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x41a0
movq %rax, %rbx
leaq 0x9963(%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 0xffc5
movq 0x112cf(%rip), %rbx     # 0x1fff0
leaq 0x989c(%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 $0x508, %rsp            # imm = 0x508
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x41b0
jne 0xf5d5
movq 0x11276(%rip), %rbx     # 0x1fff0
leaq 0x9c91(%rip), %rsi      # 0x18a12
movl $0x7a, %edx
movq %rbx, %rdi
callq 0x42f0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq 0x11244(%rip), %rdi     # 0x1fff0
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x4030
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
callq 0x4030
movq %rax, 0x48(%rsp)
movq 0x8(%rbp), %rsi
subq (%rbp), %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rbx, %rsi
leaq 0x58(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x169f8
movq 0x8(%rbp), %rsi
subq (%rbp), %rsi
sarq $0x3, %rsi
imulq %rbx, %rsi
leaq 0xf0(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x169f8
movq 0x8(%rbp), %rsi
subq (%rbp), %rsi
sarq $0x3, %rsi
imulq %rbx, %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x169f8
movq 0x8(%rbp), %rsi
subq (%rbp), %rsi
sarq $0x3, %rsi
imulq %rbx, %rsi
leaq 0xc0(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x169f8
leaq 0x90(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0xb0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x38(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x380(%rsp), %rdi
callq 0x41c0
leaq 0x170(%rsp), %rdi
leaq 0x120(%rsp), %rsi
movl $0x10, %edx
callq 0x4540
leaq 0x9cab(%rip), %rsi      # 0x18b81
leaq 0x170(%rsp), %rdi
movl $0x18, %edx
callq 0x42f0
leaq 0x170(%rsp), %rdi
callq 0x41b0
movq 0x50(%rsp), %rcx
movq 0x8(%rcx), %rax
cmpq (%rcx), %rax
je 0xefd7
movl $0x1, %ebp
movw $0x2, %r15w
leaq 0x170(%rsp), %r13
leaq 0x9c8e(%rip), %r12      # 0x18bae
movl $0x5, %edx
movq %r13, %rdi
leaq 0x9c6b(%rip), %rsi      # 0x18b9a
callq 0x42f0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x41a0
movq %rax, %rbx
movl $0x8, %edx
movq %rax, %rdi
leaq 0x9c4f(%rip), %rsi      # 0x18ba0
callq 0x42f0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x41a0
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x9c36(%rip), %rsi      # 0x18ba9
callq 0x42f0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x41a0
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x42f0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x41a0
movq %rax, %rdi
callq 0x41b0
movzwl %r15w, %ebp
movq 0x50(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
incl %r15d
cmpq %rbp, %rax
jae 0xef20
movq 0x170(%rsp), %rax
leaq 0x170(%rsp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
leaq 0x170(%rsp), %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
cmpq $0x0, 0x78(%rsp)
je 0xf474
xorl %r15d, %r15d
leaq 0x9b09(%rip), %rbp      # 0x18b2c
movq %r15, %rsi
imulq 0x20(%rsp), %rsi
addq $0x3, %rsi
movq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x4360
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x4350
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %edx
movq %r14, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4500
leaq 0x398(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4410
leaq 0x380(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
leaq 0x80(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4160
leaq 0x380(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movq %r15, %rbx
orq $0x1, %rbx
movq 0x28(%rsp), %rdi
callq 0x4440
movl %eax, %r13d
imulq 0x20(%rsp), %rbx
addq $0x3, %rbx
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x4360
movq 0x10(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x4350
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %edx
movq %r14, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4500
leaq 0x398(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4410
leaq 0x380(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movq 0x88(%rsp), %rdx
cmpq 0x30(%rsp), %rdx
jne 0xf464
testq %rdx, %rdx
je 0xf19d
movq 0x28(%rsp), %rsi
movq 0x80(%rsp), %rdi
callq 0x42e0
testl %eax, %eax
jne 0xf464
leaq 0x380(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movslq %r13d, %r13
movq 0x28(%rsp), %rdi
callq 0x4440
movslq %eax, %rbx
cmpl %r13d, %ebx
jbe 0xf3ae
movq 0x18(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x50(%rsp), %rcx
leaq 0x58(%rsp), %r8
leaq 0xf0(%rsp), %r9
leaq 0xc0(%rsp), %rax
pushq %rax
leaq 0xe0(%rsp), %rax
pushq %rax
callq 0xa608
addq $0x10, %rsp
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
leaq 0x170(%rsp), %rdi
callq 0x42f0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42f0
movq %r12, %rdi
movq %r13, %rsi
callq 0x41a0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42f0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x41a0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42f0
subq %r13, %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x41a0
movq %rax, %rdi
callq 0x41b0
movq 0x50(%rsp), %rcx
movq 0x8(%rcx), %rax
cmpq (%rcx), %rax
leaq 0x170(%rsp), %r13
je 0xf388
xorl %r12d, %r12d
movl $0x1, %edx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x42f0
movq 0x58(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
movq %r13, %rdi
callq 0x4470
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42f0
movq 0xf0(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
movq %rbx, %rdi
callq 0x4470
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42f0
movq 0xd8(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
movq %rbx, %rdi
callq 0x4470
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x42f0
movq 0xc0(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
movq %rbx, %rdi
callq 0x4470
movq %rax, %rdi
callq 0x41b0
movq 0x50(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
incq %r12
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rax, %r12
jb 0xf2b8
movq 0x170(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x4290
leaq 0x170(%rsp), %rbx
jmp 0xf451
movl $0x1e, %edx
movq 0x10c36(%rip), %rdi     # 0x1fff0
leaq 0x96f6(%rip), %rsi      # 0x18ab7
callq 0x42f0
movq 0x10c23(%rip), %rdi     # 0x1fff0
movq %rbx, %rsi
callq 0x41a0
movq %rax, %rbx
movl $0x1c, %edx
movq %rax, %rdi
leaq 0x96ef(%rip), %rsi      # 0x18ad6
callq 0x42f0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x41a0
movq %rax, %rbx
movl $0x10, %edx
movq %rax, %rdi
leaq 0x96ea(%rip), %rsi      # 0x18af3
callq 0x42f0
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq %rbx, %rdi
callq 0x42f0
movq %rax, %rbx
movl $0x27, %edx
movq %rax, %rdi
leaq 0x96cc(%rip), %rsi      # 0x18b04
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
addq $0x2, %r15
addq $-0x2, 0x78(%rsp)
jne 0xf023
movq 0x18(%rsp), %rdi
callq 0x4380
movq 0x48(%rsp), %rdi
callq 0x4380
movq 0x10(%rsp), %rdi
callq 0x4060
movq %r14, %rdi
callq 0x4060
leaq 0x170(%rsp), %rdi
callq 0x43d0
movq 0x10b22(%rip), %rax     # 0x1ffd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x178(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x170(%rsp,%rcx)
callq 0x4250
leaq 0x268(%rsp), %rdi
callq 0x40f0
movq 0x10aca(%rip), %rsi     # 0x1ffb0
leaq 0x380(%rsp), %rdi
callq 0x4200
leaq 0x400(%rsp), %rdi
callq 0x40f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xf51c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0xf541
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xf566
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0xf583
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0xf5a0
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0xf5bd
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0xffc5
movq 0x68(%rsp), %rsi
jmp 0xffbd
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x4030
movq %rax, 0x110(%rsp)
movq %rbx, %rdi
callq 0x4030
movq %rax, 0x108(%rsp)
movq 0x8(%rbp), %rsi
subq (%rbp), %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rbx, %rsi
leaq 0xf0(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x169f8
movq 0x8(%rbp), %rsi
subq (%rbp), %rsi
sarq $0x3, %rsi
imulq %rbx, %rsi
leaq 0xd8(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x169f8
movq 0x8(%rbp), %rsi
subq (%rbp), %rsi
sarq $0x3, %rsi
imulq %rbx, %rsi
leaq 0xc0(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x169f8
movq 0x8(%rbp), %rsi
subq (%rbp), %rsi
sarq $0x3, %rsi
imulq %rbx, %rsi
leaq 0x158(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x169f8
leaq 0x90(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0xb0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x38(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x380(%rsp), %rdi
callq 0x41c0
leaq 0x170(%rsp), %rdi
leaq 0x120(%rsp), %rsi
movl $0x10, %edx
callq 0x4540
leaq 0x9486(%rip), %rsi      # 0x18b81
leaq 0x170(%rsp), %rdi
movl $0x18, %edx
callq 0x42f0
leaq 0x170(%rsp), %rdi
callq 0x41b0
movq 0x8(%rbp), %rax
cmpq (%rbp), %rax
je 0xf7f2
movl $0x1, %r12d
movw $0x2, %r15w
leaq 0x170(%rsp), %r13
movl $0x5, %edx
movq %r13, %rdi
leaq 0x9450(%rip), %rsi      # 0x18b9a
callq 0x42f0
movq %r13, %rdi
movq %r12, %rsi
callq 0x41a0
movq %rax, %rbx
movl $0x8, %edx
movq %rax, %rdi
leaq 0x9434(%rip), %rsi      # 0x18ba0
callq 0x42f0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x41a0
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x941b(%rip), %rsi      # 0x18ba9
callq 0x42f0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x41a0
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
leaq 0x93fe(%rip), %rsi      # 0x18bae
callq 0x42f0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x41a0
movq %rax, %rdi
callq 0x41b0
movzwl %r15w, %r12d
movq 0x8(%rbp), %rax
subq (%rbp), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
incl %r15d
cmpq %r12, %rax
jae 0xf73b
movq 0x170(%rsp), %rax
leaq 0x170(%rsp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
leaq 0x170(%rsp), %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41b0
movl $0x8, %edi
callq 0x42c0
movq %rax, 0x48(%rsp)
movq %rax, %rdi
callq 0x174a0
cmpq $0x0, 0x78(%rsp)
sete 0xf(%rsp)
je 0xfe59
xorl %r15d, %r15d
movabsq $0x7fffffffffffffff, %rbx # imm = 0x7FFFFFFFFFFFFFFF
movq 0x78(%rsp), %rax
movq %rax, %xmm0
movq 0x8c31(%rip), %xmm1     # 0x184a0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x8c35(%rip), %xmm2     # 0x184b0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movapd %xmm3, 0x140(%rsp)
decq %rax
movq %rax, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x370(%rsp)
movaps 0x140(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movsd 0x18(%rsp), %xmm0
unpcklps 0x8bcc(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x8bd4(%rip), %xmm0     # 0x184b0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x118(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x118(%rsp), %rdx
callq 0x177c4
movq %rax, %r12
addq %rax, %r15
movq %r15, %rsi
imulq 0x20(%rsp), %rsi
addq $0x3, %rsi
movq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x4360
movq 0x10(%rsp), %rdi
movq 0x110(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x4350
testq %r12, %r12
je 0xf95b
movq %r12, %r13
movq %r14, %rdi
movq %rbx, %rsi
movl $0xa, %edx
callq 0x4190
decq %r13
jne 0xf946
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %edx
movq %r14, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4500
leaq 0x398(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4410
leaq 0x380(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
leaq 0x80(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4160
leaq 0x380(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
notq %r12
movq 0x18(%rsp), %r13
addq %r12, %r13
movq 0x28(%rsp), %rdi
callq 0x4440
movl %eax, %r12d
movaps 0x370(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movq %r13, 0x18(%rsp)
movq %r13, %xmm0
punpckldq 0x8a81(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x8a89(%rip), %xmm0     # 0x184b0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x118(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x118(%rsp), %rdx
callq 0x177c4
movq %rax, %rbp
incq %r15
addq %rax, %r15
movq %r15, %rsi
imulq 0x20(%rsp), %rsi
addq $0x3, %rsi
movq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x4360
movq 0x10(%rsp), %rdi
movq 0x108(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x4350
testq %rbp, %rbp
je 0xfaa9
movq %rbp, %r13
movq %r14, %rdi
movq %rbx, %rsi
movl $0xa, %edx
callq 0x4190
decq %r13
jne 0xfa94
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %edx
movq %r14, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4500
leaq 0x398(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4410
leaq 0x380(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
notq %rbp
addq %rbp, 0x18(%rsp)
incq %r15
movq 0x88(%rsp), %rdx
cmpq 0x30(%rsp), %rdx
jne 0xfb2c
testq %rdx, %rdx
je 0xfb3c
movq 0x28(%rsp), %rsi
movq 0x80(%rsp), %rdi
callq 0x42e0
testl %eax, %eax
je 0xfb3c
testb $0x1, 0xf(%rsp)
je 0xf8b9
jmp 0xfe59
leaq 0x380(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movq 0x50(%rsp), %rbp
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4370
movslq %r12d, %r12
movq 0x28(%rsp), %rdi
callq 0x4440
movslq %eax, %r13
movq %r12, 0x140(%rsp)
cmpl %r12d, %r13d
jbe 0xfd8c
movq 0x110(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq %rbp, %rcx
leaq 0xf0(%rsp), %r8
leaq 0xd8(%rsp), %r9
leaq 0x158(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
callq 0xa608
addq $0x10, %rsp
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
leaq 0x170(%rsp), %rdi
callq 0x42f0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x8f31(%rip), %rsi      # 0x18b2c
callq 0x42f0
movq %r12, %rdi
movq 0x140(%rsp), %rsi
callq 0x41a0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x8f0a(%rip), %rsi      # 0x18b2c
callq 0x42f0
movq %r12, %rdi
movq %r13, %rsi
callq 0x41a0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x8ee8(%rip), %rsi      # 0x18b2c
callq 0x42f0
subq 0x140(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x41a0
movq %rax, %rdi
callq 0x41b0
movq 0x8(%rbp), %rax
cmpq (%rbp), %rax
je 0xfd5e
xorl %r13d, %r13d
movl $0x1, %edx
leaq 0x170(%rsp), %rdi
leaq 0x8ea3(%rip), %rsi      # 0x18b2c
callq 0x42f0
movq 0xf0(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
leaq 0x170(%rsp), %rdi
callq 0x4470
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x8e71(%rip), %rsi      # 0x18b2c
callq 0x42f0
movq 0xd8(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
movq %r12, %rdi
callq 0x4470
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x8e44(%rip), %rsi      # 0x18b2c
callq 0x42f0
movq 0xc0(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
movq %r12, %rdi
callq 0x4470
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x8e17(%rip), %rsi      # 0x18b2c
callq 0x42f0
movq 0x158(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
movq %r12, %rdi
callq 0x4470
movq %rax, %rdi
callq 0x41b0
movq 0x8(%rbp), %rax
subq (%rbp), %rax
incq %r13
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rax, %r13
jb 0xfc75
movq 0x170(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x170(%rsp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x4290
leaq 0x170(%rsp), %r12
jmp 0xfe35
movl $0x1e, %edx
movq 0x10258(%rip), %rdi     # 0x1fff0
leaq 0x8d18(%rip), %rsi      # 0x18ab7
callq 0x42f0
movq 0x10245(%rip), %rdi     # 0x1fff0
movq %r13, %rsi
callq 0x41a0
movq %rax, %r12
movl $0x1c, %edx
movq %rax, %rdi
leaq 0x8d11(%rip), %rsi      # 0x18ad6
callq 0x42f0
movq %r12, %rdi
movq 0x140(%rsp), %rsi
callq 0x41a0
movq %rax, %r12
movl $0x10, %edx
movq %rax, %rdi
leaq 0x8d07(%rip), %rsi      # 0x18af3
callq 0x42f0
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq %r12, %rdi
callq 0x42f0
movq %rax, %r12
movl $0x27, %edx
movq %rax, %rdi
leaq 0x8ce9(%rip), %rsi      # 0x18b04
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
addq $-0x2, 0x78(%rsp)
sete 0xf(%rsp)
jne 0xf85d
movq 0x110(%rsp), %rdi
callq 0x4380
movq 0x108(%rsp), %rdi
callq 0x4380
movq 0x10(%rsp), %rdi
callq 0x4060
movq %r14, %rdi
callq 0x4060
leaq 0x170(%rsp), %rdi
callq 0x43d0
movq 0x10137(%rip), %rax     # 0x1ffd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x178(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x170(%rsp,%rcx)
callq 0x4250
leaq 0x268(%rsp), %rdi
callq 0x40f0
movq 0x100df(%rip), %rsi     # 0x1ffb0
leaq 0x380(%rsp), %rdi
callq 0x4200
leaq 0x400(%rsp), %rdi
callq 0x40f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xff07
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0xff2c
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xff51
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0xff6e
movq 0x168(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0xff8b
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0xffa8
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0xffc5
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0xffea
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x42d0
addq $0x508, %rsp            # imm = 0x508
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xffed(%rip), %rdi      # 0x1fff0
leaq 0x8b24(%rip), %rsi      # 0x18b2e
callq 0x42a0
movq 0x18(%rbp), %rsi
movq %rax, %rdi
callq 0x40b0
leaq 0x8b2f(%rip), %rsi      # 0x18b51
movq %rax, %rdi
callq 0x42a0
movq 0x238(%r12), %rsi
movq %rax, %rdi
callq 0x40b0
leaq 0x8b2d(%rip), %rsi      # 0x18b6e
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4130
movl $0x5, %edi
callq 0x4320
movq 0xff8e(%rip), %rdi      # 0x1fff0
leaq 0x8911(%rip), %rsi      # 0x1897a
movl $0x20, %edx
callq 0x42f0
movq 0x218(%r12), %rsi
movq 0x220(%r12), %rdx
movq 0xff66(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x84d3(%rip), %rsi      # 0x1856c
movl $0xa, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
jmp 0x101bb
movq 0xff36(%rip), %rdi      # 0x1fff0
leaq 0x8795(%rip), %rsi      # 0x18856
movl $0x13, %edx
callq 0x42f0
movq 0x218(%r12), %rsi
movq 0x220(%r12), %rdx
movq 0xff0e(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x8779(%rip), %rsi      # 0x1886a
movl $0x16, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
jmp 0x101bb
movq 0xfede(%rip), %rdi      # 0x1fff0
leaq 0x873d(%rip), %rsi      # 0x18856
movl $0x13, %edx
callq 0x42f0
movq 0x218(%r12), %rsi
movq 0x220(%r12), %rdx
movq 0xfeb6(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x8738(%rip), %rsi      # 0x18881
movl $0x37, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
movl $0x3, %edi
callq 0x4320
movq 0xfe81(%rip), %rdi      # 0x1fff0
leaq 0x8743(%rip), %rsi      # 0x188b9
movl $0x20, %edx
callq 0x42f0
movq 0x170(%rsp), %rsi
movq 0x178(%rsp), %rdx
movq 0xfe59(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rbx
leaq 0x83c6(%rip), %rsi      # 0x1856c
movl $0xa, %edx
movq %rax, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x4130
movl $0x2, %edi
callq 0x4320
movq %rdx, %r14
movq %rax, %rbx
movl $0x8, %esi
movq 0x48(%rsp), %rdi
callq 0x42d0
jmp 0x101e2
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x2, %r14d
jne 0x105f8
movq %rbx, %rdi
callq 0x4340
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x7720
movq %rbx, %rdi
callq 0x4110
movq 0xfdd0(%rip), %rdi      # 0x1fff0
leaq 0x84fe(%rip), %rsi      # 0x18725
movl $0x7, %edx
callq 0x42f0
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0xfdae(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rdi
callq 0x4130
jmp 0x10051
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x1026e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
callq 0x4480
jmp 0x105f8
movq %rax, %rbx
jmp 0x10713
movq %rax, %rbx
jmp 0x10734
movq %rax, %rbx
jmp 0x107b7
movq %rax, %rbx
jmp 0x107d4
movq %rax, %rbx
jmp 0x10605
movq %rax, %rbx
jmp 0x107f1
movq %rax, %rbx
jmp 0x10626
jmp 0x105d8
movq %rax, %rbx
jmp 0x106a9
jmp 0x105d8
movq %rax, %rbx
jmp 0x106c6
jmp 0x105d8
movq %rax, %rbx
jmp 0x106e3
jmp 0x105d8
jmp 0x105d8
jmp 0x105d8
jmp 0x102f5
movq %rdx, %r14
movq %rax, %rbx
jmp 0x10318
jmp 0x105f5
movq %rdx, %r14
movq %rax, %rbx
movq 0x170(%rsp), %rdi
cmpq %r15, %rdi
je 0x10318
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42d0
cmpl $0x1, %r14d
jne 0x1082d
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xfcbc(%rip), %rdi      # 0x1fff0
leaq 0x86a7(%rip), %rsi      # 0x189e2
movl $0x27, %edx
callq 0x42f0
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x170(%rsp), %rdi
callq *0x20(%rax)
movq 0x170(%rsp), %rsi
movq 0x178(%rsp), %rdx
movq 0xfc7f(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rdi
callq 0x41b0
leaq 0x170(%rsp), %rdi
callq 0x4815
movq %rax, %rbx
movq 0x170(%rsp), %rdi
cmpq %r15, %rdi
je 0x103b2
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x103b2
jmp 0x103af
movq %rax, %rbx
callq 0x4480
jmp 0x1082d
jmp 0x105d8
jmp 0x105f5
jmp 0x103d2
jmp 0x10703
jmp 0x105f5
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x1082d
movq %rbx, %rdi
callq 0x4110
movq %rax, %rbx
movq 0xfc00(%rip), %rdi      # 0x1fff0
leaq 0x8442(%rip), %rsi      # 0x18839
movl $0x1c, %edx
callq 0x42f0
movq 0x218(%r12), %rsi
movq 0x220(%r12), %rdx
movq 0xfbd8(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %r14
leaq 0x83ea(%rip), %rsi      # 0x18811
movl $0x2, %edx
movq %rax, %rdi
callq 0x42f0
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
movq (%rsi), %rax
leaq 0x170(%rsp), %rdi
callq *0x20(%rax)
movq 0x170(%rsp), %rsi
movq 0x178(%rsp), %rdx
movq %r14, %rdi
callq 0x42f0
movq %rax, %rdi
callq 0x41b0
leaq 0x170(%rsp), %rdi
callq 0x482f
movq %rax, %rbx
leaq 0x180(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x104a1
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x104a1
jmp 0x1049e
movq %rax, %rbx
callq 0x4480
jmp 0x1082d
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x105f8
movq %rbx, %rdi
callq 0x4340
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x7720
movq %rbx, %rdi
callq 0x4110
movq 0xfb05(%rip), %rdi      # 0x1fff0
leaq 0x8233(%rip), %rsi      # 0x18725
movl $0x7, %edx
callq 0x42f0
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0xfae3(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rdi
callq 0x4130
jmp 0x10051
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x10539
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
callq 0x4480
jmp 0x105f8
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x105f8
movq %rbx, %rdi
callq 0x4340
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x7720
movq %rbx, %rdi
callq 0x4110
movq 0xfa6d(%rip), %rdi      # 0x1fff0
leaq 0x819b(%rip), %rsi      # 0x18725
movl $0x7, %edx
callq 0x42f0
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0xfa4b(%rip), %rdi      # 0x1fff0
callq 0x42f0
movq %rax, %rdi
callq 0x4130
jmp 0x10051
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x105d1
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
callq 0x4480
jmp 0x105f8
movq %rax, %rbx
jmp 0x10808
movq %rax, %rdi
callq 0x7714
jmp 0x105f5
jmp 0x10703
jmp 0x105f5
jmp 0x105f5
jmp 0x105f5
movq %rax, %rbx
leaq 0x170(%rsp), %rdi
callq 0x4400
movq 0xf9a4(%rip), %rsi      # 0x1ffb0
leaq 0x380(%rsp), %rdi
callq 0x4200
leaq 0x400(%rsp), %rdi
callq 0x40f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x10642
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x10667
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x1068c
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0x106a9
movq 0x168(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x106c6
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x106e3
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x10808
movq 0x100(%rsp), %rsi
jmp 0x10800
jmp 0x10703
movq %rax, %rbx
leaq 0x170(%rsp), %rdi
callq 0x4400
movq 0xf896(%rip), %rsi      # 0x1ffb0
leaq 0x380(%rsp), %rdi
callq 0x4200
leaq 0x400(%rsp), %rdi
callq 0x40f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x10750
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x10775
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x1079a
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x107b7
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x107d4
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x107f1
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x10808
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x120(%rsp), %rdi
leaq 0x130(%rsp), %rax
cmpq %rax, %rdi
je 0x1082d
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %rbx, %rdi
callq 0x44e0
nop