// File: treroy13[P]Branch-Predictor/predictors.cpp
// Function: main
int main(int argc, char *argv[]) {

	unsigned long long addr1;
	string behavior1;
	int takenCount =0;
	int untakenCount =0;
	int numBranches = 0;


	//create a struct with addr and behavior
	struct branches{

		unsigned long long addr;
		int behavior;

	};

	branches br;

	//push structs into vector temp
	std::vector<branches>temp;

	
	//input file 
	ifstream infile(argv[1]);

	//placing values into struct/pushing back into vector
	while(infile >> std::hex >> addr1 >> behavior1) {
	
		numBranches++;	//get total count of file 

		br.addr = addr1;

		if(behavior1 == "T")
			br.behavior = 1;
		else
			br.behavior = 0;

		temp.push_back(br); //insert into vector	

	}

	infile.close();
	
//------------------------ALWAYS TAKEN & NON TAKEN--------------------------------------------

	
	for(int i = 0; i<temp.size(); i++){
		if(temp[i].behavior == 1)
			takenCount++;
		else
			untakenCount++;	
	}

	 
	//output file taken and nottaken
	ofstream outfile(argv[2]);
	outfile << takenCount<<","<<numBranches<<";\n";
	outfile << untakenCount<<","<<numBranches<<";\n";

//------------------------BIMODAL SINGLE BIT--------------------------------------------------

	
	int tableSize[] = {16,32,128,256,512,1024,2048};

	int singleCorrect16 = 0;
	int singleCorrect32 = 0;
	int singleCorrect128 = 0;
	int singleCorrect256 = 0;
	int singleCorrect512 = 0;
	int singleCorrect1024 = 0;
	int singleCorrect2048 = 0;	 

	//initialing vector to all takens (1)
	std::vector<int>bits(numBranches,1);	 
	
	int check;

	//loop through 7 different table sizes
	for(int i = 0 ; i < 7; i++){

		//reset branch for new table size
		std::fill(bits.begin(),bits.end(),1); 

		//loop through struct with values from the file
		for(int k =0; k < temp.size(); k++){
			
			//mod address with table size			
			check = temp[k].addr % tableSize[i];			
 
			//if prediction is correct, then increment counter
			if(bits[check] == temp[k].behavior){
				if (i==0){
					singleCorrect16++;
				}
				if (i ==1){
					singleCorrect32++;
				}
				if (i ==2){
					singleCorrect128++;
				}
				if (i ==3){
					singleCorrect256++;
				}
				if (i ==4){
					singleCorrect512++;
				}
				if (i ==5){
					singleCorrect1024++;
				}
				if(i==6){
					singleCorrect2048++;
				}
			}

			else{
				//wrong prediction so change to 0
				bits[check] = temp[k].behavior;
			}
			
		}			

	}

	outfile << singleCorrect16<<","<<numBranches<<"; "<< singleCorrect32<<","<<numBranches<<"; "<< singleCorrect128<<","<<numBranches<<"; "<< singleCorrect256<<","<<numBranches<<"; "<< singleCorrect512<<","<<numBranches<<"; "<< singleCorrect1024<<","<<numBranches<<"; "<< singleCorrect2048<<","<<numBranches<<";\n";



//------------------------BIMODAL 2 BIT--------------------------------------------------


	int twoCorrect16 = 0;
	int twoCorrect32 = 0;
	int twoCorrect128 = 0;
	int twoCorrect256 = 0;
	int twoCorrect512 = 0;
	int twoCorrect1024 = 0;
	int twoCorrect2048 = 0;

	int check2;
	unsigned int vecVal;	 

	//initialing vector to all takens (1)
	std::vector<unsigned int>bits2(numBranches,3);

	//looping through 7 different table sizes
	for(int j = 0 ; j < 7; j++){
	
		std::fill(bits2.begin(),bits2.end(),3); //reset vector with all 3

		for(unsigned long long n =0; n < temp.size(); n++){

			check2 = temp[n].addr % tableSize[j]; //index
			vecVal = bits2[check2]; //current state of vector


			//if prediction is correct then increment counter for each table size
                        if(((temp[n].behavior == 1) && ((vecVal == 3)||(vecVal == 2))) || ((temp[n].behavior == 0) && ((vecVal ==0) || (vecVal ==1)))){
				if (j==0){
					twoCorrect16++;
				}
				if (j ==1){
					twoCorrect32++;
				}
				if (j ==2){
					twoCorrect128++;
				}
				if (j ==3){
					twoCorrect256++;
				}
				if (j ==4){
					twoCorrect512++;
				}
				if (j ==5){
					twoCorrect1024++;
				}
				if (j ==6){
					twoCorrect2048++;
				}

			}			

			if(temp[n].behavior == 1){ //increment so closer to strongly taken
				if(vecVal != 3){
					vecVal++;
				}
			}
			if(temp[n].behavior == 0){
				if(vecVal != 0){ //decrement so closer to not taken
					vecVal--;
				}		
			}
			
			bits2[check2] = vecVal; //update vector with new value
		}

	}


	outfile << twoCorrect16<<","<<numBranches<<"; "<< twoCorrect32<<","<<numBranches<<"; "<< twoCorrect128<<","<<numBranches<<"; "<< twoCorrect256<<","<<numBranches<<"; "<< twoCorrect512<<","<<numBranches<<"; "<< twoCorrect1024<<","<<numBranches<<"; "<< twoCorrect2048<<","<<numBranches<<";\n";


//-----------------------------------------GSHARE--------------------------------------------------

	int p1 = 0;
	int p2 = 0;
	int p3 = 0;
	int p4 = 0;
	int p5 = 0;
	int p6 = 0;
	int p7 = 0;
	int p8 = 0;
	int p9 = 0;


	unsigned int size;

	unsigned long long hist;

	std::vector<unsigned int>table(2048,3);//vector initialized to strongly taken

	for(int i = 3; i<= 11; i++){

		hist = 0; //GHR

		std::fill(table.begin(),table.end(),3); //reset vector with all 3

		for(int d = 0; d < temp.size(); d++){

			int ck = (temp[d].addr ^ (hist & ((int) pow(2,i)-1))) % 2048; //XOR GHR with table size of 2048 (use pow to convert GHR to an int so its easier to xor with table size)

			unsigned int vecVal1 = table[ck];
			
			//if prediction is correct, then increment correct counter for each table size
			if(((temp[d].behavior == 1) && ((vecVal1 == 3)||(vecVal1 == 2))) || ((temp[d].behavior == 0) && ((vecVal1 ==0) || (vecVal1 ==1)))){
				if (i==3){
					p1++;
				}
				if (i ==4){
					p2++;
				}
				if (i ==5){
					p3++;
				}
				if (i ==6){
					p4++;
				}
				if (i ==7){
					p5++;
				}
				if (i ==8){
					p6++;
				}
				if (i ==9){
					p7++;
				}
				if (i ==10){
					p8++;
				}
				if (i ==11){
					p9++;
				}

			}

			if(temp[d].behavior == 1){ //increment so closer to strongly taken

				if(vecVal1 != 3)
					vecVal1++;
			}
			if(temp[d].behavior == 0){ //decrement so closer to not taken
				if(vecVal1 != 0)
					vecVal1--;
			}

			table[ck] = vecVal1; //update table with value

			//updating the GHR

			hist <<= 1; //shift the register
			
			hist |= temp[d].behavior; //bitwise OR (incrementing GHR) 			

		}	
		
	}

	outfile << p1<<","<<numBranches<<"; "<< p2<<","<<numBranches<<"; "<< p3<<","<<numBranches<<"; "<< p4<<","<<numBranches<<"; "<< p5<<","<<numBranches<<"; "<< p6<<","<<numBranches<<"; "<< p7<<","<<numBranches<<"; "<<p8<<","<<numBranches<<"; "<<p9<<","<<numBranches<<";\n";


//------------------------------------------TOURNAMENT------------------------------------------
	
	//counter for the number of times correct
	int tournCount = 0;

	//declaring GHR
	int hist2 = 0;

	//initializing gshare, bimodal, and tournament tables 
	std::vector<unsigned int> gs (2048, 3);
	std::vector<unsigned int> bi(2048, 3);
	std::vector<unsigned int> tourn(2048, 0); //tournament table initalized to prefer gshare

	for(int i = 0; i < temp.size(); i++){
                
		//using bimodal predictor index                                                                                         
		int index = temp[i].addr % 2048;

		//XORing GHR(use pow to convert to int) with table size
		int gIndex = (temp[i].addr ^ (hist2 & ((int) pow(2, 11) -1))) % 2048;

		//variables to keep track of state of each table 
		int biState = bi[index];	
		int gsState = gs[gIndex];
		int tournState = tourn[index];

		//predicted values
		int biVal = biState & 2;
		int gsVal = gsState & 2;		

		//if the predicted values are not equal, it means either bimodal or gshare is better so tournament table needs to be updated towards favored prediction 
		if(gsVal != biVal){

			//if tournament table prefers gshare
			if(tournState < 2){

				//if gshare predicted value is correct, then increment correct counter
				if(((temp[i].behavior == 1) && ((gsVal == 3)||(gsVal == 2))) || ((temp[i].behavior == 0) && ((gsVal ==0) || (gsVal ==1)))){
					tournCount++;
					
					//decrement tournament state value towards gshare since it was correct
					if(tournState != 0)
						tournState--;

				}

				//if gshare prediction was wrong, then increment tournament table towards bimodal
				else{
					if(tournState != 3)
						tournState++;
				}

			}

			else{ //tournament table prefers bimodal 

				
				//if bimodal predicted value is correct, then increment correct counter
				if(((temp[i].behavior == 1) && ((biVal == 3)||(biVal == 2))) || ((temp[i].behavior == 0) && ((biVal ==0) || (biVal ==1)))){
					tournCount++;

					//increment tournament table towards bimodal since it was correct
					if(tournState != 3)
						tournState++;

				}

				else{
					//since bimodal was wrong, then decrement tournament table towards gshare
					if(tournState != 0)
						tournState--;

				}

			}

		}


		//if predicted values are equal and its the correct prediction, then increment correct counter
		if(gsVal == biVal){

			if(((temp[i].behavior == 1) && ((gsVal == 3)||(gsVal == 2))) || ((temp[i].behavior == 0) && ((gsVal ==0) || (gsVal ==1)))){
				tournCount++;

			}

		}


		//update bimodal and gshare
		if(temp[i].behavior == 0){

			if(gsState != 0)
				gsState--;

			if(biState != 0)
				biState--;
		}
		
		if(temp[i].behavior == 1){


			if(gsState != 3)
				gsState++;

			if(biState != 3)
				biState++;


		}	

		gs[gIndex] = gsState;
		bi[index] = biState;

		//update GHR	
		hist2 <<= 1;
		hist2 |= temp[i].behavior;

		//update tournament table state value
		tourn[index] = tournState;

	}		

	outfile << tournCount<<","<<numBranches<<"; ";
	outfile.close();	

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa90, %rsp            # imm = 0xA90
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2140
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4160
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x278(%rbp), %rdi
movl $0x8, %edx
callq 0x21d0
jmp 0x237b
jmp 0x237d
leaq 0x281c(%rip), %rsi      # 0x4ba0
leaq -0x278(%rbp), %rdi
callq 0x2190
movq %rax, -0x688(%rbp)
jmp 0x2399
movq -0x688(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x2110
movq %rax, -0x690(%rbp)
jmp 0x23b2
movq -0x690(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2130
movq %rax, -0x698(%rbp)
jmp 0x23cb
movq -0x698(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2120
movb %al, -0x699(%rbp)
jmp 0x23e9
movb -0x699(%rbp), %al
testb $0x1, %al
jne 0x23f8
jmp 0x247e
movl -0x44(%rbp), %eax
incl %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq 0x4bf5(%rip), %rsi      # 0x7004
leaq -0x38(%rbp), %rdi
callq 0x4bd0
movb %al, -0x69a(%rbp)
jmp 0x2420
movb -0x69a(%rbp), %al
testb $0x1, %al
jne 0x242c
jmp 0x2463
movl $0x1, -0x50(%rbp)
jmp 0x246a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x413a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x412e
movl $0x0, -0x50(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x4180
jmp 0x2479
jmp 0x237d
leaq -0x278(%rbp), %rdi
callq 0x2030
jmp 0x248c
movl $0x0, -0x288(%rbp)
movslq -0x288(%rbp), %rax
movq %rax, -0x6a8(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x41f0
movq %rax, %rcx
movq -0x6a8(%rbp), %rax
cmpq %rcx, %rax
jae 0x24f9
movslq -0x288(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x1, 0x8(%rax)
jne 0x24dd
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x24e6
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x24e8
movl -0x288(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x288(%rbp)
jmp 0x2496
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq -0x488(%rbp), %rdi
movl $0x10, %edx
callq 0x2100
jmp 0x2514
movl -0x3c(%rbp), %esi
leaq -0x488(%rbp), %rdi
callq 0x21a0
movq %rax, -0x6b0(%rbp)
jmp 0x252c
movq -0x6b0(%rbp), %rdi
leaq 0x4acc(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x6b8(%rbp)
jmp 0x2548
movq -0x6b8(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x6c0(%rbp)
jmp 0x2560
movq -0x6c0(%rbp), %rdi
leaq 0x4a9a(%rip), %rsi      # 0x7008
callq 0x20e0
jmp 0x2575
movl -0x40(%rbp), %esi
leaq -0x488(%rbp), %rdi
callq 0x21a0
movq %rax, -0x6c8(%rbp)
jmp 0x258d
movq -0x6c8(%rbp), %rdi
leaq 0x4a6b(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x6d0(%rbp)
jmp 0x25a9
movq -0x6d0(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x6d8(%rbp)
jmp 0x25c1
movq -0x6d8(%rbp), %rdi
leaq 0x4a39(%rip), %rsi      # 0x7008
callq 0x20e0
jmp 0x25d6
movups 0x4a8f(%rip), %xmm0     # 0x706c
movups %xmm0, -0x4a4(%rbp)
movaps 0x4a75(%rip), %xmm0     # 0x7060
movaps %xmm0, -0x4b0(%rbp)
movl $0x0, -0x4b4(%rbp)
movl $0x0, -0x4b8(%rbp)
movl $0x0, -0x4bc(%rbp)
movl $0x0, -0x4c0(%rbp)
movl $0x0, -0x4c4(%rbp)
movl $0x0, -0x4c8(%rbp)
movl $0x0, -0x4cc(%rbp)
movslq -0x44(%rbp), %rax
movq %rax, -0x6e8(%rbp)
movl $0x1, -0x4ec(%rbp)
leaq -0x4ed(%rbp), %rdi
movq %rdi, -0x6e0(%rbp)
callq 0x4c00
movq -0x6e8(%rbp), %rsi
movq -0x6e0(%rbp), %rcx
leaq -0x4e8(%rbp), %rdi
leaq -0x4ec(%rbp), %rdx
callq 0x4c20
jmp 0x2683
leaq -0x4ed(%rbp), %rdi
callq 0x4ca0
movl $0x0, -0x4f8(%rbp)
cmpl $0x7, -0x4f8(%rbp)
jge 0x28f6
leaq -0x4e8(%rbp), %rdi
movq %rdi, -0x6f0(%rbp)
callq 0x4d00
movq -0x6f0(%rbp), %rdi
movq %rax, -0x500(%rbp)
callq 0x4d30
movq %rax, -0x508(%rbp)
movl $0x1, -0x50c(%rbp)
movq -0x500(%rbp), %rdi
movq -0x508(%rbp), %rsi
leaq -0x50c(%rbp), %rdx
callq 0x4cc0
jmp 0x26f9
movl $0x0, -0x510(%rbp)
movslq -0x510(%rbp), %rax
movq %rax, -0x6f8(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x41f0
movq %rax, %rcx
movq -0x6f8(%rbp), %rax
cmpq %rcx, %rax
jae 0x28e0
movslq -0x510(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
movq (%rax), %rax
movslq -0x4f8(%rbp), %rcx
movslq -0x4b0(%rbp,%rcx,4), %rcx
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, -0x4f4(%rbp)
movslq -0x4f4(%rbp), %rsi
leaq -0x4e8(%rbp), %rdi
callq 0x4d60
movl (%rax), %eax
movl %eax, -0x6fc(%rbp)
movslq -0x510(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
movq %rax, %rcx
movl -0x6fc(%rbp), %eax
cmpl 0x8(%rcx), %eax
jne 0x2896
cmpl $0x0, -0x4f8(%rbp)
jne 0x2804
movl -0x4b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4b4(%rbp)
jmp 0x2804
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x4122
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x4ed(%rbp), %rdi
callq 0x4ca0
jmp 0x4122
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x4116
cmpl $0x1, -0x4f8(%rbp)
jne 0x281c
movl -0x4b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4b8(%rbp)
cmpl $0x2, -0x4f8(%rbp)
jne 0x2834
movl -0x4bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4bc(%rbp)
cmpl $0x3, -0x4f8(%rbp)
jne 0x284c
movl -0x4c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c0(%rbp)
cmpl $0x4, -0x4f8(%rbp)
jne 0x2864
movl -0x4c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c4(%rbp)
cmpl $0x5, -0x4f8(%rbp)
jne 0x287c
movl -0x4c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c8(%rbp)
cmpl $0x6, -0x4f8(%rbp)
jne 0x2894
movl -0x4cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4cc(%rbp)
jmp 0x28ca
movslq -0x510(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
movl 0x8(%rax), %eax
movl %eax, -0x700(%rbp)
movslq -0x4f4(%rbp), %rsi
leaq -0x4e8(%rbp), %rdi
callq 0x4d60
movl -0x700(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x28cc
movl -0x510(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x510(%rbp)
jmp 0x2703
jmp 0x28e2
movl -0x4f8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4f8(%rbp)
jmp 0x2699
movl -0x4b4(%rbp), %esi
leaq -0x488(%rbp), %rdi
callq 0x21a0
movq %rax, -0x708(%rbp)
jmp 0x2911
movq -0x708(%rbp), %rdi
leaq 0x46e7(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x710(%rbp)
jmp 0x292d
movq -0x710(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x718(%rbp)
jmp 0x2945
movq -0x718(%rbp), %rdi
leaq 0x46b8(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x720(%rbp)
jmp 0x2961
movq -0x720(%rbp), %rdi
movl -0x4b8(%rbp), %esi
callq 0x21a0
movq %rax, -0x728(%rbp)
jmp 0x297c
movq -0x728(%rbp), %rdi
leaq 0x467c(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x730(%rbp)
jmp 0x2998
movq -0x730(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x738(%rbp)
jmp 0x29b0
movq -0x738(%rbp), %rdi
leaq 0x464d(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x740(%rbp)
jmp 0x29cc
movq -0x740(%rbp), %rdi
movl -0x4bc(%rbp), %esi
callq 0x21a0
movq %rax, -0x748(%rbp)
jmp 0x29e7
movq -0x748(%rbp), %rdi
leaq 0x4611(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x750(%rbp)
jmp 0x2a03
movq -0x750(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x758(%rbp)
jmp 0x2a1b
movq -0x758(%rbp), %rdi
leaq 0x45e2(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x760(%rbp)
jmp 0x2a37
movq -0x760(%rbp), %rdi
movl -0x4c0(%rbp), %esi
callq 0x21a0
movq %rax, -0x768(%rbp)
jmp 0x2a52
movq -0x768(%rbp), %rdi
leaq 0x45a6(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x770(%rbp)
jmp 0x2a6e
movq -0x770(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x778(%rbp)
jmp 0x2a86
movq -0x778(%rbp), %rdi
leaq 0x4577(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x780(%rbp)
jmp 0x2aa2
movq -0x780(%rbp), %rdi
movl -0x4c4(%rbp), %esi
callq 0x21a0
movq %rax, -0x788(%rbp)
jmp 0x2abd
movq -0x788(%rbp), %rdi
leaq 0x453b(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x790(%rbp)
jmp 0x2ad9
movq -0x790(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x798(%rbp)
jmp 0x2af1
movq -0x798(%rbp), %rdi
leaq 0x450c(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x7a0(%rbp)
jmp 0x2b0d
movq -0x7a0(%rbp), %rdi
movl -0x4c8(%rbp), %esi
callq 0x21a0
movq %rax, -0x7a8(%rbp)
jmp 0x2b28
movq -0x7a8(%rbp), %rdi
leaq 0x44d0(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x7b0(%rbp)
jmp 0x2b44
movq -0x7b0(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x7b8(%rbp)
jmp 0x2b5c
movq -0x7b8(%rbp), %rdi
leaq 0x44a1(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x7c0(%rbp)
jmp 0x2b78
movq -0x7c0(%rbp), %rdi
movl -0x4cc(%rbp), %esi
callq 0x21a0
movq %rax, -0x7c8(%rbp)
jmp 0x2b93
movq -0x7c8(%rbp), %rdi
leaq 0x4465(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x7d0(%rbp)
jmp 0x2baf
movq -0x7d0(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x7d8(%rbp)
jmp 0x2bc7
movq -0x7d8(%rbp), %rdi
leaq 0x4433(%rip), %rsi      # 0x7008
callq 0x20e0
jmp 0x2bdc
movl $0x0, -0x514(%rbp)
movl $0x0, -0x518(%rbp)
movl $0x0, -0x51c(%rbp)
movl $0x0, -0x520(%rbp)
movl $0x0, -0x524(%rbp)
movl $0x0, -0x528(%rbp)
movl $0x0, -0x52c(%rbp)
movslq -0x44(%rbp), %rax
movq %rax, -0x7e8(%rbp)
movl $0x3, -0x554(%rbp)
leaq -0x555(%rbp), %rdi
movq %rdi, -0x7e0(%rbp)
callq 0x4d80
movq -0x7e8(%rbp), %rsi
movq -0x7e0(%rbp), %rcx
leaq -0x550(%rbp), %rdi
leaq -0x554(%rbp), %rdx
callq 0x4da0
jmp 0x2c6d
leaq -0x555(%rbp), %rdi
callq 0x4e20
movl $0x0, -0x55c(%rbp)
cmpl $0x7, -0x55c(%rbp)
jge 0x2f54
leaq -0x550(%rbp), %rdi
movq %rdi, -0x7f0(%rbp)
callq 0x4e80
movq -0x7f0(%rbp), %rdi
movq %rax, -0x568(%rbp)
callq 0x4eb0
movq %rax, -0x570(%rbp)
movl $0x3, -0x574(%rbp)
movq -0x568(%rbp), %rdi
movq -0x570(%rbp), %rsi
leaq -0x574(%rbp), %rdx
callq 0x4e40
jmp 0x2ce3
movq $0x0, -0x580(%rbp)
movq -0x580(%rbp), %rax
movq %rax, -0x7f8(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x41f0
movq %rax, %rcx
movq -0x7f8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2f3e
movq -0x580(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
movq (%rax), %rax
movslq -0x55c(%rbp), %rcx
movslq -0x4b0(%rbp,%rcx,4), %rcx
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, -0x530(%rbp)
movslq -0x530(%rbp), %rsi
leaq -0x550(%rbp), %rdi
callq 0x4ee0
movl (%rax), %eax
movl %eax, -0x534(%rbp)
movq -0x580(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x1, 0x8(%rax)
jne 0x2d8a
cmpl $0x3, -0x534(%rbp)
je 0x2dba
cmpl $0x2, -0x534(%rbp)
je 0x2dba
movq -0x580(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x0, 0x8(%rax)
jne 0x2ea0
cmpl $0x0, -0x534(%rbp)
je 0x2dba
cmpl $0x1, -0x534(%rbp)
jne 0x2ea0
cmpl $0x0, -0x55c(%rbp)
jne 0x2e0e
movl -0x514(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x514(%rbp)
jmp 0x2e0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x555(%rbp), %rdi
callq 0x4e20
jmp 0x4116
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x410a
cmpl $0x1, -0x55c(%rbp)
jne 0x2e26
movl -0x518(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x518(%rbp)
cmpl $0x2, -0x55c(%rbp)
jne 0x2e3e
movl -0x51c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x51c(%rbp)
cmpl $0x3, -0x55c(%rbp)
jne 0x2e56
movl -0x520(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x520(%rbp)
cmpl $0x4, -0x55c(%rbp)
jne 0x2e6e
movl -0x524(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x524(%rbp)
cmpl $0x5, -0x55c(%rbp)
jne 0x2e86
movl -0x528(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x528(%rbp)
cmpl $0x6, -0x55c(%rbp)
jne 0x2e9e
movl -0x52c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x52c(%rbp)
jmp 0x2ea0
movq -0x580(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x1, 0x8(%rax)
jne 0x2ed0
cmpl $0x3, -0x534(%rbp)
je 0x2ece
movl -0x534(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x534(%rbp)
jmp 0x2ed0
movq -0x580(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x0, 0x8(%rax)
jne 0x2f00
cmpl $0x0, -0x534(%rbp)
je 0x2efe
movl -0x534(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x534(%rbp)
jmp 0x2f00
movl -0x534(%rbp), %eax
movl %eax, -0x7fc(%rbp)
movslq -0x530(%rbp), %rsi
leaq -0x550(%rbp), %rdi
callq 0x4ee0
movl -0x7fc(%rbp), %ecx
movl %ecx, (%rax)
movq -0x580(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x580(%rbp)
jmp 0x2cee
jmp 0x2f40
movl -0x55c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x55c(%rbp)
jmp 0x2c83
movl -0x514(%rbp), %esi
leaq -0x488(%rbp), %rdi
callq 0x21a0
movq %rax, -0x808(%rbp)
jmp 0x2f6f
movq -0x808(%rbp), %rdi
leaq 0x4089(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x810(%rbp)
jmp 0x2f8b
movq -0x810(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x818(%rbp)
jmp 0x2fa3
movq -0x818(%rbp), %rdi
leaq 0x405a(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x820(%rbp)
jmp 0x2fbf
movq -0x820(%rbp), %rdi
movl -0x518(%rbp), %esi
callq 0x21a0
movq %rax, -0x828(%rbp)
jmp 0x2fda
movq -0x828(%rbp), %rdi
leaq 0x401e(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x830(%rbp)
jmp 0x2ff6
movq -0x830(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x838(%rbp)
jmp 0x300e
movq -0x838(%rbp), %rdi
leaq 0x3fef(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x840(%rbp)
jmp 0x302a
movq -0x840(%rbp), %rdi
movl -0x51c(%rbp), %esi
callq 0x21a0
movq %rax, -0x848(%rbp)
jmp 0x3045
movq -0x848(%rbp), %rdi
leaq 0x3fb3(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x850(%rbp)
jmp 0x3061
movq -0x850(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x858(%rbp)
jmp 0x3079
movq -0x858(%rbp), %rdi
leaq 0x3f84(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x860(%rbp)
jmp 0x3095
movq -0x860(%rbp), %rdi
movl -0x520(%rbp), %esi
callq 0x21a0
movq %rax, -0x868(%rbp)
jmp 0x30b0
movq -0x868(%rbp), %rdi
leaq 0x3f48(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x870(%rbp)
jmp 0x30cc
movq -0x870(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x878(%rbp)
jmp 0x30e4
movq -0x878(%rbp), %rdi
leaq 0x3f19(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x880(%rbp)
jmp 0x3100
movq -0x880(%rbp), %rdi
movl -0x524(%rbp), %esi
callq 0x21a0
movq %rax, -0x888(%rbp)
jmp 0x311b
movq -0x888(%rbp), %rdi
leaq 0x3edd(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x890(%rbp)
jmp 0x3137
movq -0x890(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x898(%rbp)
jmp 0x314f
movq -0x898(%rbp), %rdi
leaq 0x3eae(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x8a0(%rbp)
jmp 0x316b
movq -0x8a0(%rbp), %rdi
movl -0x528(%rbp), %esi
callq 0x21a0
movq %rax, -0x8a8(%rbp)
jmp 0x3186
movq -0x8a8(%rbp), %rdi
leaq 0x3e72(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x8b0(%rbp)
jmp 0x31a2
movq -0x8b0(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x8b8(%rbp)
jmp 0x31ba
movq -0x8b8(%rbp), %rdi
leaq 0x3e43(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x8c0(%rbp)
jmp 0x31d6
movq -0x8c0(%rbp), %rdi
movl -0x52c(%rbp), %esi
callq 0x21a0
movq %rax, -0x8c8(%rbp)
jmp 0x31f1
movq -0x8c8(%rbp), %rdi
leaq 0x3e07(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x8d0(%rbp)
jmp 0x320d
movq -0x8d0(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x8d8(%rbp)
jmp 0x3225
movq -0x8d8(%rbp), %rdi
leaq 0x3dd5(%rip), %rsi      # 0x7008
callq 0x20e0
jmp 0x323a
movl $0x0, -0x584(%rbp)
movl $0x0, -0x588(%rbp)
movl $0x0, -0x58c(%rbp)
movl $0x0, -0x590(%rbp)
movl $0x0, -0x594(%rbp)
movl $0x0, -0x598(%rbp)
movl $0x0, -0x59c(%rbp)
movl $0x0, -0x5a0(%rbp)
movl $0x0, -0x5a4(%rbp)
movl $0x3, -0x5cc(%rbp)
leaq -0x5cd(%rbp), %rdi
movq %rdi, -0x8e0(%rbp)
callq 0x4d80
movq -0x8e0(%rbp), %rcx
leaq -0x5c8(%rbp), %rdi
movl $0x800, %esi            # imm = 0x800
leaq -0x5cc(%rbp), %rdx
callq 0x4da0
jmp 0x32d2
leaq -0x5cd(%rbp), %rdi
callq 0x4e20
movl $0x3, -0x5d4(%rbp)
cmpl $0xb, -0x5d4(%rbp)
jg 0x3668
movq $0x0, -0x5b0(%rbp)
leaq -0x5c8(%rbp), %rdi
movq %rdi, -0x8e8(%rbp)
callq 0x4e80
movq -0x8e8(%rbp), %rdi
movq %rax, -0x5e0(%rbp)
callq 0x4eb0
movq %rax, -0x5e8(%rbp)
movl $0x3, -0x5ec(%rbp)
movq -0x5e0(%rbp), %rdi
movq -0x5e8(%rbp), %rsi
leaq -0x5ec(%rbp), %rdx
callq 0x4e40
jmp 0x3353
movl $0x0, -0x5f0(%rbp)
movslq -0x5f0(%rbp), %rax
movq %rax, -0x8f0(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x41f0
movq %rax, %rcx
movq -0x8f0(%rbp), %rax
cmpq %rcx, %rax
jae 0x3652
movslq -0x5f0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
movq (%rax), %rax
movq %rax, -0x908(%rbp)
movq -0x5b0(%rbp), %rax
movq %rax, -0x900(%rbp)
movl -0x5d4(%rbp), %esi
movl $0x2, %edi
callq 0x4f00
movsd %xmm0, -0x8f8(%rbp)
jmp 0x33c9
movq -0x908(%rbp), %rax
movq -0x900(%rbp), %rcx
movsd -0x8f8(%rbp), %xmm0
cvttsd2si %xmm0, %edx
subl $0x1, %edx
movslq %edx, %rdx
andq %rdx, %rcx
xorq %rcx, %rax
andq $0x7ff, %rax            # imm = 0x7FF
movl %eax, -0x5f4(%rbp)
movslq -0x5f4(%rbp), %rsi
leaq -0x5c8(%rbp), %rdi
callq 0x4ee0
movl (%rax), %eax
movl %eax, -0x5f8(%rbp)
movslq -0x5f0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x1, 0x8(%rax)
jne 0x343e
cmpl $0x3, -0x5f8(%rbp)
je 0x346e
cmpl $0x2, -0x5f8(%rbp)
je 0x346e
movslq -0x5f0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x0, 0x8(%rax)
jne 0x3584
cmpl $0x0, -0x5f8(%rbp)
je 0x346e
cmpl $0x1, -0x5f8(%rbp)
jne 0x3584
cmpl $0x3, -0x5d4(%rbp)
jne 0x34c2
movl -0x584(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x584(%rbp)
jmp 0x34c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x5cd(%rbp), %rdi
callq 0x4e20
jmp 0x410a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
jmp 0x40fe
cmpl $0x4, -0x5d4(%rbp)
jne 0x34da
movl -0x588(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x588(%rbp)
cmpl $0x5, -0x5d4(%rbp)
jne 0x34f2
movl -0x58c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58c(%rbp)
cmpl $0x6, -0x5d4(%rbp)
jne 0x350a
movl -0x590(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x590(%rbp)
cmpl $0x7, -0x5d4(%rbp)
jne 0x3522
movl -0x594(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x594(%rbp)
cmpl $0x8, -0x5d4(%rbp)
jne 0x353a
movl -0x598(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x598(%rbp)
cmpl $0x9, -0x5d4(%rbp)
jne 0x3552
movl -0x59c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x59c(%rbp)
cmpl $0xa, -0x5d4(%rbp)
jne 0x356a
movl -0x5a0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5a0(%rbp)
cmpl $0xb, -0x5d4(%rbp)
jne 0x3582
movl -0x5a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5a4(%rbp)
jmp 0x3584
movslq -0x5f0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x1, 0x8(%rax)
jne 0x35b4
cmpl $0x3, -0x5f8(%rbp)
je 0x35b2
movl -0x5f8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5f8(%rbp)
jmp 0x35b4
movslq -0x5f0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x0, 0x8(%rax)
jne 0x35e4
cmpl $0x0, -0x5f8(%rbp)
je 0x35e2
movl -0x5f8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5f8(%rbp)
jmp 0x35e4
movl -0x5f8(%rbp), %eax
movl %eax, -0x90c(%rbp)
movslq -0x5f4(%rbp), %rsi
leaq -0x5c8(%rbp), %rdi
callq 0x4ee0
movl -0x90c(%rbp), %ecx
movl %ecx, (%rax)
movq -0x5b0(%rbp), %rax
shlq %rax
movq %rax, -0x5b0(%rbp)
movslq -0x5f0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
movslq 0x8(%rax), %rax
orq -0x5b0(%rbp), %rax
movq %rax, -0x5b0(%rbp)
movl -0x5f0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5f0(%rbp)
jmp 0x335d
jmp 0x3654
movl -0x5d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5d4(%rbp)
jmp 0x32e8
movl -0x584(%rbp), %esi
leaq -0x488(%rbp), %rdi
callq 0x21a0
movq %rax, -0x918(%rbp)
jmp 0x3683
movq -0x918(%rbp), %rdi
leaq 0x3975(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x920(%rbp)
jmp 0x369f
movq -0x920(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x928(%rbp)
jmp 0x36b7
movq -0x928(%rbp), %rdi
leaq 0x3946(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x930(%rbp)
jmp 0x36d3
movq -0x930(%rbp), %rdi
movl -0x588(%rbp), %esi
callq 0x21a0
movq %rax, -0x938(%rbp)
jmp 0x36ee
movq -0x938(%rbp), %rdi
leaq 0x390a(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x940(%rbp)
jmp 0x370a
movq -0x940(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x948(%rbp)
jmp 0x3722
movq -0x948(%rbp), %rdi
leaq 0x38db(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x950(%rbp)
jmp 0x373e
movq -0x950(%rbp), %rdi
movl -0x58c(%rbp), %esi
callq 0x21a0
movq %rax, -0x958(%rbp)
jmp 0x3759
movq -0x958(%rbp), %rdi
leaq 0x389f(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x960(%rbp)
jmp 0x3775
movq -0x960(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x968(%rbp)
jmp 0x378d
movq -0x968(%rbp), %rdi
leaq 0x3870(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x970(%rbp)
jmp 0x37a9
movq -0x970(%rbp), %rdi
movl -0x590(%rbp), %esi
callq 0x21a0
movq %rax, -0x978(%rbp)
jmp 0x37c4
movq -0x978(%rbp), %rdi
leaq 0x3834(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x980(%rbp)
jmp 0x37e0
movq -0x980(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x988(%rbp)
jmp 0x37f8
movq -0x988(%rbp), %rdi
leaq 0x3805(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x990(%rbp)
jmp 0x3814
movq -0x990(%rbp), %rdi
movl -0x594(%rbp), %esi
callq 0x21a0
movq %rax, -0x998(%rbp)
jmp 0x382f
movq -0x998(%rbp), %rdi
leaq 0x37c9(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x9a0(%rbp)
jmp 0x384b
movq -0x9a0(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x9a8(%rbp)
jmp 0x3863
movq -0x9a8(%rbp), %rdi
leaq 0x379a(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x9b0(%rbp)
jmp 0x387f
movq -0x9b0(%rbp), %rdi
movl -0x598(%rbp), %esi
callq 0x21a0
movq %rax, -0x9b8(%rbp)
jmp 0x389a
movq -0x9b8(%rbp), %rdi
leaq 0x375e(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x9c0(%rbp)
jmp 0x38b6
movq -0x9c0(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x9c8(%rbp)
jmp 0x38ce
movq -0x9c8(%rbp), %rdi
leaq 0x372f(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x9d0(%rbp)
jmp 0x38ea
movq -0x9d0(%rbp), %rdi
movl -0x59c(%rbp), %esi
callq 0x21a0
movq %rax, -0x9d8(%rbp)
jmp 0x3905
movq -0x9d8(%rbp), %rdi
leaq 0x36f3(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0x9e0(%rbp)
jmp 0x3921
movq -0x9e0(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0x9e8(%rbp)
jmp 0x3939
movq -0x9e8(%rbp), %rdi
leaq 0x36c4(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0x9f0(%rbp)
jmp 0x3955
movq -0x9f0(%rbp), %rdi
movl -0x5a0(%rbp), %esi
callq 0x21a0
movq %rax, -0x9f8(%rbp)
jmp 0x3970
movq -0x9f8(%rbp), %rdi
leaq 0x3688(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0xa00(%rbp)
jmp 0x398c
movq -0xa00(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0xa08(%rbp)
jmp 0x39a4
movq -0xa08(%rbp), %rdi
leaq 0x3659(%rip), %rsi      # 0x700b
callq 0x20e0
movq %rax, -0xa10(%rbp)
jmp 0x39c0
movq -0xa10(%rbp), %rdi
movl -0x5a4(%rbp), %esi
callq 0x21a0
movq %rax, -0xa18(%rbp)
jmp 0x39db
movq -0xa18(%rbp), %rdi
leaq 0x361d(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0xa20(%rbp)
jmp 0x39f7
movq -0xa20(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0xa28(%rbp)
jmp 0x3a0f
movq -0xa28(%rbp), %rdi
leaq 0x35eb(%rip), %rsi      # 0x7008
callq 0x20e0
jmp 0x3a24
movl $0x0, -0x5fc(%rbp)
movl $0x0, -0x600(%rbp)
movl $0x3, -0x61c(%rbp)
leaq -0x61d(%rbp), %rdi
movq %rdi, -0xa30(%rbp)
callq 0x4d80
movq -0xa30(%rbp), %rcx
leaq -0x618(%rbp), %rdi
movl $0x800, %esi            # imm = 0x800
leaq -0x61c(%rbp), %rdx
callq 0x4da0
jmp 0x3a76
leaq -0x61d(%rbp), %rdi
callq 0x4e20
movl $0x3, -0x63c(%rbp)
leaq -0x63d(%rbp), %rdi
movq %rdi, -0xa38(%rbp)
callq 0x4d80
movq -0xa38(%rbp), %rcx
leaq -0x638(%rbp), %rdi
movl $0x800, %esi            # imm = 0x800
leaq -0x63c(%rbp), %rdx
callq 0x4da0
jmp 0x3ac0
leaq -0x63d(%rbp), %rdi
callq 0x4e20
movl $0x0, -0x65c(%rbp)
leaq -0x65d(%rbp), %rdi
movq %rdi, -0xa40(%rbp)
callq 0x4d80
movq -0xa40(%rbp), %rcx
leaq -0x658(%rbp), %rdi
movl $0x800, %esi            # imm = 0x800
leaq -0x65c(%rbp), %rdx
callq 0x4da0
jmp 0x3b0a
leaq -0x65d(%rbp), %rdi
callq 0x4e20
movl $0x0, -0x664(%rbp)
movslq -0x664(%rbp), %rax
movq %rax, -0xa48(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x41f0
movq %rax, %rcx
movq -0xa48(%rbp), %rax
cmpq %rcx, %rax
jae 0x3fef
movslq -0x664(%rbp), %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0xa68(%rbp)
callq 0x4210
movq -0xa68(%rbp), %rdi
movl (%rax), %eax
andl $0x7ff, %eax            # imm = 0x7FF
movl %eax, -0x668(%rbp)
movslq -0x664(%rbp), %rsi
callq 0x4210
movq (%rax), %rax
movq %rax, -0xa60(%rbp)
movl -0x600(%rbp), %eax
movl %eax, -0xa54(%rbp)
movl $0x2, %edi
movl $0xb, %esi
callq 0x4f00
movsd %xmm0, -0xa50(%rbp)
jmp 0x3bb0
movq -0xa60(%rbp), %rax
movl -0xa54(%rbp), %ecx
movsd -0xa50(%rbp), %xmm0
cvttsd2si %xmm0, %edx
subl $0x1, %edx
andl %edx, %ecx
movslq %ecx, %rcx
xorq %rcx, %rax
andq $0x7ff, %rax            # imm = 0x7FF
movl %eax, -0x66c(%rbp)
movslq -0x668(%rbp), %rsi
leaq -0x638(%rbp), %rdi
callq 0x4ee0
movl (%rax), %eax
movl %eax, -0x670(%rbp)
movslq -0x66c(%rbp), %rsi
leaq -0x618(%rbp), %rdi
callq 0x4ee0
movl (%rax), %eax
movl %eax, -0x674(%rbp)
movslq -0x668(%rbp), %rsi
leaq -0x658(%rbp), %rdi
callq 0x4ee0
movl (%rax), %eax
movl %eax, -0x678(%rbp)
movl -0x670(%rbp), %eax
andl $0x2, %eax
movl %eax, -0x67c(%rbp)
movl -0x674(%rbp), %eax
andl $0x2, %eax
movl %eax, -0x680(%rbp)
movl -0x680(%rbp), %eax
cmpl -0x67c(%rbp), %eax
je 0x3e3a
cmpl $0x2, -0x678(%rbp)
jge 0x3da3
movslq -0x664(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x1, 0x8(%rax)
jne 0x3c96
cmpl $0x3, -0x680(%rbp)
je 0x3cc6
cmpl $0x2, -0x680(%rbp)
je 0x3cc6
movslq -0x664(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x0, 0x8(%rax)
jne 0x3d84
cmpl $0x0, -0x680(%rbp)
je 0x3cc6
cmpl $0x1, -0x680(%rbp)
jne 0x3d84
movl -0x5fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5fc(%rbp)
cmpl $0x0, -0x678(%rbp)
je 0x3d82
movl -0x678(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x678(%rbp)
jmp 0x3d82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x61d(%rbp), %rdi
callq 0x4e20
jmp 0x40fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x63d(%rbp), %rdi
callq 0x4e20
jmp 0x40f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x65d(%rbp), %rdi
callq 0x4e20
jmp 0x40e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x280(%rbp)
movl %eax, -0x284(%rbp)
leaq -0x658(%rbp), %rdi
callq 0x4f30
jmp 0x40e6
jmp 0x3d9e
cmpl $0x3, -0x678(%rbp)
je 0x3d9c
movl -0x678(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x678(%rbp)
jmp 0x3d9e
jmp 0x3e38
movslq -0x664(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x1, 0x8(%rax)
jne 0x3dcb
cmpl $0x3, -0x67c(%rbp)
je 0x3df3
cmpl $0x2, -0x67c(%rbp)
je 0x3df3
movslq -0x664(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x0, 0x8(%rax)
jne 0x3e1c
cmpl $0x0, -0x67c(%rbp)
je 0x3df3
cmpl $0x1, -0x67c(%rbp)
jne 0x3e1c
movl -0x5fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5fc(%rbp)
cmpl $0x3, -0x678(%rbp)
je 0x3e1a
movl -0x678(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x678(%rbp)
jmp 0x3e36
cmpl $0x0, -0x678(%rbp)
je 0x3e34
movl -0x678(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x678(%rbp)
jmp 0x3e36
jmp 0x3e38
jmp 0x3e3a
movl -0x680(%rbp), %eax
cmpl -0x67c(%rbp), %eax
jne 0x3ea9
movslq -0x664(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x1, 0x8(%rax)
jne 0x3e70
cmpl $0x3, -0x680(%rbp)
je 0x3e98
cmpl $0x2, -0x680(%rbp)
je 0x3e98
movslq -0x664(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x0, 0x8(%rax)
jne 0x3ea7
cmpl $0x0, -0x680(%rbp)
je 0x3e98
cmpl $0x1, -0x680(%rbp)
jne 0x3ea7
movl -0x5fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5fc(%rbp)
jmp 0x3ea9
movslq -0x664(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x0, 0x8(%rax)
jne 0x3ef1
cmpl $0x0, -0x674(%rbp)
je 0x3ed7
movl -0x674(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x674(%rbp)
cmpl $0x0, -0x670(%rbp)
je 0x3eef
movl -0x670(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x670(%rbp)
jmp 0x3ef1
movslq -0x664(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
cmpl $0x1, 0x8(%rax)
jne 0x3f39
cmpl $0x3, -0x674(%rbp)
je 0x3f1f
movl -0x674(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x674(%rbp)
cmpl $0x3, -0x670(%rbp)
je 0x3f37
movl -0x670(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x670(%rbp)
jmp 0x3f39
movl -0x674(%rbp), %eax
movl %eax, -0xa74(%rbp)
movslq -0x66c(%rbp), %rsi
leaq -0x618(%rbp), %rdi
callq 0x4ee0
movl -0xa74(%rbp), %ecx
movl %ecx, (%rax)
movl -0x670(%rbp), %eax
movl %eax, -0xa70(%rbp)
movslq -0x668(%rbp), %rsi
leaq -0x638(%rbp), %rdi
callq 0x4ee0
movl -0xa70(%rbp), %ecx
movl %ecx, (%rax)
movl -0x600(%rbp), %eax
shll %eax
movl %eax, -0x600(%rbp)
movslq -0x664(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4210
movl 0x8(%rax), %eax
orl -0x600(%rbp), %eax
movl %eax, -0x600(%rbp)
movl -0x678(%rbp), %eax
movl %eax, -0xa6c(%rbp)
movslq -0x668(%rbp), %rsi
leaq -0x658(%rbp), %rdi
callq 0x4ee0
movl -0xa6c(%rbp), %ecx
movl %ecx, (%rax)
movl -0x664(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x664(%rbp)
jmp 0x3b20
movl -0x5fc(%rbp), %esi
leaq -0x488(%rbp), %rdi
callq 0x21a0
movq %rax, -0xa80(%rbp)
jmp 0x400a
movq -0xa80(%rbp), %rdi
leaq 0x2fee(%rip), %rsi      # 0x7006
callq 0x20e0
movq %rax, -0xa88(%rbp)
jmp 0x4026
movq -0xa88(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x21a0
movq %rax, -0xa90(%rbp)
jmp 0x403e
movq -0xa90(%rbp), %rdi
leaq 0x2fbf(%rip), %rsi      # 0x700b
callq 0x20e0
jmp 0x4053
leaq -0x488(%rbp), %rdi
callq 0x2150
jmp 0x4061
movl $0x0, -0x4(%rbp)
leaq -0x658(%rbp), %rdi
callq 0x4f30
leaq -0x638(%rbp), %rdi
callq 0x4f30
leaq -0x618(%rbp), %rdi
callq 0x4f30
leaq -0x5c8(%rbp), %rdi
callq 0x4f30
leaq -0x550(%rbp), %rdi
callq 0x4f30
leaq -0x4e8(%rbp), %rdi
callq 0x4f90
leaq -0x488(%rbp), %rdi
callq 0x2160
leaq -0x278(%rbp), %rdi
callq 0x2040
leaq -0x70(%rbp), %rdi
callq 0x4230
leaq -0x38(%rbp), %rdi
callq 0x20a0
movl -0x4(%rbp), %eax
addq $0xa90, %rsp            # imm = 0xA90
popq %rbp
retq
leaq -0x638(%rbp), %rdi
callq 0x4f30
leaq -0x618(%rbp), %rdi
callq 0x4f30
leaq -0x5c8(%rbp), %rdi
callq 0x4f30
leaq -0x550(%rbp), %rdi
callq 0x4f30
leaq -0x4e8(%rbp), %rdi
callq 0x4f90
leaq -0x488(%rbp), %rdi
callq 0x2160
leaq -0x278(%rbp), %rdi
callq 0x2040
leaq -0x70(%rbp), %rdi
callq 0x4230
leaq -0x38(%rbp), %rdi
callq 0x20a0
movq -0x280(%rbp), %rdi
callq 0x21c0
nopl (%rax,%rax)