// File: superyuan[P]refeditor/DiploidConstructor.cpp
// Function: main
int main(int argc, char *argv[])
{	
	string chrName = "", chrNameB = "";
	CLineFields inputReferenceGenomeFile;
	CLineFields genotypesFile;

	if (parseParameters (argc, argv) == false) 	{
		cerr << "Version: 1.0-r7" << endl;
		cerr << "Contact: shuaiyuan.emory@gmail.com" << endl << endl;		
		cerr << "Usage: " << argv[0] <<" -r haploid.fa -g genotypes -l length -o diploid.fa" << endl << endl;
		cerr << "Convert haploid reference genome to diploid reference genome according to the genotypes and sequencing read length" << endl << endl;
		cerr << "Example: " << argv[0] << " -r hg19.fa -g known.genotypes -l 36 -o diploid.fa" << endl;
		cerr << endl << "Parameters (mandatory): " << endl;
		cerr << "  -r\t\thaploid reference genome file " << endl;
		cerr << "  -g\t\tgenotypes file" << endl;
		cerr << "  -l\t\tread length" << endl;
		cerr << "  -o\t\toutput diploid reference genome file " << endl;
		cerr << endl << "Parameters (optional): " << endl;
		cerr << "  -d\t\tmaximal deletion in a read and mapped to alternative alleles [default=0]" << endl;
		cerr << "  -s\t\tsex of the individual [default=\"m\"]" << endl;
		exit(-1);
	}
	
	if (inputReferenceGenomeFile.openFile(inputReferenceGenomeFileName)==false) {
		cerr << "Can not open file: " << inputReferenceGenomeFileName << endl;
		exit (-1);
	}

	if (genotypesFile.openFile(genotypesFileName)==false) {
		cerr << "Can not open file: " << genotypesFileName << endl;
		exit (-1);
	}	

	// step 1: read haploid reference genome file, double the total number of chromosomes.
	bool readin = false;
	inputReferenceGenomeFile.readline();
	while (inputReferenceGenomeFile.endofFile()==false) {
		if (inputReferenceGenomeFile.line[0]=='>') {
			chrName = inputReferenceGenomeFile.line.substr(1);
			chrNameB = chrName+"b";
			if (chrName != "chrY" || gender=='m') {
				chrMap[chrName] = "";
				chrMap[chrNameB] = "";
				chrNameList.push_back(chrName);			
				chrNameList.push_back(chrNameB);
				readin = true;
			} else {
				readin = false;  // skip chromosome Y for female individuals.
			}
		} else if (readin){
			
			chrMap[chrName] += inputReferenceGenomeFile.line;
			chrMap[chrNameB] += inputReferenceGenomeFile.line;
		}
		inputReferenceGenomeFile.readline();
	}	
	inputReferenceGenomeFile.closeFile();

	// step 2: use genotype file to modify the chromosomes. double the chromosome numbers.
	if (genotypesFile.isOpen()) {
		int refColumn = -1, altColumn=-1;
		genotypesFile.readline();
		while(genotypesFile.endofFile()==false) {

			if ((genotypesFile.field.size()>=5) && (genotypesFile.field[3].length()==1) && (genotypesFile.field[4].length()==1))
			{
				unsigned int pos = atoi(genotypesFile.field[2].c_str());
				chrName = genotypesFile.field[1];
				chrNameB = chrName+"b";
			
				if (chrMap[chrName].length()<pos) {
					cerr << "Warning!!! genotype is out of range at: " << chrName << ": " << genotypesFile.field[2] << endl;
				} else {
					// decide which is ref and which is non-ref
					if (toupper(chrMap[chrName][pos-1]) == toupper(genotypesFile.field[4][0])) {
						refColumn = 4;
						altColumn = 3;
					}
					else {
						refColumn = 3;
						altColumn = 4;
					}

					// if genotype is alt/alt, then we still need to change reference allele.
					if (chrMap[chrName][pos-1] >='A' && chrMap[chrName][pos-1] <='Z') {
						chrMap[chrName][pos-1] = toupper(genotypesFile.field[refColumn][0]);
						chrMap[chrNameB][pos-1] = toupper(genotypesFile.field[altColumn][0]);
					}
					else {
						chrMap[chrName][pos-1] = tolower(genotypesFile.field[refColumn][0]);
						chrMap[chrNameB][pos-1] = tolower(genotypesFile.field[altColumn][0]);
					}
				}
			}
			genotypesFile.readline();
		}
		genotypesFile.closeFile();
	} 
	contextLength = 2*readLength - 1 + 2*maxDeletion;
	outputReferenceGenomeFile.open(outputReferenceGenomeFileName);
	dipmapFile.open(dipmapFileName);

	// step 3: create mini chromosomes and append them to the end of reference allele.
	for (int i=0; i<(int)chrNameList.size(); i++) {
		chrName = chrNameList[i];		
		if (chrName[chrName.length()-1] == 'b')
			extendFromDiploid(chrName);
	}

	// step 4: print out the reference allele, which has already been extended by mini chromosomes.
	for (int i=0; i<(int)chrNameList.size(); i++) {
		chrName = chrNameList[i];		
		if (chrName[chrName.length()-1] != 'b')
			printHaploid(chrName);
	}
	outputReferenceGenomeFile << endl;
	dipmapFile.close();
	outputReferenceGenomeFile.close();
	
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x500, %rsp            # imm = 0x500
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x3460
movq -0x250(%rbp), %rdx
leaq 0x8b97(%rip), %rsi      # 0xc32e
leaq -0x30(%rbp), %rdi
callq 0x5810
jmp 0x37a2
leaq -0x31(%rbp), %rdi
callq 0x32d0
leaq -0x69(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x3460
movq -0x258(%rbp), %rdx
leaq 0x8b65(%rip), %rsi      # 0xc32e
leaq -0x68(%rbp), %rdi
callq 0x5810
jmp 0x37d4
leaq -0x69(%rbp), %rdi
callq 0x32d0
leaq -0xb0(%rbp), %rdi
callq 0x9250
jmp 0x37eb
leaq -0xf0(%rbp), %rdi
callq 0x9250
jmp 0x37f9
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x4a10
movb %al, -0x259(%rbp)
jmp 0x380d
movb -0x259(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x3c0b
movq 0xe7c8(%rip), %rdi      # 0x11ff0
leaq 0x88a9(%rip), %rsi      # 0xc0d8
callq 0x3250
movq %rax, -0x268(%rbp)
jmp 0x383d
movq -0x268(%rbp), %rdi
movq 0xe75d(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3852
movq 0xe797(%rip), %rdi      # 0x11ff0
leaq 0x8888(%rip), %rsi      # 0xc0e8
callq 0x3250
movq %rax, -0x270(%rbp)
jmp 0x386e
movq -0x270(%rbp), %rdi
movq 0xe72c(%rip), %rsi      # 0x11fa8
callq 0x32a0
movq %rax, -0x278(%rbp)
jmp 0x388a
movq -0x278(%rbp), %rdi
movq 0xe710(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x389f
movq 0xe74a(%rip), %rdi      # 0x11ff0
leaq 0x885e(%rip), %rsi      # 0xc10b
callq 0x3250
movq %rax, -0x280(%rbp)
jmp 0x38bb
movq -0x280(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x3250
movq %rax, -0x288(%rbp)
jmp 0x38d7
movq -0x288(%rbp), %rdi
leaq 0x882e(%rip), %rsi      # 0xc113
callq 0x3250
movq %rax, -0x290(%rbp)
jmp 0x38f3
movq -0x290(%rbp), %rdi
movq 0xe6a7(%rip), %rsi      # 0x11fa8
callq 0x32a0
movq %rax, -0x298(%rbp)
jmp 0x390f
movq -0x298(%rbp), %rdi
movq 0xe68b(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3924
movq 0xe6c5(%rip), %rdi      # 0x11ff0
leaq 0x8815(%rip), %rsi      # 0xc147
callq 0x3250
movq %rax, -0x2a0(%rbp)
jmp 0x3940
movq -0x2a0(%rbp), %rdi
movq 0xe65a(%rip), %rsi      # 0x11fa8
callq 0x32a0
movq %rax, -0x2a8(%rbp)
jmp 0x395c
movq -0x2a8(%rbp), %rdi
movq 0xe63e(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3971
movq 0xe678(%rip), %rdi      # 0x11ff0
leaq 0x883b(%rip), %rsi      # 0xc1ba
callq 0x3250
movq %rax, -0x2b0(%rbp)
jmp 0x398d
movq -0x2b0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x3250
movq %rax, -0x2b8(%rbp)
jmp 0x39a9
movq -0x2b8(%rbp), %rdi
leaq 0x880d(%rip), %rsi      # 0xc1c4
callq 0x3250
movq %rax, -0x2c0(%rbp)
jmp 0x39c5
movq -0x2c0(%rbp), %rdi
movq 0xe5d5(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x39da
movq 0xe60f(%rip), %rdi      # 0x11ff0
movq 0xe5c0(%rip), %rsi      # 0x11fa8
callq 0x32a0
movq %rax, -0x2c8(%rbp)
jmp 0x39f6
movq -0x2c8(%rbp), %rdi
leaq 0x87f3(%rip), %rsi      # 0xc1f7
callq 0x3250
movq %rax, -0x2d0(%rbp)
jmp 0x3a12
movq -0x2d0(%rbp), %rdi
movq 0xe588(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3a27
movq 0xe5c2(%rip), %rdi      # 0x11ff0
leaq 0x87db(%rip), %rsi      # 0xc210
callq 0x3250
movq %rax, -0x2d8(%rbp)
jmp 0x3a43
movq -0x2d8(%rbp), %rdi
movq 0xe557(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3a58
movq 0xe591(%rip), %rdi      # 0x11ff0
leaq 0x87cf(%rip), %rsi      # 0xc235
callq 0x3250
movq %rax, -0x2e0(%rbp)
jmp 0x3a74
movq -0x2e0(%rbp), %rdi
movq 0xe526(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3a89
movq 0xe560(%rip), %rdi      # 0x11ff0
leaq 0x87b3(%rip), %rsi      # 0xc24a
callq 0x3250
movq %rax, -0x2e8(%rbp)
jmp 0x3aa5
movq -0x2e8(%rbp), %rdi
movq 0xe4f5(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3aba
movq 0xe52f(%rip), %rdi      # 0x11ff0
leaq 0x8794(%rip), %rsi      # 0xc25c
callq 0x3250
movq %rax, -0x2f0(%rbp)
jmp 0x3ad6
movq -0x2f0(%rbp), %rdi
movq 0xe4c4(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3aeb
movq 0xe4fe(%rip), %rdi      # 0x11ff0
movq 0xe4af(%rip), %rsi      # 0x11fa8
callq 0x32a0
movq %rax, -0x2f8(%rbp)
jmp 0x3b07
movq -0x2f8(%rbp), %rdi
leaq 0x8773(%rip), %rsi      # 0xc288
callq 0x3250
movq %rax, -0x300(%rbp)
jmp 0x3b23
movq -0x300(%rbp), %rdi
movq 0xe477(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3b38
movq 0xe4b1(%rip), %rdi      # 0x11ff0
leaq 0x875a(%rip), %rsi      # 0xc2a0
callq 0x3250
movq %rax, -0x308(%rbp)
jmp 0x3b54
movq -0x308(%rbp), %rdi
movq 0xe446(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3b69
movq 0xe480(%rip), %rdi      # 0x11ff0
leaq 0x8778(%rip), %rsi      # 0xc2ef
callq 0x3250
movq %rax, -0x310(%rbp)
jmp 0x3b85
movq -0x310(%rbp), %rdi
movq 0xe415(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3b9a
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3310
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x32d0
jmp 0x4a03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x32d0
jmp 0x49fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x49f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x49e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x49d9
leaq 0xe6be(%rip), %rsi      # 0x122d0
leaq -0xb0(%rbp), %rdi
callq 0x9110
movb %al, -0x311(%rbp)
jmp 0x3c26
movb -0x311(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x3c8d
movq 0xe3b3(%rip), %rdi      # 0x11ff0
leaq 0x86d5(%rip), %rsi      # 0xc319
callq 0x3250
movq %rax, -0x320(%rbp)
jmp 0x3c52
movq -0x320(%rbp), %rdi
leaq 0xe670(%rip), %rsi      # 0x122d0
callq 0x3250
movq %rax, -0x328(%rbp)
jmp 0x3c6e
movq -0x328(%rbp), %rdi
movq 0xe32c(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3c83
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3310
leaq 0xe93c(%rip), %rsi      # 0x125d0
leaq -0xf0(%rbp), %rdi
callq 0x9110
movb %al, -0x329(%rbp)
jmp 0x3ca8
movb -0x329(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x3d0f
movq 0xe331(%rip), %rdi      # 0x11ff0
leaq 0x8653(%rip), %rsi      # 0xc319
callq 0x3250
movq %rax, -0x338(%rbp)
jmp 0x3cd4
movq -0x338(%rbp), %rdi
leaq 0xe8ee(%rip), %rsi      # 0x125d0
callq 0x3250
movq %rax, -0x340(%rbp)
jmp 0x3cf0
movq -0x340(%rbp), %rdi
movq 0xe2aa(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x3d05
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3310
movb $0x0, -0xf1(%rbp)
leaq -0x119(%rbp), %rdi
movq %rdi, -0x348(%rbp)
callq 0x3460
movq -0x348(%rbp), %rdx
leaq 0x85f6(%rip), %rsi      # 0xc32d
leaq -0x118(%rbp), %rdi
callq 0x5810
jmp 0x3d45
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
leaq -0x118(%rbp), %rdx
callq 0x92c0
jmp 0x3d5f
leaq -0x118(%rbp), %rdi
callq 0x3518
leaq -0x119(%rbp), %rdi
callq 0x32d0
leaq -0xb0(%rbp), %rdi
callq 0x9290
movb %al, -0x349(%rbp)
jmp 0x3d8b
movb -0x349(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4077
leaq -0x90(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x358(%rbp)
jmp 0x3db8
movq -0x358(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0x3f55
leaq -0x90(%rbp), %rsi
leaq -0x140(%rbp), %rdi
movl $0x1, %edx
movq $-0x1, %rcx
callq 0x3280
jmp 0x3dec
leaq -0x30(%rbp), %rdi
movq %rdi, -0x360(%rbp)
leaq -0x140(%rbp), %rsi
movq %rsi, -0x368(%rbp)
callq 0x3320
movq -0x368(%rbp), %rdi
callq 0x3518
movq -0x360(%rbp), %rsi
leaq 0x850b(%rip), %rdx      # 0xc32f
leaq -0x160(%rbp), %rdi
callq 0x58c0
jmp 0x3e32
leaq -0x68(%rbp), %rdi
leaq -0x160(%rbp), %rsi
movq %rsi, -0x378(%rbp)
callq 0x3320
movq -0x378(%rbp), %rdi
callq 0x3518
leaq 0x84d5(%rip), %rsi      # 0xc331
leaq -0x30(%rbp), %rdi
callq 0x5940
movb %al, -0x369(%rbp)
jmp 0x3e6d
movb -0x369(%rbp), %al
testb $0x1, %al
jne 0x3e89
jmp 0x3e79
movsbl 0xe418(%rip), %eax      # 0x12298
cmpl $0x6d, %eax
jne 0x3f49
leaq 0xec50(%rip), %rdi      # 0x12ae0
leaq -0x30(%rbp), %rsi
callq 0x5970
movq %rax, -0x380(%rbp)
jmp 0x3ea2
movq -0x380(%rbp), %rdi
leaq 0x847e(%rip), %rsi      # 0xc32e
callq 0x3370
jmp 0x3eb7
leaq 0xec22(%rip), %rdi      # 0x12ae0
leaq -0x68(%rbp), %rsi
callq 0x5970
movq %rax, -0x388(%rbp)
jmp 0x3ed0
movq -0x388(%rbp), %rdi
leaq 0x8450(%rip), %rsi      # 0xc32e
callq 0x3370
jmp 0x3ee5
leaq 0xec24(%rip), %rdi      # 0x12b10
leaq -0x30(%rbp), %rsi
callq 0x5a50
jmp 0x3ef7
leaq 0xec12(%rip), %rdi      # 0x12b10
leaq -0x68(%rbp), %rsi
callq 0x5a50
jmp 0x3f09
movb $0x1, -0xf1(%rbp)
jmp 0x3f50
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3f38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x3518
leaq -0x119(%rbp), %rdi
callq 0x32d0
jmp 0x49d9
movb $0x0, -0xf1(%rbp)
jmp 0x3fda
testb $0x1, -0xf1(%rbp)
je 0x3fd8
leaq -0x90(%rbp), %rax
movq %rax, -0x398(%rbp)
leaq 0xeb6d(%rip), %rdi      # 0x12ae0
leaq -0x30(%rbp), %rsi
callq 0x5970
movq %rax, -0x390(%rbp)
jmp 0x3f85
movq -0x398(%rbp), %rsi
movq -0x390(%rbp), %rdi
callq 0x3350
jmp 0x3f9a
leaq -0x90(%rbp), %rax
movq %rax, -0x3a8(%rbp)
leaq 0xeb31(%rip), %rdi      # 0x12ae0
leaq -0x68(%rbp), %rsi
callq 0x5970
movq %rax, -0x3a0(%rbp)
jmp 0x3fc1
movq -0x3a8(%rbp), %rsi
movq -0x3a0(%rbp), %rdi
callq 0x3350
jmp 0x3fd6
jmp 0x3fd8
jmp 0x3fda
leaq -0x181(%rbp), %rdi
movq %rdi, -0x3b0(%rbp)
callq 0x3460
movq -0x3b0(%rbp), %rdx
leaq 0x8332(%rip), %rsi      # 0xc32d
leaq -0x180(%rbp), %rdi
callq 0x5810
jmp 0x4009
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
leaq -0x180(%rbp), %rdx
callq 0x92c0
jmp 0x4023
leaq -0x180(%rbp), %rdi
callq 0x3518
leaq -0x181(%rbp), %rdi
callq 0x32d0
jmp 0x3d77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4066
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x3518
leaq -0x181(%rbp), %rdi
callq 0x32d0
jmp 0x49d9
leaq -0xb0(%rbp), %rdi
callq 0x9190
jmp 0x4085
leaq -0xf0(%rbp), %rdi
callq 0x91b0
movb %al, -0x3b1(%rbp)
jmp 0x4099
movb -0x3b1(%rbp), %al
testb $0x1, %al
jne 0x40a8
jmp 0x473d
movl $0xffffffff, -0x188(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x18c(%rbp) # imm = 0xFFFFFFFF
leaq -0x1b1(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x3460
movq -0x3c0(%rbp), %rdx
leaq 0x8250(%rip), %rsi      # 0xc32d
leaq -0x1b0(%rbp), %rdi
callq 0x5810
jmp 0x40eb
leaq -0xf0(%rbp), %rdi
movl $0x1, %esi
leaq -0x1b0(%rbp), %rdx
callq 0x92c0
jmp 0x4105
leaq -0x1b0(%rbp), %rdi
callq 0x3518
leaq -0x1b1(%rbp), %rdi
callq 0x32d0
leaq -0xf0(%rbp), %rdi
callq 0x9290
movb %al, -0x3c1(%rbp)
jmp 0x4131
movb -0x3c1(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x472d
leaq -0xf0(%rbp), %rdi
callq 0x5ac0
cmpq $0x5, %rax
jb 0x4690
leaq -0xf0(%rbp), %rdi
movl $0x3, %esi
callq 0x5ae0
movq %rax, %rdi
callq 0x33c0
cmpq $0x1, %rax
jne 0x4690
leaq -0xf0(%rbp), %rdi
movl $0x4, %esi
callq 0x5ae0
movq %rax, %rdi
callq 0x33c0
cmpq $0x1, %rax
jne 0x4690
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
movl $0x2, %esi
callq 0x5ae0
movq %rax, %rdi
callq 0x3100
movq %rax, %rdi
callq 0x33e0
movq -0x3d0(%rbp), %rdi
movl %eax, -0x1b8(%rbp)
movl $0x1, %esi
callq 0x5ae0
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x3040
jmp 0x41ee
leaq 0x813a(%rip), %rdx      # 0xc32f
leaq -0x1d8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x58c0
jmp 0x4207
leaq -0x68(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
movq %rsi, -0x3e0(%rbp)
callq 0x3320
movq -0x3e0(%rbp), %rdi
callq 0x3518
leaq 0xe8af(%rip), %rdi      # 0x12ae0
leaq -0x30(%rbp), %rsi
callq 0x5970
movq %rax, -0x3d8(%rbp)
jmp 0x4243
movq -0x3d8(%rbp), %rdi
callq 0x33c0
movl -0x1b8(%rbp), %ecx
cmpq %rcx, %rax
jae 0x4329
movq 0xdd8b(%rip), %rdi      # 0x11ff0
leaq 0x80ca(%rip), %rsi      # 0xc336
callq 0x3250
movq %rax, -0x3e8(%rbp)
jmp 0x427a
movq -0x3e8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3220
movq %rax, -0x3f0(%rbp)
jmp 0x4293
movq -0x3f0(%rbp), %rdi
leaq 0x7ffc(%rip), %rsi      # 0xc29d
callq 0x3250
movq %rax, -0x3f8(%rbp)
jmp 0x42af
leaq -0xf0(%rbp), %rdi
movl $0x2, %esi
callq 0x5ae0
movq -0x3f8(%rbp), %rdi
movq %rax, %rsi
callq 0x3220
movq %rax, -0x400(%rbp)
jmp 0x42d8
movq -0x400(%rbp), %rdi
movq 0xdcc2(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x42ed
jmp 0x468e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4318
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x3518
leaq -0x1b1(%rbp), %rdi
callq 0x32d0
jmp 0x49d9
leaq 0xe7b0(%rip), %rdi      # 0x12ae0
leaq -0x30(%rbp), %rsi
callq 0x5970
movq %rax, -0x408(%rbp)
jmp 0x4342
movq -0x408(%rbp), %rdi
movl -0x1b8(%rbp), %eax
decl %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x410(%rbp)
jmp 0x4361
movq -0x410(%rbp), %rax
movsbl (%rax), %edi
callq 0x34c0
movl %eax, -0x41c(%rbp)
leaq -0xf0(%rbp), %rdi
movl $0x4, %esi
callq 0x5ae0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x418(%rbp)
jmp 0x439c
movq -0x418(%rbp), %rax
movsbl (%rax), %edi
callq 0x34c0
movl %eax, %ecx
movl -0x41c(%rbp), %eax
cmpl %ecx, %eax
jne 0x43cd
movl $0x4, -0x188(%rbp)
movl $0x3, -0x18c(%rbp)
jmp 0x43e1
movl $0x3, -0x188(%rbp)
movl $0x4, -0x18c(%rbp)
leaq 0xe6f8(%rip), %rdi      # 0x12ae0
leaq -0x30(%rbp), %rsi
callq 0x5970
movq %rax, -0x428(%rbp)
jmp 0x43fa
movq -0x428(%rbp), %rdi
movl -0x1b8(%rbp), %eax
decl %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x430(%rbp)
jmp 0x4419
movq -0x430(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x41, %eax
jl 0x4584
leaq 0xe6ad(%rip), %rdi      # 0x12ae0
leaq -0x30(%rbp), %rsi
callq 0x5970
movq %rax, -0x438(%rbp)
jmp 0x4445
movq -0x438(%rbp), %rdi
movl -0x1b8(%rbp), %eax
decl %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x440(%rbp)
jmp 0x4464
movq -0x440(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5a, %eax
jg 0x4584
movslq -0x188(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x5ae0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x448(%rbp)
jmp 0x449f
movq -0x448(%rbp), %rax
movsbl (%rax), %edi
callq 0x34c0
movb %al, -0x451(%rbp)
leaq 0xe625(%rip), %rdi      # 0x12ae0
leaq -0x30(%rbp), %rsi
callq 0x5970
movq %rax, -0x450(%rbp)
jmp 0x44cd
movq -0x450(%rbp), %rdi
movl -0x1b8(%rbp), %eax
decl %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x460(%rbp)
jmp 0x44ec
movq -0x460(%rbp), %rax
movb -0x451(%rbp), %cl
movb %cl, (%rax)
movslq -0x18c(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x5ae0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x468(%rbp)
jmp 0x4523
movq -0x468(%rbp), %rax
movsbl (%rax), %edi
callq 0x34c0
movb %al, -0x471(%rbp)
leaq 0xe5a1(%rip), %rdi      # 0x12ae0
leaq -0x68(%rbp), %rsi
callq 0x5970
movq %rax, -0x470(%rbp)
jmp 0x4551
movq -0x470(%rbp), %rdi
movl -0x1b8(%rbp), %eax
decl %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x480(%rbp)
jmp 0x4570
movq -0x480(%rbp), %rax
movb -0x471(%rbp), %cl
movb %cl, (%rax)
jmp 0x468c
movslq -0x188(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x5ae0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x488(%rbp)
jmp 0x45ac
movq -0x488(%rbp), %rax
movsbl (%rax), %edi
callq 0x33a0
movb %al, -0x491(%rbp)
leaq 0xe518(%rip), %rdi      # 0x12ae0
leaq -0x30(%rbp), %rsi
callq 0x5970
movq %rax, -0x490(%rbp)
jmp 0x45da
movq -0x490(%rbp), %rdi
movl -0x1b8(%rbp), %eax
decl %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x4a0(%rbp)
jmp 0x45f9
movq -0x4a0(%rbp), %rax
movb -0x491(%rbp), %cl
movb %cl, (%rax)
movslq -0x18c(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x5ae0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x4a8(%rbp)
jmp 0x4630
movq -0x4a8(%rbp), %rax
movsbl (%rax), %edi
callq 0x33a0
movb %al, -0x4b1(%rbp)
leaq 0xe494(%rip), %rdi      # 0x12ae0
leaq -0x68(%rbp), %rsi
callq 0x5970
movq %rax, -0x4b0(%rbp)
jmp 0x465e
movq -0x4b0(%rbp), %rdi
movl -0x1b8(%rbp), %eax
decl %eax
movl %eax, %esi
callq 0x34f0
movq %rax, -0x4c0(%rbp)
jmp 0x467d
movq -0x4c0(%rbp), %rax
movb -0x4b1(%rbp), %cl
movb %cl, (%rax)
jmp 0x468e
jmp 0x4690
leaq -0x1f9(%rbp), %rdi
movq %rdi, -0x4c8(%rbp)
callq 0x3460
movq -0x4c8(%rbp), %rdx
leaq 0x7c7c(%rip), %rsi      # 0xc32d
leaq -0x1f8(%rbp), %rdi
callq 0x5810
jmp 0x46bf
leaq -0xf0(%rbp), %rdi
movl $0x1, %esi
leaq -0x1f8(%rbp), %rdx
callq 0x92c0
jmp 0x46d9
leaq -0x1f8(%rbp), %rdi
callq 0x3518
leaq -0x1f9(%rbp), %rdi
callq 0x32d0
jmp 0x411d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x471c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x3518
leaq -0x1f9(%rbp), %rdi
callq 0x32d0
jmp 0x49d9
leaq -0xf0(%rbp), %rdi
callq 0x9190
jmp 0x473b
jmp 0x473d
movl 0xdf8d(%rip), %eax      # 0x126d0
movl 0xdf8b(%rip), %edx      # 0x126d4
addl %edx, %edx
movl %eax, %ecx
movl %edx, %eax
leal -0x1(%rax,%rcx,2), %eax
movl %eax, 0xe37f(%rip)      # 0x12ad8
leaq 0xe178(%rip), %rdi      # 0x128d8
leaq 0xdc69(%rip), %rsi      # 0x123d0
movl $0x10, %edx
callq 0x3050
jmp 0x4773
leaq 0xdf5e(%rip), %rdi      # 0x126d8
leaq 0xdd4f(%rip), %rsi      # 0x124d0
movl $0x10, %edx
callq 0x3050
jmp 0x478d
movl $0x0, -0x200(%rbp)
movl -0x200(%rbp), %eax
movl %eax, -0x4cc(%rbp)
leaq 0xe366(%rip), %rdi      # 0x12b10
callq 0x5ac0
movq %rax, %rcx
movl -0x4cc(%rbp), %eax
cmpl %ecx, %eax
jge 0x487c
movslq -0x200(%rbp), %rsi
leaq 0xe342(%rip), %rdi      # 0x12b10
callq 0x5ae0
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x3040
jmp 0x47e1
leaq -0x30(%rbp), %rdi
movq %rdi, -0x4e0(%rbp)
callq 0x33c0
movq -0x4e0(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x34f0
movq %rax, -0x4d8(%rbp)
jmp 0x480c
movq -0x4d8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x62, %eax
jne 0x4866
leaq -0x220(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3110
jmp 0x482d
leaq -0x220(%rbp), %rdi
callq 0x4b80
jmp 0x483b
leaq -0x220(%rbp), %rdi
callq 0x3518
jmp 0x4866
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x3518
jmp 0x49d9
jmp 0x4868
movl -0x200(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x200(%rbp)
jmp 0x4797
movl $0x0, -0x224(%rbp)
movl -0x224(%rbp), %eax
movl %eax, -0x4e4(%rbp)
leaq 0xe277(%rip), %rdi      # 0x12b10
callq 0x5ac0
movq %rax, %rcx
movl -0x4e4(%rbp), %eax
cmpl %ecx, %eax
jge 0x496b
movslq -0x224(%rbp), %rsi
leaq 0xe253(%rip), %rdi      # 0x12b10
callq 0x5ae0
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x3040
jmp 0x48d0
leaq -0x30(%rbp), %rdi
movq %rdi, -0x4f8(%rbp)
callq 0x33c0
movq -0x4f8(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x34f0
movq %rax, -0x4f0(%rbp)
jmp 0x48fb
movq -0x4f0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x62, %eax
je 0x4955
leaq -0x248(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3110
jmp 0x491c
leaq -0x248(%rbp), %rdi
callq 0x5550
jmp 0x492a
leaq -0x248(%rbp), %rdi
callq 0x3518
jmp 0x4955
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x3518
jmp 0x49d9
jmp 0x4957
movl -0x224(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x224(%rbp)
jmp 0x4886
leaq 0xdf66(%rip), %rdi      # 0x128d8
movq 0xd62f(%rip), %rsi      # 0x11fa8
callq 0x32a0
jmp 0x4980
leaq 0xdd51(%rip), %rdi      # 0x126d8
callq 0x3390
jmp 0x498e
leaq 0xdf43(%rip), %rdi      # 0x128d8
callq 0x3390
jmp 0x499c
movl $0x0, -0x4(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x5b00
leaq -0xb0(%rbp), %rdi
callq 0x5b00
leaq -0x68(%rbp), %rdi
callq 0x3518
leaq -0x30(%rbp), %rdi
callq 0x3518
movl -0x4(%rbp), %eax
addq $0x500, %rsp            # imm = 0x500
popq %rbp
retq
leaq -0xf0(%rbp), %rdi
callq 0x5b00
leaq -0xb0(%rbp), %rdi
callq 0x5b00
leaq -0x68(%rbp), %rdi
callq 0x3518
leaq -0x30(%rbp), %rdi
callq 0x3518
movq -0x40(%rbp), %rdi
callq 0x3450
nopl (%rax)