// File: tonymugen[P]sampleSNPs/varfiles.cpp
// Function: sampFiles::BedFileI::sampleLD(unsigned long const&)
void BedFileI::sampleLD(const uint64_t &n){
	if (n == 0) {
		cerr << "WARNING: zero SNPs requested. Nothing to be done." << endl;
		return;
	}

    if (_bimFile.is_open()) {
        _bimFile.close();
    }
    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 nSamp = 2UL * n; // n is the number of pairs
	uint64_t N           = _numLines(); // also sets _nCols correctly
    const uint16_t Npad  = _nCols % 4UL;
    const uint64_t Nbed  = (_nCols/4UL) + static_cast<uint64_t>(Npad > 0UL);
	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
		double rSq;
		double Dprime;
		double cnt1;
		double cnt2;
		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\trSq\tDprime\tn1\tn2"  << endl;

        try {
            _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 << " for input: " << error.code().message() << flush;
            perror(" ");
            exit(1);
        }
		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, Nbed, Npad, rSq, Dprime, cnt1, cnt2);
			outFile << chrID << "\t" << pos1 << "\t" << pos2 << "\t" << pos2 - pos1 << "\t" << rSq << "\t" << Dprime << "\t" << cnt1 << "\t" << cnt2 << endl;
		}

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

	}
	try {
		_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);
	}
	// 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;
	double rSq;
	double Dprime;
	double cnt1;
	double cnt2;
	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\trSq\tDprime\tn1\tn2"  << 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, Nbed, Npad, rSq, Dprime, cnt1, cnt2);
		outFile << chrID << "\t" << pos1 << "\t" << pos2 << "\t" << pos2 - pos1 << "\t" << rSq << "\t" << Dprime << "\t" << cnt1 << "\t" << cnt2 << endl;
		nSamp--;
	}

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe60, %rsp            # imm = 0xE60
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa48(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x121df
movq 0x19e31(%rip), %rdi     # 0x2bff0
leaq 0x113e6(%rip), %rsi     # 0x235ac
callq 0x4310
movq %rax, %rdi
movq 0x19ddb(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x14043
movq -0xa48(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
callq 0x45e0
testb $0x1, %al
jne 0x121f8
jmp 0x1220b
movq -0xa48(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
callq 0x4060
movq -0xa48(%rbp), %rsi
addq $0x668, %rsi            # imm = 0x668
leaq 0x115fc(%rip), %rdx     # 0x2381c
leaq -0x30(%rbp), %rdi
callq 0x7920
jmp 0x1222b
movq -0xa48(%rbp), %rax
addq $0x458, %rax            # imm = 0x458
movq %rax, -0xa50(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4140
movq -0xa50(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x42f0
jmp 0x1225e
movq -0xa48(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
callq 0x45e0
movb %al, -0xa51(%rbp)
jmp 0x12279
movb -0xa51(%rbp), %al
testb $0x1, %al
jne 0x123bb
jmp 0x12289
movq 0x19d60(%rip), %rdi     # 0x2bff0
leaq 0x1160a(%rip), %rsi     # 0x238a1
callq 0x4310
movq %rax, -0xa60(%rbp)
jmp 0x122a5
movq -0xa60(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x42e0
movq %rax, -0xa68(%rbp)
jmp 0x122be
movq -0xa68(%rbp), %rdi
leaq 0x11288(%rip), %rsi     # 0x23554
callq 0x4310
movq %rax, -0xa70(%rbp)
jmp 0x122da
movq -0xa70(%rbp), %rdi
movq 0x19cc8(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x122ef
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1231c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x46d8
movl -0x3c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x14094
movq -0x38(%rbp), %rdi
callq 0x4130
movq %rax, -0x48(%rbp)
movq 0x19cb0(%rip), %rdi     # 0x2bff0
leaq 0x11683(%rip), %rsi     # 0x239ca
callq 0x4310
movq %rax, -0xa78(%rbp)
jmp 0x12355
movq -0x48(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x1eeb0
jmp 0x1236c
movq -0xa78(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x42e0
movq %rax, -0xa80(%rbp)
jmp 0x12385
movq -0xa80(%rbp), %rdi
movq 0x19c35(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x1239a
leaq -0x68(%rbp), %rdi
callq 0x46d8
leaq 0x11450(%rip), %rdi     # 0x237fa
callq 0x42a0
jmp 0x123b1
movl $0x1, %edi
callq 0x4400
leaq -0x30(%rbp), %rdi
callq 0x46d8
jmp 0x123f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x123e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x123f0
jmp 0x14094
movq -0xa48(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
shlq %rax
movq %rax, -0x70(%rbp)
callq 0xb9e0
movq -0xa48(%rbp), %rsi
movq %rax, -0x78(%rbp)
movq 0x238(%rsi), %rax
andq $0x3, %rax
movw %ax, -0x7a(%rbp)
movq 0x238(%rsi), %rax
shrq $0x2, %rax
movzwl -0x7a(%rbp), %ecx
cmpq $0x0, %rcx
seta %cl
andb $0x1, %cl
movzbl %cl, %ecx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
addq $0x668, %rsi            # imm = 0x668
leaq -0xa8(%rbp), %rdi
leaq 0x1158e(%rip), %rdx     # 0x239f2
callq 0x7920
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jbe 0x12532
movq 0x19b72(%rip), %rdi     # 0x2bff0
leaq 0x11159(%rip), %rsi     # 0x235de
callq 0x4310
movq %rax, -0xa88(%rbp)
jmp 0x12493
movq -0xa88(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x40d0
movq %rax, -0xa90(%rbp)
jmp 0x124ac
movq -0xa90(%rbp), %rdi
leaq 0x11426(%rip), %rsi     # 0x238e0
callq 0x4310
movq %rax, -0xa98(%rbp)
jmp 0x124c8
movq -0xa98(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x40d0
movq %rax, -0xaa0(%rbp)
jmp 0x124e1
movq -0xaa0(%rbp), %rdi
leaq 0x1113d(%rip), %rsi     # 0x2362c
callq 0x4310
movq %rax, -0xaa8(%rbp)
jmp 0x124fd
movq -0xaa8(%rbp), %rdi
movq 0x19aa5(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x12512
movl $0x1, -0xac(%rbp)
jmp 0x14037
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x14088
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jne 0x13095
movq 0x19aa9(%rip), %rdi     # 0x2bff0
leaq 0x114ac(%rip), %rsi     # 0x239fa
callq 0x4310
movq %rax, -0xab0(%rbp)
jmp 0x1255c
movq -0xab0(%rbp), %rdi
movq 0x19a46(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x12571
movq -0x88(%rbp), %rdi
callq 0x4030
movq %rax, -0xab8(%rbp)
jmp 0x12586
movq -0xab8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x88(%rbp), %rdi
callq 0x4030
movq %rax, -0xac0(%rbp)
jmp 0x125a9
movq -0xac0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x44d0
leaq -0x138(%rbp), %rdi
callq 0x44d0
leaq -0x158(%rbp), %rdi
callq 0x44d0
leaq -0x2e0(%rbp), %rdi
callq 0x4220
jmp 0x125f4
leaq -0x4e0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movl $0x10, %edx
callq 0x4680
jmp 0x1260e
leaq 0x11460(%rip), %rsi     # 0x23a75
leaq -0x4e0(%rbp), %rdi
callq 0x4310
movq %rax, -0xac8(%rbp)
jmp 0x1262a
movq -0xac8(%rbp), %rdi
movq 0x19978(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1263f
movq -0xa48(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0xae0(%rbp)
addq $0x218, %rdi            # imm = 0x218
callq 0x4140
movq %rax, -0xad8(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x1ee70
movl %eax, -0xacc(%rbp)
jmp 0x1267e
movl -0xacc(%rbp), %edx
movq -0xad8(%rbp), %rsi
movq -0xae0(%rbp), %rdi
callq 0x42f0
jmp 0x12699
movq -0xa48(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
movb %al, -0xae1(%rbp)
jmp 0x126b1
movb -0xae1(%rbp), %al
testb $0x1, %al
jne 0x12867
jmp 0x126c1
movq 0x19928(%rip), %rdi     # 0x2bff0
leaq 0x11293(%rip), %rsi     # 0x23962
callq 0x4310
movq %rax, -0xaf0(%rbp)
jmp 0x126dd
movq -0xaf0(%rbp), %rdi
movq -0xa48(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0xaf8(%rbp)
jmp 0x12700
movq -0xaf8(%rbp), %rdi
leaq 0x10e46(%rip), %rsi     # 0x23554
callq 0x4310
movq %rax, -0xb00(%rbp)
jmp 0x1271c
movq -0xb00(%rbp), %rdi
movq 0x19886(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x12731
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1306c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x13060
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x13054
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x13054
movq -0x38(%rbp), %rdi
callq 0x4130
movq %rax, -0x4f0(%rbp)
movq 0x1984f(%rip), %rdi     # 0x2bff0
leaq 0x111db(%rip), %rsi     # 0x23983
callq 0x4310
movq %rax, -0xb08(%rbp)
jmp 0x127b6
movq -0xb08(%rbp), %rdi
movq -0xa48(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0xb10(%rbp)
jmp 0x127d9
movq -0xb10(%rbp), %rdi
leaq 0x111fe(%rip), %rsi     # 0x239e5
callq 0x4310
movq %rax, -0xb18(%rbp)
jmp 0x127f5
movq -0x4f0(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x510(%rbp), %rdi
callq 0x1eeb0
jmp 0x12812
movq -0xb18(%rbp), %rdi
leaq -0x510(%rbp), %rsi
callq 0x42e0
movq %rax, -0xb20(%rbp)
jmp 0x1282e
movq -0xb20(%rbp), %rdi
movq 0x1978c(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x12843
leaq -0x510(%rbp), %rdi
callq 0x46d8
leaq 0x10fa4(%rip), %rdi     # 0x237fa
callq 0x42a0
jmp 0x1285d
movl $0x1, %edi
callq 0x4400
movq -0xa48(%rbp), %rdi
addq $0x8, %rdi
leaq -0x4e3(%rbp), %rsi
movl $0x3, %edx
callq 0x4450
jmp 0x12885
movsbl -0x4e3(%rbp), %eax
cmpl $0x6c, %eax
jne 0x1289d
movsbl -0x4e2(%rbp), %eax
cmpl $0x1b, %eax
je 0x12917
movq 0x1974c(%rip), %rdi     # 0x2bff0
leaq 0x10f93(%rip), %rsi     # 0x2383e
callq 0x4310
movq %rax, -0xb28(%rbp)
jmp 0x128b9
movq -0xb28(%rbp), %rdi
movq -0xa48(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0xb30(%rbp)
jmp 0x128dc
movq -0xb30(%rbp), %rdi
leaq 0x10f68(%rip), %rsi     # 0x23852
callq 0x4310
movq %rax, -0xb38(%rbp)
jmp 0x128f8
movq -0xb38(%rbp), %rdi
movq 0x196aa(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x1290d
movl $0x2, %edi
callq 0x4400
movsbl -0x4e1(%rbp), %eax
cmpl $0x1, %eax
je 0x1299d
movq 0x196c6(%rip), %rdi     # 0x2bff0
leaq 0x10f0d(%rip), %rsi     # 0x2383e
callq 0x4310
movq %rax, -0xb40(%rbp)
jmp 0x1293f
movq -0xb40(%rbp), %rdi
movq -0xa48(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0xb48(%rbp)
jmp 0x12962
movq -0xb48(%rbp), %rdi
leaq 0x10ef9(%rip), %rsi     # 0x23869
callq 0x4310
movq %rax, -0xb50(%rbp)
jmp 0x1297e
movq -0xb50(%rbp), %rdi
movq 0x19624(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x12993
movl $0x3, %edi
callq 0x4400
jmp 0x1299f
jmp 0x129d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x129c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x510(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x129ce
jmp 0x13054
jmp 0x129d5
cmpq $0x0, -0x70(%rbp)
je 0x12fa1
movq -0xa48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xb58(%rbp)
movq -0xc8(%rbp), %rsi
movq -0x88(%rbp), %rax
imulq %rax, %rsi
addq $0x3, %rsi
leaq -0x520(%rbp), %rdi
callq 0x1ef20
jmp 0x12a16
movq -0xb58(%rbp), %rdi
movq -0x520(%rbp), %rsi
movq -0x518(%rbp), %rdx
callq 0x4460
jmp 0x12a32
movq -0xa48(%rbp), %rdi
addq $0x8, %rdi
movq -0xb8(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x4450
jmp 0x12a52
movq -0xa48(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
leaq -0x138(%rbp), %rsi
callq 0x4080
jmp 0x12a6e
movq -0xc8(%rbp), %rax
incq %rax
movq %rax, -0xc8(%rbp)
movq -0x70(%rbp), %rax
decq %rax
movq %rax, -0x70(%rbp)
leaq -0x2e0(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x43d0
jmp 0x12a9f
leaq -0x2e0(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x4470
jmp 0x12ab4
leaq -0x108(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x4040
jmp 0x12ac9
leaq -0x2e0(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x4470
movq %rax, -0xb60(%rbp)
jmp 0x12ae5
movq -0xb60(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x4470
movq %rax, -0xb68(%rbp)
jmp 0x12b01
movq -0xb68(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x4470
jmp 0x12b16
leaq -0x158(%rbp), %rdi
callq 0x4140
movq %rax, %rdi
callq 0x4540
movl %eax, %ecx
movq -0xa48(%rbp), %rax
movslq %ecx, %rcx
movq %rcx, -0x110(%rbp)
addq $0x8, %rax
movq %rax, -0xb70(%rbp)
movq -0xc8(%rbp), %rsi
movq -0x88(%rbp), %rax
imulq %rax, %rsi
addq $0x3, %rsi
leaq -0x530(%rbp), %rdi
callq 0x1ef20
jmp 0x12b6c
movq -0xb70(%rbp), %rdi
movq -0x530(%rbp), %rsi
movq -0x528(%rbp), %rdx
callq 0x4460
jmp 0x12b88
movq -0xa48(%rbp), %rdi
addq $0x8, %rdi
movq -0xc0(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x4450
jmp 0x12ba8
movq -0xa48(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
leaq -0x138(%rbp), %rsi
callq 0x4080
jmp 0x12bc4
movq -0xc8(%rbp), %rax
incq %rax
movq %rax, -0xc8(%rbp)
movq -0x70(%rbp), %rax
decq %rax
movq %rax, -0x70(%rbp)
leaq -0x2e0(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x43d0
jmp 0x12bf5
leaq -0x2e0(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x4470
jmp 0x12c0a
leaq -0x108(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x1f3a0
testb $0x1, %al
jne 0x12c23
jmp 0x12c28
jmp 0x129d5
leaq -0x2e0(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x4470
movq %rax, -0xb78(%rbp)
jmp 0x12c44
movq -0xb78(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x4470
movq %rax, -0xb80(%rbp)
jmp 0x12c60
movq -0xb80(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x4470
jmp 0x12c75
leaq -0x158(%rbp), %rdi
callq 0x4140
movq %rax, %rdi
callq 0x4540
cltq
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
cmpq -0x110(%rbp), %rax
ja 0x12d84
movq 0x19343(%rip), %rdi     # 0x2bff0
leaq 0x10deb(%rip), %rsi     # 0x23a9f
callq 0x4310
movq %rax, -0xb88(%rbp)
jmp 0x12cc2
movq -0xb88(%rbp), %rdi
movq -0x118(%rbp), %rsi
callq 0x40d0
movq %rax, -0xb90(%rbp)
jmp 0x12cde
movq -0xb90(%rbp), %rdi
leaq 0x10dd2(%rip), %rsi     # 0x23abe
callq 0x4310
movq %rax, -0xb98(%rbp)
jmp 0x12cfa
movq -0xb98(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0x40d0
movq %rax, -0xba0(%rbp)
jmp 0x12d16
movq -0xba0(%rbp), %rdi
leaq 0x10db7(%rip), %rsi     # 0x23adb
callq 0x4310
movq %rax, -0xba8(%rbp)
jmp 0x12d32
movq -0xba8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x42e0
movq %rax, -0xbb0(%rbp)
jmp 0x12d4e
movq -0xbb0(%rbp), %rdi
leaq 0x10d90(%rip), %rsi     # 0x23aec
callq 0x4310
movq %rax, -0xbb8(%rbp)
jmp 0x12d6a
movq -0xbb8(%rbp), %rdi
movq 0x19238(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x12d7f
jmp 0x129d5
movq -0xa48(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq %rsp, %rax
leaq -0xe8(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq -0xe0(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq -0xd8(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x88(%rbp), %rcx
leaq -0x7a(%rbp), %r8
leaq -0xd0(%rbp), %r9
callq 0xc770
jmp 0x12dd5
leaq -0x4e0(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x42e0
movq %rax, -0xbc0(%rbp)
jmp 0x12df1
movq -0xbc0(%rbp), %rdi
leaq 0x10d15(%rip), %rsi     # 0x23b14
callq 0x4310
movq %rax, -0xbc8(%rbp)
jmp 0x12e0d
movq -0xbc8(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0x40d0
movq %rax, -0xbd0(%rbp)
jmp 0x12e29
movq -0xbd0(%rbp), %rdi
leaq 0x10cdd(%rip), %rsi     # 0x23b14
callq 0x4310
movq %rax, -0xbd8(%rbp)
jmp 0x12e45
movq -0xbd8(%rbp), %rdi
movq -0x118(%rbp), %rsi
callq 0x40d0
movq %rax, -0xbe0(%rbp)
jmp 0x12e61
movq -0xbe0(%rbp), %rdi
leaq 0x10ca5(%rip), %rsi     # 0x23b14
callq 0x4310
movq %rax, -0xbe8(%rbp)
jmp 0x12e7d
movq -0xbe8(%rbp), %rdi
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rax
subq %rax, %rsi
callq 0x40d0
movq %rax, -0xbf0(%rbp)
jmp 0x12ea3
movq -0xbf0(%rbp), %rdi
leaq 0x10c63(%rip), %rsi     # 0x23b14
callq 0x4310
movq %rax, -0xbf8(%rbp)
jmp 0x12ebf
movq -0xbf8(%rbp), %rdi
movsd -0xd0(%rbp), %xmm0
callq 0x4660
movq %rax, -0xc00(%rbp)
jmp 0x12edc
movq -0xc00(%rbp), %rdi
leaq 0x10c2a(%rip), %rsi     # 0x23b14
callq 0x4310
movq %rax, -0xc08(%rbp)
jmp 0x12ef8
movq -0xc08(%rbp), %rdi
movsd -0xd8(%rbp), %xmm0
callq 0x4660
movq %rax, -0xc10(%rbp)
jmp 0x12f15
movq -0xc10(%rbp), %rdi
leaq 0x10bf1(%rip), %rsi     # 0x23b14
callq 0x4310
movq %rax, -0xc18(%rbp)
jmp 0x12f31
movq -0xc18(%rbp), %rdi
movsd -0xe0(%rbp), %xmm0
callq 0x4660
movq %rax, -0xc20(%rbp)
jmp 0x12f4e
movq -0xc20(%rbp), %rdi
leaq 0x10bb8(%rip), %rsi     # 0x23b14
callq 0x4310
movq %rax, -0xc28(%rbp)
jmp 0x12f6a
movq -0xc28(%rbp), %rdi
movsd -0xe8(%rbp), %xmm0
callq 0x4660
movq %rax, -0xc30(%rbp)
jmp 0x12f87
movq -0xc30(%rbp), %rdi
movq 0x1901b(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x12f9c
jmp 0x129d5
movq -0xb8(%rbp), %rax
movq %rax, -0xc38(%rbp)
cmpq $0x0, %rax
je 0x12fc1
movq -0xc38(%rbp), %rdi
callq 0x4480
movq -0xc0(%rbp), %rax
movq %rax, -0xc40(%rbp)
cmpq $0x0, %rax
je 0x12fe1
movq -0xc40(%rbp), %rdi
callq 0x4480
movq -0xa48(%rbp), %rdi
addq $0x8, %rdi
callq 0x4060
jmp 0x12ff3
movq -0xa48(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
callq 0x4060
jmp 0x13008
leaq -0x4e0(%rbp), %rdi
callq 0x44e0
jmp 0x13016
leaq -0x4e0(%rbp), %rdi
callq 0x4520
leaq -0x2e0(%rbp), %rdi
callq 0x4260
leaq -0x158(%rbp), %rdi
callq 0x46d8
leaq -0x138(%rbp), %rdi
callq 0x46d8
leaq -0x108(%rbp), %rdi
callq 0x46d8
jmp 0x13095
leaq -0x4e0(%rbp), %rdi
callq 0x4520
leaq -0x2e0(%rbp), %rdi
callq 0x4260
leaq -0x158(%rbp), %rdi
callq 0x46d8
leaq -0x138(%rbp), %rdi
callq 0x46d8
leaq -0x108(%rbp), %rdi
callq 0x46d8
jmp 0x14088
jmp 0x13097
movq -0xa48(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0xc58(%rbp)
addq $0x218, %rdi            # imm = 0x218
callq 0x4140
movq %rax, -0xc50(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x1ee70
movl %eax, -0xc44(%rbp)
jmp 0x130d6
movl -0xc44(%rbp), %edx
movq -0xc50(%rbp), %rsi
movq -0xc58(%rbp), %rdi
callq 0x42f0
jmp 0x130f1
movq -0xa48(%rbp), %rdi
addq $0x8, %rdi
callq 0x45e0
movb %al, -0xc59(%rbp)
jmp 0x13109
movb -0xc59(%rbp), %al
testb $0x1, %al
jne 0x1328c
jmp 0x13119
movq 0x18ed0(%rip), %rdi     # 0x2bff0
leaq 0x1083b(%rip), %rsi     # 0x23962
callq 0x4310
movq %rax, -0xc68(%rbp)
jmp 0x13135
movq -0xc68(%rbp), %rdi
movq -0xa48(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0xc70(%rbp)
jmp 0x13158
movq -0xc70(%rbp), %rdi
leaq 0x103ee(%rip), %rsi     # 0x23554
callq 0x4310
movq %rax, -0xc78(%rbp)
jmp 0x13174
movq -0xc78(%rbp), %rdi
movq 0x18e2e(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x13189
movl $0x2, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x14088
movq -0x38(%rbp), %rdi
callq 0x4130
movq %rax, -0x540(%rbp)
movq 0x18e2a(%rip), %rdi     # 0x2bff0
leaq 0x10654(%rip), %rsi     # 0x23821
callq 0x4310
movq %rax, -0xc80(%rbp)
jmp 0x131db
movq -0xc80(%rbp), %rdi
movq -0xa48(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0xc88(%rbp)
jmp 0x131fe
movq -0xc88(%rbp), %rdi
leaq 0x105ed(%rip), %rsi     # 0x237f9
callq 0x4310
movq %rax, -0xc90(%rbp)
jmp 0x1321a
movq -0x540(%rbp), %rdi
callq 0x1ee90
movq %rax, %rsi
leaq -0x560(%rbp), %rdi
callq 0x1eeb0
jmp 0x13237
movq -0xc90(%rbp), %rdi
leaq -0x560(%rbp), %rsi
callq 0x42e0
movq %rax, -0xc98(%rbp)
jmp 0x13253
movq -0xc98(%rbp), %rdi
movq 0x18d67(%rip), %rsi     # 0x2bfc8
callq 0x4350
jmp 0x13268
leaq -0x560(%rbp), %rdi
callq 0x46d8
leaq 0x1057f(%rip), %rdi     # 0x237fa
callq 0x42a0
jmp 0x13282
movl $0x1, %edi
callq 0x4400
movq -0xa48(%rbp), %rdi
addq $0x8, %rdi
leaq -0x533(%rbp), %rsi
movl $0x3, %edx
callq 0x4450
jmp 0x132aa
movsbl -0x533(%rbp), %eax
cmpl $0x6c, %eax
jne 0x132c2
movsbl -0x532(%rbp), %eax
cmpl $0x1b, %eax
je 0x1333c
movq 0x18d27(%rip), %rdi     # 0x2bff0
leaq 0x1056e(%rip), %rsi     # 0x2383e
callq 0x4310
movq %rax, -0xca0(%rbp)
jmp 0x132de
movq -0xca0(%rbp), %rdi
movq -0xa48(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0xca8(%rbp)
jmp 0x13301
movq -0xca8(%rbp), %rdi
leaq 0x10543(%rip), %rsi     # 0x23852
callq 0x4310
movq %rax, -0xcb0(%rbp)
jmp 0x1331d
movq -0xcb0(%rbp), %rdi
movq 0x18c85(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x13332
movl $0x2, %edi
callq 0x4400
movsbl -0x531(%rbp), %eax
cmpl $0x1, %eax
je 0x133c2
movq 0x18ca1(%rip), %rdi     # 0x2bff0
leaq 0x104e8(%rip), %rsi     # 0x2383e
callq 0x4310
movq %rax, -0xcb8(%rbp)
jmp 0x13364
movq -0xcb8(%rbp), %rdi
movq -0xa48(%rbp), %rsi
addq $0x218, %rsi            # imm = 0x218
callq 0x42e0
movq %rax, -0xcc0(%rbp)
jmp 0x13387
movq -0xcc0(%rbp), %rdi
leaq 0x104d4(%rip), %rsi     # 0x23869
callq 0x4310
movq %rax, -0xcc8(%rbp)
jmp 0x133a3
movq -0xcc8(%rbp), %rdi
movq 0x18bff(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x133b8
movl $0x3, %edi
callq 0x4400
jmp 0x133c4
jmp 0x133f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x133ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x560(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x133f3
jmp 0x14088
movq -0x88(%rbp), %rdi
callq 0x4030
movq %rax, -0xcd0(%rbp)
jmp 0x1340d
movq -0xcd0(%rbp), %rax
movq %rax, -0x568(%rbp)
movq -0x88(%rbp), %rdi
callq 0x4030
movq %rax, -0xcd8(%rbp)
jmp 0x13430
movq -0xcd8(%rbp), %rax
movq %rax, -0x570(%rbp)
movq $0x0, -0x578(%rbp)
leaq -0x5c0(%rbp), %rdi
callq 0x44d0
leaq -0x5f0(%rbp), %rdi
callq 0x44d0
leaq -0x610(%rbp), %rdi
callq 0x44d0
leaq -0x798(%rbp), %rdi
callq 0x4220
jmp 0x1347b
leaq -0x998(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movl $0x10, %edx
callq 0x4680
jmp 0x13495
leaq 0x105d9(%rip), %rsi     # 0x23a75
leaq -0x998(%rbp), %rdi
callq 0x4310
movq %rax, -0xce0(%rbp)
jmp 0x134b1
movq -0xce0(%rbp), %rdi
movq 0x18af1(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x134c6
movl $0x8, %edi
callq 0x4330
movq %rax, -0xce8(%rbp)
jmp 0x134d9
movq -0xce8(%rbp), %rdi
callq 0x22380
jmp 0x134e7
movq -0xce8(%rbp), %rax
movq %rax, -0x9a0(%rbp)
jmp 0x13610
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x14064
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x14058
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1404c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x13558
movq -0xce8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x8, %esi
callq 0x4340
movl -0x3c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x1404c
movq -0x38(%rbp), %rdi
movq %rdi, -0xcf0(%rbp)
callq 0x4430
movq %rax, %rsi
leaq -0x9c0(%rbp), %rdi
callq 0x4150
jmp 0x13589
movq -0xcf0(%rbp), %rdi
callq 0x4130
movq 0x18a54(%rip), %rdi     # 0x2bff0
leaq 0x1016a(%rip), %rsi     # 0x2370d
callq 0x4310
movq %rax, -0xcf8(%rbp)
jmp 0x135b1
movq -0xcf8(%rbp), %rdi
leaq -0x9c0(%rbp), %rsi
callq 0x42e0
movq %rax, -0xd00(%rbp)
jmp 0x135cd
movq -0xd00(%rbp), %rdi
movq 0x189d5(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x135e2
movl $0x5, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x9c0(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x1360b
jmp 0x1404c
jmp 0x13612
cmpq $0x0, -0x70(%rbp)
je 0x13f7c
movq -0x9a0(%rbp), %rdi
movq -0x70(%rbp), %xmm0
movaps 0xfe70(%rip), %xmm2     # 0x234a0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0xfe74(%rip), %xmm1     # 0x234b0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm3
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm3, %xmm0
movsd %xmm0, -0x9c8(%rbp)
movq -0x78(%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, -0x9d0(%rbp)
leaq -0x9c8(%rbp), %rsi
leaq -0x9d0(%rbp), %rdx
callq 0x227a0
movq %rax, -0xd08(%rbp)
jmp 0x1368f
movq -0xd08(%rbp), %rax
movq %rax, -0x580(%rbp)
jmp 0x13766
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x1404c
movq -0x38(%rbp), %rdi
movq %rdi, -0xd10(%rbp)
callq 0x4430
movq %rax, %rsi
leaq -0x9f0(%rbp), %rdi
callq 0x4150
jmp 0x136df
movq -0xd10(%rbp), %rdi
callq 0x4130
movq 0x188fe(%rip), %rdi     # 0x2bff0
leaq 0x10014(%rip), %rsi     # 0x2370d
callq 0x4310
movq %rax, -0xd18(%rbp)
jmp 0x13707
movq -0xd18(%rbp), %rdi
leaq -0x9f0(%rbp), %rsi
callq 0x42e0
movq %rax, -0xd20(%rbp)
jmp 0x13723
movq -0xd20(%rbp), %rdi
movq 0x1887f(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x13738
movl $0x5, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x9f0(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x13761
jmp 0x1404c
movq -0xa48(%rbp), %rax
movq -0x580(%rbp), %rdx
movq -0x578(%rbp), %rcx
addq %rdx, %rcx
movq %rcx, -0x578(%rbp)
movq -0x580(%rbp), %rcx
movq -0x78(%rbp), %rdx
notq %rcx
addq %rdx, %rcx
movq %rcx, -0x78(%rbp)
addq $0x8, %rax
movq %rax, -0xd28(%rbp)
movq -0x578(%rbp), %rsi
movq -0x88(%rbp), %rax
imulq %rax, %rsi
addq $0x3, %rsi
leaq -0xa00(%rbp), %rdi
callq 0x1ef20
jmp 0x137c9
movq -0xd28(%rbp), %rdi
movq -0xa00(%rbp), %rsi
movq -0x9f8(%rbp), %rdx
callq 0x4460
jmp 0x137e5
movq -0xa48(%rbp), %rdi
addq $0x8, %rdi
movq -0x568(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x4450
jmp 0x13805
movq -0x578(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x578(%rbp)
cmpq $0x0, -0x580(%rbp)
je 0x13864
movq -0xa48(%rbp), %rax
addq $0x458, %rax            # imm = 0x458
movq %rax, -0xd30(%rbp)
callq 0x1f390
movq -0xd30(%rbp), %rdi
movq %rax, %rsi
movl $0xa, %edx
callq 0x41f0
jmp 0x13850
movq -0x580(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x580(%rbp)
jmp 0x13817
movq -0xa48(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
leaq -0x5f0(%rbp), %rsi
callq 0x4080
jmp 0x13880
leaq -0x798(%rbp), %rdi
leaq -0x5f0(%rbp), %rsi
callq 0x43d0
jmp 0x13895
leaq -0x798(%rbp), %rdi
leaq -0x610(%rbp), %rsi
callq 0x4470
jmp 0x138aa
leaq -0x5c0(%rbp), %rdi
leaq -0x610(%rbp), %rsi
callq 0x4040
jmp 0x138bf
leaq -0x798(%rbp), %rdi
leaq -0x610(%rbp), %rsi
callq 0x4470
movq %rax, -0xd38(%rbp)
jmp 0x138db
movq -0xd38(%rbp), %rdi
leaq -0x610(%rbp), %rsi
callq 0x4470
movq %rax, -0xd40(%rbp)
jmp 0x138f7
movq -0xd40(%rbp), %rdi
leaq -0x610(%rbp), %rsi
callq 0x4470
jmp 0x1390c
leaq -0x610(%rbp), %rdi
callq 0x4140
movq %rax, %rdi
callq 0x4540
cltq
movq %rax, -0x5c8(%rbp)
movq -0x70(%rbp), %rax
decq %rax
movq %rax, -0x70(%rbp)
movq -0x9a0(%rbp), %rdi
movq -0x70(%rbp), %xmm0
movaps 0xfb59(%rip), %xmm2     # 0x234a0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0xfb5d(%rip), %xmm1     # 0x234b0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm3
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm3, %xmm0
movsd %xmm0, -0xa08(%rbp)
movq -0x78(%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, -0xa10(%rbp)
leaq -0xa08(%rbp), %rsi
leaq -0xa10(%rbp), %rdx
callq 0x227a0
movq %rax, -0xd48(%rbp)
jmp 0x139a6
movq -0xd48(%rbp), %rax
movq %rax, -0x580(%rbp)
jmp 0x13a7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x1404c
movq -0x38(%rbp), %rdi
movq %rdi, -0xd50(%rbp)
callq 0x4430
movq %rax, %rsi
leaq -0xa30(%rbp), %rdi
callq 0x4150
jmp 0x139f6
movq -0xd50(%rbp), %rdi
callq 0x4130
movq 0x185e7(%rip), %rdi     # 0x2bff0
leaq 0xfcfd(%rip), %rsi      # 0x2370d
callq 0x4310
movq %rax, -0xd58(%rbp)
jmp 0x13a1e
movq -0xd58(%rbp), %rdi
leaq -0xa30(%rbp), %rsi
callq 0x42e0
movq %rax, -0xd60(%rbp)
jmp 0x13a3a
movq -0xd60(%rbp), %rdi
movq 0x18568(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x13a4f
movl $0x5, %edi
callq 0x4400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa30(%rbp), %rdi
callq 0x46d8
callq 0x4580
jmp 0x13a78
jmp 0x1404c
movq -0xa48(%rbp), %rax
movq -0x580(%rbp), %rdx
movq -0x578(%rbp), %rcx
addq %rdx, %rcx
movq %rcx, -0x578(%rbp)
movq -0x580(%rbp), %rcx
movq -0x78(%rbp), %rdx
notq %rcx
addq %rdx, %rcx
movq %rcx, -0x78(%rbp)
addq $0x8, %rax
movq %rax, -0xd68(%rbp)
movq -0x578(%rbp), %rsi
movq -0x88(%rbp), %rax
imulq %rax, %rsi
addq $0x3, %rsi
leaq -0xa40(%rbp), %rdi
callq 0x1ef20
jmp 0x13ae0
movq -0xd68(%rbp), %rdi
movq -0xa40(%rbp), %rsi
movq -0xa38(%rbp), %rdx
callq 0x4460
jmp 0x13afc
movq -0xa48(%rbp), %rdi
addq $0x8, %rdi
movq -0x570(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x4450
jmp 0x13b1c
movq -0x578(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x578(%rbp)
cmpq $0x0, -0x580(%rbp)
je 0x13b7b
movq -0xa48(%rbp), %rax
addq $0x458, %rax            # imm = 0x458
movq %rax, -0xd70(%rbp)
callq 0x1f390
movq -0xd70(%rbp), %rdi
movq %rax, %rsi
movl $0xa, %edx
callq 0x41f0
jmp 0x13b67
movq -0x580(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x580(%rbp)
jmp 0x13b2e
movq -0xa48(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
leaq -0x5f0(%rbp), %rsi
callq 0x4080
jmp 0x13b97
leaq -0x798(%rbp), %rdi
leaq -0x5f0(%rbp), %rsi
callq 0x43d0
jmp 0x13bac
leaq -0x798(%rbp), %rdi
leaq -0x610(%rbp), %rsi
callq 0x4470
jmp 0x13bc1
leaq -0x5c0(%rbp), %rdi
leaq -0x610(%rbp), %rsi
callq 0x1f3a0
testb $0x1, %al
jne 0x13bda
jmp 0x13beb
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x13612
leaq -0x798(%rbp), %rdi
leaq -0x610(%rbp), %rsi
callq 0x4470
movq %rax, -0xd78(%rbp)
jmp 0x13c07
movq -0xd78(%rbp), %rdi
leaq -0x610(%rbp), %rsi
callq 0x4470
movq %rax, -0xd80(%rbp)
jmp 0x13c23
movq -0xd80(%rbp), %rdi
leaq -0x610(%rbp), %rsi
callq 0x4470
jmp 0x13c38
leaq -0x610(%rbp), %rdi
callq 0x4140
movq %rax, %rdi
callq 0x4540
cltq
movq %rax, -0x5d0(%rbp)
movq -0x5d0(%rbp), %rax
cmpq -0x5c8(%rbp), %rax
ja 0x13d53
movq 0x18380(%rip), %rdi     # 0x2bff0
leaq 0xfe28(%rip), %rsi      # 0x23a9f
callq 0x4310
movq %rax, -0xd88(%rbp)
jmp 0x13c85
movq -0xd88(%rbp), %rdi
movq -0x5d0(%rbp), %rsi
callq 0x40d0
movq %rax, -0xd90(%rbp)
jmp 0x13ca1
movq -0xd90(%rbp), %rdi
leaq 0xfe0f(%rip), %rsi      # 0x23abe
callq 0x4310
movq %rax, -0xd98(%rbp)
jmp 0x13cbd
movq -0xd98(%rbp), %rdi
movq -0x5c8(%rbp), %rsi
callq 0x40d0
movq %rax, -0xda0(%rbp)
jmp 0x13cd9
movq -0xda0(%rbp), %rdi
leaq 0xfdf4(%rip), %rsi      # 0x23adb
callq 0x4310
movq %rax, -0xda8(%rbp)
jmp 0x13cf5
movq -0xda8(%rbp), %rdi
leaq -0x5c0(%rbp), %rsi
callq 0x42e0
movq %rax, -0xdb0(%rbp)
jmp 0x13d11
movq -0xdb0(%rbp), %rdi
leaq 0xfdcd(%rip), %rsi      # 0x23aec
callq 0x4310
movq %rax, -0xdb8(%rbp)
jmp 0x13d2d
movq -0xdb8(%rbp), %rdi
movq 0x18275(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x13d42
movq -0x70(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x13612
movq -0xa48(%rbp), %rdi
movq -0x568(%rbp), %rsi
movq -0x570(%rbp), %rdx
movq %rsp, %rax
leaq -0x5a0(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq -0x598(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq -0x590(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x88(%rbp), %rcx
leaq -0x7a(%rbp), %r8
leaq -0x588(%rbp), %r9
callq 0xc770
jmp 0x13da4
leaq -0x998(%rbp), %rdi
leaq -0x5c0(%rbp), %rsi
callq 0x42e0
movq %rax, -0xdc0(%rbp)
jmp 0x13dc0
movq -0xdc0(%rbp), %rdi
leaq 0xfd46(%rip), %rsi      # 0x23b14
callq 0x4310
movq %rax, -0xdc8(%rbp)
jmp 0x13ddc
movq -0xdc8(%rbp), %rdi
movq -0x5c8(%rbp), %rsi
callq 0x40d0
movq %rax, -0xdd0(%rbp)
jmp 0x13df8
movq -0xdd0(%rbp), %rdi
leaq 0xfd0e(%rip), %rsi      # 0x23b14
callq 0x4310
movq %rax, -0xdd8(%rbp)
jmp 0x13e14
movq -0xdd8(%rbp), %rdi
movq -0x5d0(%rbp), %rsi
callq 0x40d0
movq %rax, -0xde0(%rbp)
jmp 0x13e30
movq -0xde0(%rbp), %rdi
leaq 0xfcd6(%rip), %rsi      # 0x23b14
callq 0x4310
movq %rax, -0xde8(%rbp)
jmp 0x13e4c
movq -0xde8(%rbp), %rdi
movq -0x5d0(%rbp), %rsi
movq -0x5c8(%rbp), %rax
subq %rax, %rsi
callq 0x40d0
movq %rax, -0xdf0(%rbp)
jmp 0x13e72
movq -0xdf0(%rbp), %rdi
leaq 0xfc94(%rip), %rsi      # 0x23b14
callq 0x4310
movq %rax, -0xdf8(%rbp)
jmp 0x13e8e
movq -0xdf8(%rbp), %rdi
movsd -0x588(%rbp), %xmm0
callq 0x4660
movq %rax, -0xe00(%rbp)
jmp 0x13eab
movq -0xe00(%rbp), %rdi
leaq 0xfc5b(%rip), %rsi      # 0x23b14
callq 0x4310
movq %rax, -0xe08(%rbp)
jmp 0x13ec7
movq -0xe08(%rbp), %rdi
movsd -0x590(%rbp), %xmm0
callq 0x4660
movq %rax, -0xe10(%rbp)
jmp 0x13ee4
movq -0xe10(%rbp), %rdi
leaq 0xfc22(%rip), %rsi      # 0x23b14
callq 0x4310
movq %rax, -0xe18(%rbp)
jmp 0x13f00
movq -0xe18(%rbp), %rdi
movsd -0x598(%rbp), %xmm0
callq 0x4660
movq %rax, -0xe20(%rbp)
jmp 0x13f1d
movq -0xe20(%rbp), %rdi
leaq 0xfbe9(%rip), %rsi      # 0x23b14
callq 0x4310
movq %rax, -0xe28(%rbp)
jmp 0x13f39
movq -0xe28(%rbp), %rdi
movsd -0x5a0(%rbp), %xmm0
callq 0x4660
movq %rax, -0xe30(%rbp)
jmp 0x13f56
movq -0xe30(%rbp), %rdi
movq 0x1804c(%rip), %rsi     # 0x2bfb0
callq 0x4350
jmp 0x13f6b
movq -0x70(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x13612
movq -0x568(%rbp), %rax
movq %rax, -0xe38(%rbp)
cmpq $0x0, %rax
je 0x13f9c
movq -0xe38(%rbp), %rdi
callq 0x4480
movq -0x570(%rbp), %rax
movq %rax, -0xe40(%rbp)
cmpq $0x0, %rax
je 0x13fbc
movq -0xe40(%rbp), %rdi
callq 0x4480
movq -0xa48(%rbp), %rdi
addq $0x8, %rdi
callq 0x4060
jmp 0x13fce
movq -0xa48(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
callq 0x4060
jmp 0x13fe3
leaq -0x998(%rbp), %rdi
callq 0x44e0
jmp 0x13ff1
leaq -0x998(%rbp), %rdi
callq 0x4520
leaq -0x798(%rbp), %rdi
callq 0x4260
leaq -0x610(%rbp), %rdi
callq 0x46d8
leaq -0x5f0(%rbp), %rdi
callq 0x46d8
leaq -0x5c0(%rbp), %rdi
callq 0x46d8
movl $0x0, -0xac(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x46d8
addq $0xe60, %rsp            # imm = 0xE60
popq %rbp
retq
leaq -0x998(%rbp), %rdi
callq 0x4520
leaq -0x798(%rbp), %rdi
callq 0x4260
leaq -0x610(%rbp), %rdi
callq 0x46d8
leaq -0x5f0(%rbp), %rdi
callq 0x46d8
leaq -0x5c0(%rbp), %rdi
callq 0x46d8
leaq -0xa8(%rbp), %rdi
callq 0x46d8
movq -0x38(%rbp), %rdi
callq 0x4610
movq %rax, %rdi
callq 0x82c0
nopw %cs:(%rax,%rax)