// File: Doug0855[P]TigerZone/Board.cpp
// Function: Board::buildTrail(Structure*, Tile*, std::vector<std::vector<Block, std::allocator<Block>>, std::allocator<std::vector<Block, std::allocator<Block>>>>&, std::pair<int, int>, std::vector<Tile*, std::allocator<Tile*>>&)
void Board::buildTrail(Structure* struc, Tile *tile, std::vector< std::vector<Block> >& tileBlocks, std::pair<int,int> blockSpot, std::vector<Tile*> &visitedTiles) {
	int row = blockSpot.first;
	int col = blockSpot.second;
	tileBlocks[row][col].visit();

	// We must check how many ways a trail exits/enters a block to know how many trails the block contains.
	// If its 2 or under then the block is 1 connected trail, if it's more than the trails all start from the center and are unique entities
	if(row == 1 && col == 1) {
		int divergingTrailCount = 0;
		if(tileBlocks[row+1][col].getType() == "trail")
			divergingTrailCount++;
		if(tileBlocks[row-1][col].getType() == "trail")
			divergingTrailCount++;
		if(tileBlocks[row][col+1].getType() == "trail")
			divergingTrailCount++;
		if(tileBlocks[row][col-1].getType() == "trail")
			divergingTrailCount++;
		if(divergingTrailCount > 2)
			return;
	}

	struc->structureBlocks.push_back(tileBlocks[row][col]);

	// Check block for meeple
	if(tileBlocks[row][col].hasMeeple())
		struc->hasMeeple = true;

	// Check to see if you've added this blocks animals
	bool addedTileAnimals;
	for(int i = 0; i < visitedTiles.size(); i++) {
			if(visitedTiles[i] == tile)
			{
				addedTileAnimals = true;
				//debugging std::cout<<"Added animals already for this tile"<<std::endl;
			}
	}
	if(!addedTileAnimals) {
		struc->checkAnimals(tile);
		// if(tile->hasCrocodile())
		// 	struc->crocodileCount++;
		// if(tile->hasDeer())
		// 	struc->deerCount++;
		// if(tile->hasBoar())
		// 	struc->boarCount++;
		// if(tile->hasBuffalo())
		// 	struc->buffaloCount++;
	}

	// Check tiles above, below, left, and right of the current block to see if trail structure continues
	if((row + 1) <= 2 && !(tileBlocks[row + 1][col].isVisited()) && tileBlocks[row+1][col].getType() == "trail") {
		buildTrail(struc, tile, tileBlocks, std::pair<int,int>(row+1,col), visitedTiles);
	}
	else if(row + 1 > 2 && tile->getDownTile() != NULL) {
		bool visitedNeighborTile = false;
		for(int i = 0; i < visitedTiles.size(); i++) {
			if(visitedTiles[i] == tile->getDownTile())
				visitedNeighborTile = true;
		}
		if(!visitedNeighborTile) {
			visitedTiles.push_back(tile->getDownTile());
			std::vector< std::vector<Block> > newBlocks = tile->getDownTile()->getInnerBlocks();
			buildTrail(struc, tile->getDownTile(), newBlocks, std::pair<int,int>(row - 2,col), visitedTiles);
		}
	}
	// std::cout<<"about to check row-1"<<std::endl;
	if((row - 1) >= 0 && !(tileBlocks[row - 1][col].isVisited()) && tileBlocks[row - 1][col].getType() == "trail") {
		buildTrail(struc, tile, tileBlocks, std::pair<int,int>(row-1,col), visitedTiles);
	}
	else if(row-1 < 0 && tile->getUpTile() != NULL) {
		bool visitedNeighborTile = false;
		for(int i = 0; i < visitedTiles.size(); i++) {
			if(visitedTiles[i] == tile->getUpTile())
				visitedNeighborTile = true;
		}
		if(!visitedNeighborTile) {
			visitedTiles.push_back(tile->getUpTile());
			std::vector< std::vector<Block> > newBlocks = tile->getUpTile()->getInnerBlocks();
			buildTrail(struc, tile->getUpTile(), newBlocks, std::pair<int,int>(row+2,col), visitedTiles);
		}
	}
	// std::cout<<"about to check col+1"<<std::endl;
	if((col + 1) <= 2 && !(tileBlocks[row][col + 1].isVisited()) && tileBlocks[row][col + 1].getType() == "trail") {
		buildTrail(struc, tile, tileBlocks, std::pair<int,int>(row,col+1), visitedTiles);
	}
	else if(col+1 > 2 && tile->getRightTile() != NULL) {
		bool visitedNeighborTile = false;
		for(int i = 0; i < visitedTiles.size(); i++) {
			if(visitedTiles[i] == tile->getRightTile())
				visitedNeighborTile = true;
		}
		if(!visitedNeighborTile) {
			visitedTiles.push_back(tile->getRightTile());
			std::vector< std::vector<Block> > newBlocks = tile->getRightTile()->getInnerBlocks();
			buildTrail(struc, tile->getRightTile(), newBlocks, std::pair<int,int>(row,col-2), visitedTiles);
		}
	}
	// std::cout<<"about to check col-1"<<std::endl;
	if((col - 1) >= 0 && !(tileBlocks[row][col-1].isVisited()) && tileBlocks[row][col - 1].getType() == "trail") {
		// std::cout<<"passing col-1"<<std::endl;
		buildTrail(struc, tile, tileBlocks, std::pair<int,int>(row,col-1), visitedTiles);
	}
	else if(col-1 < 0 && tile->getLeftTile() != NULL) {
		bool visitedNeighborTile = false;
		for(int i = 0; i < visitedTiles.size(); i++) {
			if(visitedTiles[i] == tile->getLeftTile())
				visitedNeighborTile = true;
		}
		if(!visitedNeighborTile) {
			visitedTiles.push_back(tile->getLeftTile());
			std::vector< std::vector<Block> > newBlocks = tile->getLeftTile()->getInnerBlocks();
			buildTrail(struc, tile->getLeftTile(), newBlocks, std::pair<int,int>(row,col+2), visitedTiles);
		}
	}
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movq %r8, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x280(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x17390
movq %rax, %rdi
movslq -0x38(%rbp), %rsi
callq 0x173b0
movq %rax, %rdi
callq 0x20580
cmpl $0x1, -0x34(%rbp)
jne 0x1f3c2
cmpl $0x1, -0x38(%rbp)
jne 0x1f3c2
movl $0x0, -0x3c(%rbp)
movq -0x28(%rbp), %rdi
movl -0x34(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x17390
movq %rax, %rdi
movslq -0x38(%rbp), %rsi
callq 0x173b0
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x15490
movq -0x290(%rbp), %rdi
leaq 0xa4ef(%rip), %rsi      # 0x296b3
callq 0x85b0
movb %al, -0x281(%rbp)
jmp 0x1f1d1
leaq -0x60(%rbp), %rdi
callq 0x3210
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0x1f1e6
jmp 0x1f20b
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1f20b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3210
jmp 0x20119
movq -0x28(%rbp), %rdi
movl -0x34(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x17390
movq %rax, %rdi
movslq -0x38(%rbp), %rsi
callq 0x173b0
movq %rax, %rsi
leaq -0x90(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x15490
movq -0x2a0(%rbp), %rdi
leaq 0xa467(%rip), %rsi      # 0x296b3
callq 0x85b0
movb %al, -0x291(%rbp)
jmp 0x1f259
leaq -0x90(%rbp), %rdi
callq 0x3210
movb -0x291(%rbp), %al
testb $0x1, %al
jne 0x1f271
jmp 0x1f299
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1f299
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3210
jmp 0x20119
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x17390
movq %rax, %rdi
movl -0x38(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x173b0
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x15490
movq -0x2b0(%rbp), %rdi
leaq 0xa3d9(%rip), %rsi      # 0x296b3
callq 0x85b0
movb %al, -0x2a1(%rbp)
jmp 0x1f2e7
leaq -0xb0(%rbp), %rdi
callq 0x3210
movb -0x2a1(%rbp), %al
testb $0x1, %al
jne 0x1f2ff
jmp 0x1f327
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1f327
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3210
jmp 0x20119
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x17390
movq %rax, %rdi
movl -0x38(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x173b0
movq %rax, %rsi
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x15490
movq -0x2c0(%rbp), %rdi
leaq 0xa34b(%rip), %rsi      # 0x296b3
callq 0x85b0
movb %al, -0x2b1(%rbp)
jmp 0x1f375
leaq -0xd0(%rbp), %rdi
callq 0x3210
movb -0x2b1(%rbp), %al
testb $0x1, %al
jne 0x1f38d
jmp 0x1f3b5
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1f3b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x3210
jmp 0x20119
cmpl $0x2, -0x3c(%rbp)
jle 0x1f3c0
jmp 0x20110
jmp 0x1f3c2
movq -0x18(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x2c8(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x17390
movq %rax, %rdi
movslq -0x38(%rbp), %rsi
callq 0x173b0
movq -0x2c8(%rbp), %rdi
movq %rax, %rsi
callq 0x205a0
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x17390
movq %rax, %rdi
movslq -0x38(%rbp), %rsi
callq 0x173b0
movq %rax, %rdi
callq 0x20610
testb $0x1, %al
jne 0x1f420
jmp 0x1f428
movq -0x18(%rbp), %rax
movb $0x1, 0x50(%rax)
movl $0x0, -0xd8(%rbp)
movslq -0xd8(%rbp), %rax
movq %rax, -0x2d0(%rbp)
movq -0x30(%rbp), %rdi
callq 0x81f0
movq %rax, %rcx
movq -0x2d0(%rbp), %rax
cmpq %rcx, %rax
jae 0x1f48b
movq -0x30(%rbp), %rdi
movslq -0xd8(%rbp), %rsi
callq 0x8230
movq (%rax), %rax
cmpq -0x20(%rbp), %rax
jne 0x1f478
movb $0x1, -0xd1(%rbp)
jmp 0x1f47a
movl -0xd8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd8(%rbp)
jmp 0x1f432
testb $0x1, -0xd1(%rbp)
jne 0x1f4a1
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x28760
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movb $0x0, -0xf9(%rbp)
xorl %eax, %eax
cmpl $0x2, %ecx
movb %al, -0x2d1(%rbp)
jg 0x1f557
movq -0x28(%rbp), %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x17390
movq %rax, %rdi
movslq -0x38(%rbp), %rsi
callq 0x173b0
movq %rax, %rdi
callq 0x20630
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x2d1(%rbp)
jne 0x1f557
movq -0x28(%rbp), %rdi
movl -0x34(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x17390
movq %rax, %rdi
movslq -0x38(%rbp), %rsi
callq 0x173b0
movq %rax, %rsi
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x15490
movq -0x2e0(%rbp), %rdi
movb $0x1, -0xf9(%rbp)
leaq 0xa177(%rip), %rsi      # 0x296b3
callq 0x85b0
movb %al, -0x2d2(%rbp)
jmp 0x1f549
movb -0x2d2(%rbp), %al
movb %al, -0x2d1(%rbp)
jmp 0x1f557
movb -0x2d1(%rbp), %al
movb %al, -0x2e1(%rbp)
testb $0x1, -0xf9(%rbp)
jne 0x1f56e
jmp 0x1f57a
leaq -0xf8(%rbp), %rdi
callq 0x3210
movb -0x2e1(%rbp), %al
testb $0x1, %al
jne 0x1f589
jmp 0x1f626
movq -0x18(%rbp), %rax
movq %rax, -0x300(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x2f8(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x108(%rbp)
leaq -0x104(%rbp), %rdi
leaq -0x108(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x20450
movq -0x280(%rbp), %rdi
movq -0x300(%rbp), %rsi
movq -0x2f8(%rbp), %rdx
movq -0x2f0(%rbp), %rcx
movq -0x30(%rbp), %r9
movq -0x104(%rbp), %r8
callq 0x1f110
jmp 0x1f7bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
testb $0x1, -0xf9(%rbp)
jne 0x1f615
jmp 0x1f621
leaq -0xf8(%rbp), %rdi
callq 0x3210
jmp 0x20119
movl -0x34(%rbp), %eax
addl $0x1, %eax
cmpl $0x2, %eax
jle 0x1f7bb
movq -0x20(%rbp), %rdi
callq 0x20650
cmpq $0x0, %rax
je 0x1f7bb
movb $0x0, -0x109(%rbp)
movl $0x0, -0x110(%rbp)
movslq -0x110(%rbp), %rax
movq %rax, -0x308(%rbp)
movq -0x30(%rbp), %rdi
callq 0x81f0
movq %rax, %rcx
movq -0x308(%rbp), %rax
cmpq %rcx, %rax
jae 0x1f6cb
movq -0x30(%rbp), %rdi
movslq -0x110(%rbp), %rsi
callq 0x8230
movq (%rax), %rax
movq %rax, -0x310(%rbp)
movq -0x20(%rbp), %rdi
callq 0x20650
movq %rax, %rcx
movq -0x310(%rbp), %rax
cmpq %rcx, %rax
jne 0x1f6b8
movb $0x1, -0x109(%rbp)
jmp 0x1f6ba
movl -0x110(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x110(%rbp)
jmp 0x1f659
testb $0x1, -0x109(%rbp)
jne 0x1f7b9
movq -0x30(%rbp), %rax
movq %rax, -0x328(%rbp)
movq -0x20(%rbp), %rdi
callq 0x20650
movq -0x328(%rbp), %rdi
movq %rax, -0x118(%rbp)
leaq -0x118(%rbp), %rsi
callq 0x206a0
movq -0x20(%rbp), %rdi
callq 0x20650
movq %rax, %rsi
leaq -0x130(%rbp), %rdi
callq 0x206d0
movq -0x18(%rbp), %rax
movq %rax, -0x320(%rbp)
movq -0x20(%rbp), %rdi
callq 0x20650
movq %rax, -0x318(%rbp)
jmp 0x1f73b
movl -0x34(%rbp), %eax
addl $-0x2, %eax
movl %eax, -0x13c(%rbp)
leaq -0x138(%rbp), %rdi
leaq -0x13c(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x20450
jmp 0x1f760
movq -0x318(%rbp), %rdx
movq -0x320(%rbp), %rsi
movq -0x280(%rbp), %rdi
movq -0x30(%rbp), %r9
movq -0x138(%rbp), %r8
leaq -0x130(%rbp), %rcx
callq 0x1f110
jmp 0x1f78e
leaq -0x130(%rbp), %rdi
callq 0x20710
jmp 0x1f7b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x20710
jmp 0x20119
jmp 0x1f7bb
jmp 0x1f7bd
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movb $0x0, -0x161(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x329(%rbp)
jl 0x1f873
movq -0x28(%rbp), %rdi
movl -0x34(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x17390
movq %rax, %rdi
movslq -0x38(%rbp), %rsi
callq 0x173b0
movq %rax, %rdi
callq 0x20630
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x329(%rbp)
jne 0x1f873
movq -0x28(%rbp), %rdi
movl -0x34(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x17390
movq %rax, %rdi
movslq -0x38(%rbp), %rsi
callq 0x173b0
movq %rax, %rsi
leaq -0x160(%rbp), %rdi
movq %rdi, -0x338(%rbp)
callq 0x15490
movq -0x338(%rbp), %rdi
movb $0x1, -0x161(%rbp)
leaq 0x9e5b(%rip), %rsi      # 0x296b3
callq 0x85b0
movb %al, -0x32a(%rbp)
jmp 0x1f865
movb -0x32a(%rbp), %al
movb %al, -0x329(%rbp)
jmp 0x1f873
movb -0x329(%rbp), %al
movb %al, -0x339(%rbp)
testb $0x1, -0x161(%rbp)
jne 0x1f88a
jmp 0x1f896
leaq -0x160(%rbp), %rdi
callq 0x3210
movb -0x339(%rbp), %al
testb $0x1, %al
jne 0x1f8a5
jmp 0x1f942
movq -0x18(%rbp), %rax
movq %rax, -0x358(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x350(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x348(%rbp)
movl -0x34(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x170(%rbp)
leaq -0x16c(%rbp), %rdi
leaq -0x170(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x20450
movq -0x280(%rbp), %rdi
movq -0x358(%rbp), %rsi
movq -0x350(%rbp), %rdx
movq -0x348(%rbp), %rcx
movq -0x30(%rbp), %r9
movq -0x16c(%rbp), %r8
callq 0x1f110
jmp 0x1fad9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
testb $0x1, -0x161(%rbp)
jne 0x1f931
jmp 0x1f93d
leaq -0x160(%rbp), %rdi
callq 0x3210
jmp 0x20119
movl -0x34(%rbp), %eax
subl $0x1, %eax
cmpl $0x0, %eax
jge 0x1fad7
movq -0x20(%rbp), %rdi
callq 0x20770
cmpq $0x0, %rax
je 0x1fad7
movb $0x0, -0x171(%rbp)
movl $0x0, -0x178(%rbp)
movslq -0x178(%rbp), %rax
movq %rax, -0x360(%rbp)
movq -0x30(%rbp), %rdi
callq 0x81f0
movq %rax, %rcx
movq -0x360(%rbp), %rax
cmpq %rcx, %rax
jae 0x1f9e7
movq -0x30(%rbp), %rdi
movslq -0x178(%rbp), %rsi
callq 0x8230
movq (%rax), %rax
movq %rax, -0x368(%rbp)
movq -0x20(%rbp), %rdi
callq 0x20770
movq %rax, %rcx
movq -0x368(%rbp), %rax
cmpq %rcx, %rax
jne 0x1f9d4
movb $0x1, -0x171(%rbp)
jmp 0x1f9d6
movl -0x178(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x178(%rbp)
jmp 0x1f975
testb $0x1, -0x171(%rbp)
jne 0x1fad5
movq -0x30(%rbp), %rax
movq %rax, -0x380(%rbp)
movq -0x20(%rbp), %rdi
callq 0x20770
movq -0x380(%rbp), %rdi
movq %rax, -0x180(%rbp)
leaq -0x180(%rbp), %rsi
callq 0x206a0
movq -0x20(%rbp), %rdi
callq 0x20770
movq %rax, %rsi
leaq -0x198(%rbp), %rdi
callq 0x206d0
movq -0x18(%rbp), %rax
movq %rax, -0x378(%rbp)
movq -0x20(%rbp), %rdi
callq 0x20770
movq %rax, -0x370(%rbp)
jmp 0x1fa57
movl -0x34(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x1a4(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq -0x1a4(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x20450
jmp 0x1fa7c
movq -0x370(%rbp), %rdx
movq -0x378(%rbp), %rsi
movq -0x280(%rbp), %rdi
movq -0x30(%rbp), %r9
movq -0x1a0(%rbp), %r8
leaq -0x198(%rbp), %rcx
callq 0x1f110
jmp 0x1faaa
leaq -0x198(%rbp), %rdi
callq 0x20710
jmp 0x1fad5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x20710
jmp 0x20119
jmp 0x1fad7
jmp 0x1fad9
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movb $0x0, -0x1c9(%rbp)
xorl %eax, %eax
cmpl $0x2, %ecx
movb %al, -0x381(%rbp)
jg 0x1fb8f
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x17390
movq %rax, %rdi
movl -0x38(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x173b0
movq %rax, %rdi
callq 0x20630
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x381(%rbp)
jne 0x1fb8f
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x17390
movq %rax, %rdi
movl -0x38(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x173b0
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
movq %rdi, -0x390(%rbp)
callq 0x15490
movq -0x390(%rbp), %rdi
movb $0x1, -0x1c9(%rbp)
leaq 0x9b3f(%rip), %rsi      # 0x296b3
callq 0x85b0
movb %al, -0x382(%rbp)
jmp 0x1fb81
movb -0x382(%rbp), %al
movb %al, -0x381(%rbp)
jmp 0x1fb8f
movb -0x381(%rbp), %al
movb %al, -0x391(%rbp)
testb $0x1, -0x1c9(%rbp)
jne 0x1fba6
jmp 0x1fbb2
leaq -0x1c8(%rbp), %rdi
callq 0x3210
movb -0x391(%rbp), %al
testb $0x1, %al
jne 0x1fbc1
jmp 0x1fc5e
movq -0x18(%rbp), %rax
movq %rax, -0x3b0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x3a8(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x3a0(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d8(%rbp)
leaq -0x1d4(%rbp), %rdi
leaq -0x34(%rbp), %rsi
leaq -0x1d8(%rbp), %rdx
callq 0x20480
movq -0x280(%rbp), %rdi
movq -0x3b0(%rbp), %rsi
movq -0x3a8(%rbp), %rdx
movq -0x3a0(%rbp), %rcx
movq -0x30(%rbp), %r9
movq -0x1d4(%rbp), %r8
callq 0x1f110
jmp 0x1fdf5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
testb $0x1, -0x1c9(%rbp)
jne 0x1fc4d
jmp 0x1fc59
leaq -0x1c8(%rbp), %rdi
callq 0x3210
jmp 0x20119
movl -0x38(%rbp), %eax
addl $0x1, %eax
cmpl $0x2, %eax
jle 0x1fdf3
movq -0x20(%rbp), %rdi
callq 0x207c0
cmpq $0x0, %rax
je 0x1fdf3
movb $0x0, -0x1d9(%rbp)
movl $0x0, -0x1e0(%rbp)
movslq -0x1e0(%rbp), %rax
movq %rax, -0x3b8(%rbp)
movq -0x30(%rbp), %rdi
callq 0x81f0
movq %rax, %rcx
movq -0x3b8(%rbp), %rax
cmpq %rcx, %rax
jae 0x1fd03
movq -0x30(%rbp), %rdi
movslq -0x1e0(%rbp), %rsi
callq 0x8230
movq (%rax), %rax
movq %rax, -0x3c0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x207c0
movq %rax, %rcx
movq -0x3c0(%rbp), %rax
cmpq %rcx, %rax
jne 0x1fcf0
movb $0x1, -0x1d9(%rbp)
jmp 0x1fcf2
movl -0x1e0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e0(%rbp)
jmp 0x1fc91
testb $0x1, -0x1d9(%rbp)
jne 0x1fdf1
movq -0x30(%rbp), %rax
movq %rax, -0x3d8(%rbp)
movq -0x20(%rbp), %rdi
callq 0x207c0
movq -0x3d8(%rbp), %rdi
movq %rax, -0x1e8(%rbp)
leaq -0x1e8(%rbp), %rsi
callq 0x206a0
movq -0x20(%rbp), %rdi
callq 0x207c0
movq %rax, %rsi
leaq -0x200(%rbp), %rdi
callq 0x206d0
movq -0x18(%rbp), %rax
movq %rax, -0x3d0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x207c0
movq %rax, -0x3c8(%rbp)
jmp 0x1fd73
movl -0x38(%rbp), %eax
addl $-0x2, %eax
movl %eax, -0x20c(%rbp)
leaq -0x208(%rbp), %rdi
leaq -0x34(%rbp), %rsi
leaq -0x20c(%rbp), %rdx
callq 0x20480
jmp 0x1fd98
movq -0x3c8(%rbp), %rdx
movq -0x3d0(%rbp), %rsi
movq -0x280(%rbp), %rdi
movq -0x30(%rbp), %r9
movq -0x208(%rbp), %r8
leaq -0x200(%rbp), %rcx
callq 0x1f110
jmp 0x1fdc6
leaq -0x200(%rbp), %rdi
callq 0x20710
jmp 0x1fdf1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x20710
jmp 0x20119
jmp 0x1fdf3
jmp 0x1fdf5
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movb $0x0, -0x231(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x3d9(%rbp)
jl 0x1feab
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x17390
movq %rax, %rdi
movl -0x38(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x173b0
movq %rax, %rdi
callq 0x20630
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x3d9(%rbp)
jne 0x1feab
movq -0x28(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x17390
movq %rax, %rdi
movl -0x38(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x173b0
movq %rax, %rsi
leaq -0x230(%rbp), %rdi
movq %rdi, -0x3e8(%rbp)
callq 0x15490
movq -0x3e8(%rbp), %rdi
movb $0x1, -0x231(%rbp)
leaq 0x9823(%rip), %rsi      # 0x296b3
callq 0x85b0
movb %al, -0x3da(%rbp)
jmp 0x1fe9d
movb -0x3da(%rbp), %al
movb %al, -0x3d9(%rbp)
jmp 0x1feab
movb -0x3d9(%rbp), %al
movb %al, -0x3e9(%rbp)
testb $0x1, -0x231(%rbp)
jne 0x1fec2
jmp 0x1fece
leaq -0x230(%rbp), %rdi
callq 0x3210
movb -0x3e9(%rbp), %al
testb $0x1, %al
jne 0x1fedd
jmp 0x1ff7a
movq -0x18(%rbp), %rax
movq %rax, -0x408(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x400(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x3f8(%rbp)
movl -0x38(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x240(%rbp)
leaq -0x23c(%rbp), %rdi
leaq -0x34(%rbp), %rsi
leaq -0x240(%rbp), %rdx
callq 0x20480
movq -0x280(%rbp), %rdi
movq -0x408(%rbp), %rsi
movq -0x400(%rbp), %rdx
movq -0x3f8(%rbp), %rcx
movq -0x30(%rbp), %r9
movq -0x23c(%rbp), %r8
callq 0x1f110
jmp 0x2010e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
testb $0x1, -0x231(%rbp)
jne 0x1ff69
jmp 0x1ff75
leaq -0x230(%rbp), %rdi
callq 0x3210
jmp 0x20119
movl -0x38(%rbp), %eax
subl $0x1, %eax
cmpl $0x0, %eax
jge 0x2010c
movq -0x20(%rbp), %rdi
callq 0x20810
cmpq $0x0, %rax
je 0x2010c
movb $0x0, -0x241(%rbp)
movl $0x0, -0x248(%rbp)
movslq -0x248(%rbp), %rax
movq %rax, -0x410(%rbp)
movq -0x30(%rbp), %rdi
callq 0x81f0
movq %rax, %rcx
movq -0x410(%rbp), %rax
cmpq %rcx, %rax
jae 0x2001f
movq -0x30(%rbp), %rdi
movslq -0x248(%rbp), %rsi
callq 0x8230
movq (%rax), %rax
movq %rax, -0x418(%rbp)
movq -0x20(%rbp), %rdi
callq 0x20810
movq %rax, %rcx
movq -0x418(%rbp), %rax
cmpq %rcx, %rax
jne 0x2000c
movb $0x1, -0x241(%rbp)
jmp 0x2000e
movl -0x248(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x248(%rbp)
jmp 0x1ffad
testb $0x1, -0x241(%rbp)
jne 0x2010a
movq -0x30(%rbp), %rax
movq %rax, -0x430(%rbp)
movq -0x20(%rbp), %rdi
callq 0x20810
movq -0x430(%rbp), %rdi
movq %rax, -0x250(%rbp)
leaq -0x250(%rbp), %rsi
callq 0x206a0
movq -0x20(%rbp), %rdi
callq 0x20810
movq %rax, %rsi
leaq -0x268(%rbp), %rdi
callq 0x206d0
movq -0x18(%rbp), %rax
movq %rax, -0x428(%rbp)
movq -0x20(%rbp), %rdi
callq 0x20810
movq %rax, -0x420(%rbp)
jmp 0x2008f
movl -0x38(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x274(%rbp)
leaq -0x270(%rbp), %rdi
leaq -0x34(%rbp), %rsi
leaq -0x274(%rbp), %rdx
callq 0x20480
jmp 0x200b4
movq -0x420(%rbp), %rdx
movq -0x428(%rbp), %rsi
movq -0x280(%rbp), %rdi
movq -0x30(%rbp), %r9
movq -0x270(%rbp), %r8
leaq -0x268(%rbp), %rcx
callq 0x1f110
jmp 0x200e2
leaq -0x268(%rbp), %rdi
callq 0x20710
jmp 0x2010a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x20710
jmp 0x20119
jmp 0x2010c
jmp 0x2010e
jmp 0x20110
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x34f0
nopw %cs:(%rax,%rax)
nopl (%rax)