// File: /workspace/github_cpp_makefile_star2_O1/Alcaro[P]bridges/generate.cpp
// Function: (anonymous namespace)::loc_generator::generate_one(unsigned long)
void generate_one(uint64_t seed)
{
	rand.seed(seed);
	
	map.width = par.width;
	map.height = par.height;
	map.numislands = 0;
	
	for (int y=0;y<map.height;y++)
	for (int x=0;x<map.width;x++)
	{
		gamemap::island& here = map.map[y][x];
		
		here.population = -1;
		here.totbridges = 0;
		here.rootnode = y*100+x;
		
		here.bridgelen[0] = -1;
		here.bridgelen[1] = -1;
		here.bridgelen[2] = -1;
		here.bridgelen[3] = -1;
		
		here.bridges[0] = 0;
		here.bridges[1] = 0;
		here.bridges[2] = 0;
		here.bridges[3] = 0;
		
		map.towalk[y*100+x] = 0;
	}
	
	map.an_island[1] = -1;
	map.an_island[2] = -1;
	map.an_island[3] = -1;
	map.an_island[4] = -1;
	
	if (!par.use_castle)
	{
		int startx = rand(par.width);
		int starty = rand(par.height);
		map.an_island[0] = starty*100 + startx;
		add_island_sub(startx, starty, starty*100+startx, false, 3);
		
		map.has_castles = false;
	}
	int ncastle = 0;
	int ncastleeach = 1;
	if (par.use_castle)
	{
		ncastle = rand(3) + 2;
		uint8_t colors[4] = {80,81,82,83};
		for (int i=4;i>0;i--)
		{
			int a = i-1;
			int b = rand(i);
			
			uint8_t tmp = colors[a];
			colors[a] = colors[b];
			colors[b] = tmp;
		}
		
		map.has_castles = true;
		
		//minimum sizes with 2 castles, such that there's always a place to put the last castle,
		// no matter where the first ones ended up, even with dense false:
		//2x? - 2x7
		//3x? - 3x7
		//4x? - 4x7
		//5x? - 5x5
		//6x? - 6x5
		//
		//minimum sizes with 3 castles:
		//2x? - 2x12
		//3x? - 3x12
		//4x? - 4x12
		//5x? - 5x9
		//6x? - 6x8
		//7x? - 7x7
		//
		//minimum sizes with 4 castles:
		//2x? - 2x17
		//3x? - 3x17
		//4x? - 4x17
		//5x? - 5x13
		//6x? - 6x11
		//7x? - 7x7
		
		//-> allow 3 or 4 castles on 7x7 maps, but anything smaller gets 2
		if (par.width < 7 || par.height < 7) ncastle = 2;
		if (par.width < 3 || par.height < 3) ncastle = 1; // tiny maps get only one castle
		if (par.width < 5 && par.height < 5) ncastle = 1;
		
		
		for (int i=0;i<ncastle;i++)
		{
			while (true)
			{
				int x = rand(par.width-1);
				int y = rand(par.height-1);
				
				if (map.towalk[y*100+x    ] <= 1 &&
				    map.towalk[y*100+x+  1] <= 1 &&
				    map.towalk[y*100+x+100] <= 1 &&
				    map.towalk[y*100+x+101] <= 1)
				{
					add_island_sub(x,   y,   y*100+x, false, colors[i]);
					add_island_sub(x+1, y,   y*100+x, false, colors[i]);
					add_island_sub(x,   y+1, y*100+x, false, colors[i]);
					add_island_sub(x+1, y+1, y*100+x, false, colors[i]);
					
					map.map[y][x].population = colors[i];
					map.towalk[y*100+x] = colors[i];
					
					map.an_island[0] = y*100 + x;
					map.an_island[colors[i]-80+1] = y*100 + x;
					
					break;
				}
			}
		}
	}
	
	if (par.use_reef)
	{
		for (int y=0;y<map.height;y++)
		for (int x=0;x<map.width;x++)
		{
			if (rand(100) > 3) continue;
			if (map.towalk[y*100+x] >= 3) continue;
			
			map.towalk[y*100+x] = 3;
			map.map[y][x].population = -2;
		}
	}
	
	int totislands = par.width*par.height*par.density;
	totislands = totislands * (rand(100)+50) / 100; // multiply by 50%..150%
	//make sure it doesn't loop forever saying "here's a map with density 0" "don't give me maps with only one island!"
	if (totislands < 4) totislands = 4;
	while (map.numislands < totislands)
	{
		//packed index - equal to y*width+x, as opposed to normal index (y*100+x)
		int pidx_start = rand(par.width*par.height);
		int pidx_skip = rand_coprime(par.width*par.height);
		
		int pidx = pidx_start;
		
		while (true)
		{
			uint16_t y = pidx / par.width;
			uint16_t x = pidx % par.width;
			
			if (try_add_island(x, y)) break;
			else if (map.towalk[y*100+x] == 1) map.towalk[y*100+x] = 0;
			
			pidx = (pidx+pidx_skip) % (par.width*par.height);
			if (pidx == pidx_start) goto done; // all possibilities taken already?
		}
		
		//try to create more castles
		if (par.use_castle && ncastle*ncastleeach <= 4)
		{
//puts(".");
			uint16_t numoptions[4] = { 0,0,0,0 };
			uint16_t newcastle[4];
			uint16_t newroot[4];
			
			for (int y=0;y<par.height-1;y++)
			for (int x=0;x<par.width-1;x++)
			{
				//if
				//- at least one tile is island
				//- all four tiles are available (towalk < 3, or rootnode same)
				//   (towalk=2 is always true somewhere unless the island initially was a 2x2,
				//     which is a pointless restriction, so it must be allowed)
				//- none of the eight surrounding tiles has the same root node
				//- allow_ambiguous is true, or this one is not beside a castle of the same color
				//then a castle can be placed here
				
				uint16_t index = y*100+x;
				
				//- at least one tile is island
				uint16_t root = -1;
				if (map.get(index    ).population >= 0) root = index    ;
				if (map.get(index+  1).population >= 0) root = index+  1;
				if (map.get(index+100).population >= 0) root = index+100;
				if (map.get(index+101).population >= 0) root = index+101;
				
				if (root == (uint16_t)-1) continue;
				root = map.get(root).rootnode;
				if (map.get(root).population >= 80) continue;
				
				//- all four tiles are available (towalk < 3)
				if (map.towalk[index    ] >= 3 && map.get(index    ).rootnode != root) continue;
				if (map.towalk[index+  1] >= 3 && map.get(index+  1).rootnode != root) continue;
				if (map.towalk[index+100] >= 3 && map.get(index+100).rootnode != root) continue;
				if (map.towalk[index+101] >= 3 && map.get(index+101).rootnode != root) continue;
				
				//- all four tiles are available (rootnode same)
				if (map.get(index    ).population >= 0 && map.get(index    ).rootnode != root) continue;
				if (map.get(index+  1).population >= 0 && map.get(index+  1).rootnode != root) continue;
				if (map.get(index+100).population >= 0 && map.get(index+100).rootnode != root) continue;
				if (map.get(index+101).population >= 0 && map.get(index+101).rootnode != root) continue;
				
				//- none of the eight surrounding tiles has the same root node
				if (x > 0 && map.get(index    -1).population >= 0 && map.get(index    -1).rootnode == root) continue;
				if (x > 0 && map.get(index+100-1).population >= 0 && map.get(index+100-1).rootnode == root) continue;
				if (y > 0 && map.get(index-100  ).population >= 0 && map.get(index-100  ).rootnode == root) continue;
				if (y > 0 && map.get(index-100+1).population >= 0 && map.get(index-100+1).rootnode == root) continue;
				
				//- none of the eight surrounding tiles has the same root node
				if (x < map.width-1  && map.get(index+  2).population >= 0 && map.get(index+  2).rootnode == root) continue;
				if (x < map.width-1  && map.get(index+102).population >= 0 && map.get(index+102).rootnode == root) continue;
				if (y < map.height-1 && map.get(index+200).population >= 0 && map.get(index+200).rootnode == root) continue;
				if (y < map.height-1 && map.get(index+201).population >= 0 && map.get(index+201).rootnode == root) continue;
				
				//- allow_ambiguous is true, or this one is not beside a castle of the same color
				//(TODO: allow, but force zero bridges that way)
				if (!par.allow_ambiguous)
				{
					for (int tile=0;tile<4;tile++)
					{
						static const int8_t tilepos[] = { 0, 1, 100, 101 };
						uint16_t lindex = index + tilepos[tile];
						
						static const int8_t diroff[] = { 1, -100, -1, 100 };
						for (int dir=0;dir<4;dir++)
						{
							int8_t bridgelen = map.get(lindex).bridgelen[dir];
							if (bridgelen == -1) continue;
							
							uint16_t newindex = lindex + bridgelen*diroff[dir];
							//printf("%.4X\n",newindex);
							if (map.get(newindex).population == map.towalk[root]) goto has_castle_link;
						}
					}
				}
				if (false) { has_castle_link: continue; }
				
				uint16_t color = map.towalk[root];
//printf("CASTLEVALID[%i]:%.3i,%.3i\n",color,root,index);
				if (rand(++numoptions[color-80]) != 0) continue;
				
				newcastle[color-80] = index;
				newroot[color-80] = root;
			}
			
			if (!!numoptions[0] + !!numoptions[1] + !!numoptions[2] + !!numoptions[3] == ncastle)
			{
				//make sure the new islands don't overlap
				for (int i=0;i<4;i++)
				{
					for (int j=0;j<4;j++)
					{
						if (numoptions[i] == 0) continue;
						if (numoptions[j] == 0) continue;
						
						uint16_t pos1 = newcastle[i];
						uint16_t pos2 = newcastle[j];
						
						if (pos1 == pos2 + 001) goto skip_new_castles;
						if (pos1 == pos2 + 101) goto skip_new_castles;
						if (pos1 == pos2 + 100) goto skip_new_castles;
						if (pos1 == pos2 +  99) goto skip_new_castles;
						//these four checks are enough; if they overlap in other directions, it'll be one of those for the other one
						//equal position is impossible, it'd cause unauthorized overlaps
					}
				}
				
				ncastleeach++;
				for (int i=0;i<4;i++)
				{
					uint16_t pos = newcastle[i];
//printf("CASTLE[%i]=%.3i\n",i,pos);
					if (numoptions[i] == 0) continue;
					
					map.towalk[pos    ] = 80+i; // preallocate these so it won't try to build bridges across them
					map.towalk[pos+  1] = 80+i;
					map.towalk[pos+100] = 80+i;
					map.towalk[pos+101] = 80+i;
				}
				for (int i=0;i<4;i++)
				{
					uint16_t pos = newcastle[i];
					if (numoptions[i] == 0) continue;
					
					if (map.get(pos    ).population < 0) add_island_sub(pos%100  , pos/100  , newroot[i], false, 80+i);
					if (map.get(pos+  1).population < 0) add_island_sub(pos%100+1, pos/100  , newroot[i], false, 80+i);
					if (map.get(pos+100).population < 0) add_island_sub(pos%100  , pos/100+1, newroot[i], false, 80+i);
					if (map.get(pos+101).population < 0) add_island_sub(pos%100+1, pos/100+1, newroot[i], false, 80+i);
					
					map.get(newroot[i]).population = 80+i;
				}
			skip_new_castles: ;
			}
//puts(".");
		}
//for (int y=0;y<map.height;y++)
//for (int x=0;x<map.width;x++)
//{
//if(y&&!x)puts("");
//printf("%i",map.towalk[y*100+x]%(80-6));
//}
//puts("\n");
//for (int y=0;y<map.height;y++)
//for (int x=0;x<map.width;x++)
//{
//if(y&&!x)puts("");
//char ch=map.map[y][x].population;
//if(0);
//else if(ch<0)ch='?';
//else if(ch<10)ch='0'+ch;
//else if(ch<20)ch='A'+ch-10;
//else ch="rbyg"[ch-80];
//printf("%c",ch);
//}
//puts("\n\n");
	}
done: ;
	
	//to ensure large islands' roots are not at bottom right, and its location is not a clue:
	//- set towalk on each island to point to itself
	//- for every tile, swap towalk with its root; this creates linked lists
	//- for each large island, pick a random valid root, then use it
	for (int y=0;y<map.height;y++)
	for (int x=0;x<map.width;x++)
	{
		map.towalk[y*100+x] = y*100+x;
	}
	
	for (int y=0;y<map.height;y++)
	for (int x=0;x<map.width;x++)
	{
		gamemap::island& here = map.map[y][x];
		if (here.population < 0) continue;
		
		uint16_t swap = map.towalk[y*100+x];
		map.towalk[y*100+x] = map.towalk[here.rootnode];
		map.towalk[here.rootnode] = swap;
		
		//also repair bridgelen, bridges==3, non-root population, and bridge counts for oceans
		here.population = map.get(here.rootnode).population;
		here.totbridges = (here.population < 80 ? here.population : 16); // the exact number doesn't matter
		
		for (int x2=x-1;x2>=0;x2--)
		{
			if (map.map[y][x2].population != -1)
			{
				if (map.map[y][x2].population == -2) break;
				
				here.bridgelen[2] = x-x2;
				map.map[y][x2].bridgelen[0] = x-x2;
				for (int x3=x2+1;x3<x;x3++)
				{
					map.map[y][x3].bridgelen[0] = x-x3;
					map.map[y][x3].bridgelen[2] = x3-x2;
					map.map[y][x3].bridges[0] = here.bridges[2];
					map.map[y][x3].bridges[2] = here.bridges[2];
				}
				
				if (map.map[y][x2].rootnode == here.rootnode && x-x2==1)
				{
					here.bridges[2] = 3;
					map.map[y][x2].bridges[0] = 3;
				}
				
				break;
			}
		}
		for (int y2=y-1;y2>=0;y2--)
		{
			if (map.map[y2][x].population != -1)
			{
				if (map.map[y2][x].population == -2) break;
				
				here.bridgelen[1] = y-y2;
				map.map[y2][x].bridgelen[3] = y-y2;
				for (int y3=y2+1;y3<y;y3++)
				{
					map.map[y3][x].bridgelen[1] = y3-y2;
					map.map[y3][x].bridgelen[3] = y-y3;
					map.map[y3][x].bridges[1] = here.bridges[1];
					map.map[y3][x].bridges[3] = here.bridges[1];
				}
				
				if (map.map[y2][x].rootnode == here.rootnode && y-y2==1)
				{
					here.bridges[1] = 3;
					map.map[y2][x].bridges[3] = 3;
				}
				
				break;
			}
		}
	}
	
	for (int y=0;y<map.height;y++)
	for (int x=0;x<map.width;x++)
	{
		int idx = y*100+x;
		if (map.map[y][x].population < 0) continue;  // ignore oceans
		if (map.towalk[idx]==idx) continue;          // ignore small islands
		// I could ignore non-roots, but then I'd rerandomize the root if it moved down. I'd rather not bias it.
		// TODO: examine whether there's some interesting mathematical property on anything in towalk,
		//  for example if the linked lists are strictly increasing except when it loops back to the lowest
		//if (map.map[y][x].rootnode != idx) continue;
		
		int newroot = -1; // a valid root is known to exist, but gcc won't realize that
		int nroots = 0;
		do {
			gamemap::island& here = map.get(idx);
			
			bool valid_root = false;
			
			if (here.population >= 80)
			{
				//castles are always on a 2x2, so this always works, even if it doesn't check that bottom-right is connected
				valid_root = (here.bridges[0]==3 && here.bridges[3]==3);
			}
			else
			{
				valid_root = (here.bridges[0]==3 || here.bridges[3]==3);
			}
			
			if (valid_root)
			{
				nroots++;
				if (rand(nroots) == 0) newroot = idx;
			}
			idx = map.towalk[idx];
		} while (idx != y*100+x);
		
		do {
			map.get(idx).rootnode = newroot;
			idx = map.towalk[idx];
		} while (idx != y*100+x);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
leaq 0x10(%rdi), %r13
movq %rsi, 0x10(%rdi)
movq %r13, %rdi
callq 0x165a4
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movzbl (%rcx), %edx
movl %edx, (%rax)
movzbl 0x1(%rcx), %ecx
movl %ecx, 0x4(%rax)
movl $0x0, 0x8(%rax)
movq (%rbx), %rdi
cmpl $0x0, 0x4(%rdi)
jle 0x23e17
movl $0x6, %eax
xorl %ecx, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %esi, %esi
movq (%rbx), %rdi
cmpl $0x0, (%rdi)
jle 0x23dfe
movq %rax, %r8
movq %rcx, %r9
xorl %r10d, %r10d
movw $0xff, (%rdi,%r8,2)
movw %r9w, 0x2(%rdi,%r8,2)
movq %rdx, 0x4(%rdi,%r8,2)
movq (%rbx), %rdi
movw $0x0, 0x1fbe8(%rdi,%r9,2)
incq %r10
movslq (%rdi), %r11
incq %r9
addq $0x6, %r8
cmpq %r11, %r10
jl 0x23dcc
incq %rsi
movq (%rbx), %rdi
movslq 0x4(%rdi), %r8
addq $0x64, %rcx
addq $0x258, %rax            # imm = 0x258
cmpq %r8, %rsi
jl 0x23dbb
movq $-0x1, 0x1d4d0(%rdi)
movq 0x8(%rbx), %rax
cmpb $0x0, 0xb(%rax)
jne 0x23e7a
movzbl (%rax), %esi
movq %r13, %rdi
callq 0x166c8
movl %eax, %ebp
movq 0x8(%rbx), %rax
movzbl 0x1(%rax), %esi
movq %r13, %rdi
callq 0x166c8
imull $0x64, %eax, %ecx
addl %ebp, %ecx
movq (%rbx), %rdx
movw %cx, 0x1d4ce(%rdx)
movzwl %cx, %ecx
movq %rbx, %rdi
movl %ebp, %esi
movl %eax, %edx
xorl %r8d, %r8d
movl $0x3, %r9d
callq 0x254ea
movq (%rbx), %rax
movb $0x0, 0x1d4cc(%rax)
movq 0x8(%rbx), %rax
movl $0x0, 0x58(%rsp)
cmpb $0x1, 0xb(%rax)
movq %r13, 0x40(%rsp)
jne 0x24063
movq %r13, %rdi
movl $0x3, %esi
callq 0x166c8
movl %eax, %ebp
movl $0x53525150, 0x30(%rsp) # imm = 0x53525150
movl $0x5, %r14d
leaq -0x1(%r14), %r15
movq %r13, %rdi
movl %r15d, %esi
callq 0x166c8
movb 0x2e(%rsp,%r14), %cl
cltq
movb 0x30(%rsp,%rax), %dl
movb %dl, 0x2e(%rsp,%r14)
movb %cl, 0x30(%rsp,%rax)
movq %r15, %r14
cmpq $0x1, %r15
ja 0x23eb2
movq (%rbx), %rax
movb $0x1, 0x1d4cc(%rax)
movq 0x8(%rbx), %rax
movb (%rax), %cl
cmpb $0x7, %cl
jb 0x23ef9
cmpb $0x6, 0x1(%rax)
ja 0x23f00
movl $0x2, %ebp
jmp 0x23f03
addl $0x2, %ebp
cmpb $0x3, %cl
jb 0x23f0e
cmpb $0x2, 0x1(%rax)
ja 0x23f13
movl $0x1, %ebp
cmpb $0x4, %cl
ja 0x23f24
cmpb $0x5, 0x1(%rax)
movl $0x1, %eax
cmovbl %eax, %ebp
movl %ebp, 0x58(%rsp)
testl %ebp, %ebp
jle 0x24063
movl 0x58(%rsp), %eax
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
movq 0x8(%rbx), %rax
movzbl (%rax), %esi
decl %esi
movq %r13, %rdi
callq 0x166c8
movl %eax, %r15d
movq 0x8(%rbx), %rax
movzbl 0x1(%rax), %esi
decl %esi
movq %r13, %rdi
callq 0x166c8
movl %eax, %r12d
movq (%rbx), %rax
imull $0x64, %r12d, %ecx
addl %r15d, %ecx
movslq %ecx, %r14
cmpw $0x1, 0x1fbe8(%rax,%r14,2)
jg 0x23f3b
cmpw $0x1, 0x1fbea(%rax,%r14,2)
jg 0x23f3b
cmpw $0x1, 0x1fcb0(%rax,%r14,2)
jg 0x23f3b
cmpw $0x1, 0x1fcb2(%rax,%r14,2)
jg 0x23f3b
movzbl 0x30(%rsp,%rbp), %r13d
movq %rbp, 0x28(%rsp)
movzwl %r14w, %ebp
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
movl %r13d, %r9d
callq 0x254ea
leal 0x1(%r15), %esi
movl %esi, 0x18(%rsp)
movq %rbx, %rdi
movl %r12d, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
movl %r13d, %r9d
callq 0x254ea
leal 0x1(%r12), %edx
movl %edx, 0x48(%rsp)
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %ecx
xorl %r8d, %r8d
movl %r13d, %r9d
callq 0x254ea
movq %rbx, %rdi
movl 0x18(%rsp), %esi
movl 0x48(%rsp), %edx
movl %ebp, %ecx
movq 0x28(%rsp), %rbp
xorl %r8d, %r8d
movl %r13d, %r9d
callq 0x254ea
movq (%rbx), %rax
movslq %r12d, %rcx
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rax, %rcx
movslq %r15d, %rdx
leaq (%rdx,%rdx,2), %rdx
movb %r13b, 0xc(%rcx,%rdx,4)
movw %r13w, 0x1fbe8(%rax,%r14,2)
movw %r14w, 0x1d4ce(%rax)
movw %r14w, 0x1d430(%rax,%r13,2)
movq 0x40(%rsp), %r13
incq %rbp
cmpq 0x8(%rsp), %rbp
jne 0x23f3b
movq 0x8(%rbx), %rax
cmpb $0x1, 0x9(%rax)
jne 0x240f2
movq (%rbx), %rax
cmpl $0x0, 0x4(%rax)
jle 0x240f2
movl $0x1fbe8, %r14d         # imm = 0x1FBE8
movl $0xc, %r15d
xorl %r12d, %r12d
movq (%rbx), %rax
cmpl $0x0, (%rax)
jle 0x240d5
movq %r15, %r13
xorl %ebp, %ebp
movq 0x40(%rsp), %rdi
movl $0x64, %esi
callq 0x166c8
cmpl $0x3, %eax
ja 0x240c3
movq (%rbx), %rax
leaq (%rax,%r14), %rcx
cmpw $0x2, (%rcx,%rbp,2)
jg 0x240c3
movw $0x3, (%rcx,%rbp,2)
movb $-0x2, (%rax,%r13)
incq %rbp
movq (%rbx), %rax
movslq (%rax), %rax
addq $0xc, %r13
cmpq %rax, %rbp
jl 0x24096
incq %r12
movq (%rbx), %rax
movslq 0x4(%rax), %rax
addq $0xc8, %r14
addq $0x4b0, %r15            # imm = 0x4B0
cmpq %rax, %r12
jl 0x24089
movq 0x8(%rbx), %rax
movzbl (%rax), %ecx
movzbl 0x1(%rax), %edx
imull %ecx, %edx
cvtsi2ss %edx, %xmm0
mulss 0x4(%rax), %xmm0
cvttss2si %xmm0, %ebp
movq 0x40(%rsp), %r14
movq %r14, %rdi
movl $0x64, %esi
callq 0x166c8
addl $0x32, %eax
imull %ebp, %eax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
shrq $0x25, %rax
cmpl $0x5, %eax
movl $0x4, %ecx
cmovael %eax, %ecx
movl %ecx, 0x8c(%rsp)
movl $0x1, 0x6c(%rsp)
movq %rbx, 0x90(%rsp)
movq (%rbx), %rax
movl 0x8c(%rsp), %ecx
cmpl %ecx, 0x8(%rax)
jge 0x24e5e
movq 0x8(%rbx), %rax
movzbl (%rax), %ecx
movzbl 0x1(%rax), %esi
imull %ecx, %esi
movq %r14, %rdi
callq 0x166c8
movl %eax, 0x18(%rsp)
movq 0x8(%rbx), %rax
movzbl (%rax), %ecx
movzbl 0x1(%rax), %r15d
imull %ecx, %r15d
leal -0x1(%r15), %esi
movq %r14, %rdi
callq 0x166c8
movl %eax, %r13d
incl %r13d
movl %r13d, %edi
movl %r15d, %esi
callq 0x25d4e
movl %eax, %ecx
movl %r13d, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %r13d
cmpl $0x1, %ecx
ja 0x241a1
movl 0x18(%rsp), %edi
movl $0xffff, %r14d          # imm = 0xFFFF
movq (%rbx), %rcx
movq 0x8(%rbx), %rax
movzbl (%rax), %esi
movl %edi, %eax
cltd
idivl %esi
movl %eax, %ebp
movl %edx, %r15d
andl %r14d, %r15d
andl %r14d, %ebp
imull $0x64, %ebp, %r12d
addl %r15d, %r12d
movl %r12d, %eax
andl %r14d, %eax
cmpw $0x1, 0x1fbe8(%rcx,%rax,2)
jne 0x24436
movl %edi, 0x28(%rsp)
movw $0xffff, 0x30(%rsp)     # imm = 0xFFFF
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %edx
xorl %ecx, %ecx
leaq 0x30(%rsp), %r8
callq 0x258d2
testw %ax, %ax
je 0x242c8
movw %ax, 0x48(%rsp)
movzwl %r12w, %ecx
movzwl 0x30(%rsp), %r9d
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %edx
movl %ecx, 0x10(%rsp)
movl $0x1, %r8d
movl %r9d, 0x8(%rsp)
callq 0x254ea
movq 0x8(%rbx), %rax
cmpb $0x1, 0xa(%rax)
jne 0x24425
movq 0x40(%rsp), %rdi
movl $0x64, %esi
callq 0x166c8
cmpl $0x31, %eax
ja 0x24425
movq 0x40(%rsp), %rdi
movl $0xa, %esi
callq 0x166c8
cmpl $0x9, %eax
ja 0x24425
movl %eax, %eax
leaq 0xe309(%rip), %rcx      # 0x325a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leal 0x1(%r15), %esi
movq %rbx, %rdi
movl %ebp, %edx
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x25d60
testb %al, %al
je 0x24425
addl $0x2, %r15d
jmp 0x24385
movl 0x28(%rsp), %edi
jmp 0x24436
leal 0x1(%rbp), %edx
movq %rbx, %rdi
movl %r15d, %esi
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x25d60
testb %al, %al
je 0x24425
addl $0x2, %ebp
jmp 0x24385
leal 0x1(%r15), %esi
jmp 0x243c7
leal 0x1(%r15), %esi
movq %rbx, %rdi
movl %ebp, %edx
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x25d60
decl %r15d
jmp 0x24385
leal -0x1(%rbp), %edx
movq %rbx, %rdi
movl %r15d, %esi
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x25d60
testb %al, %al
je 0x24425
addl $-0x2, %ebp
jmp 0x24385
leal 0x1(%r15), %esi
jmp 0x243a4
leal -0x1(%r15), %esi
movq %rbx, %rdi
movl %ebp, %edx
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x25d60
testb %al, %al
je 0x24425
addl $-0x2, %r15d
jmp 0x24385
leal -0x1(%rbp), %edx
movq %rbx, %rdi
movl %r15d, %esi
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x25d60
incl %ebp
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %edx
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x25d60
jmp 0x24425
leal -0x1(%r15), %esi
movq %rbx, %rdi
movl %esi, 0x3c(%rsp)
movl %ebp, %edx
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x25d60
movb %al, 0x24(%rsp)
decl %ebp
jmp 0x243e4
leal -0x1(%r15), %esi
movq %rbx, %rdi
movl %esi, 0x3c(%rsp)
movl %ebp, %edx
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x25d60
movb %al, 0x24(%rsp)
incl %ebp
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %edx
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
callq 0x25d60
cmpb $0x0, 0x24(%rsp)
jne 0x24405
testb %al, %al
je 0x24425
movq 0x40(%rsp), %rdi
movl $0x64, %esi
callq 0x166c8
cmpl $0x4a, %eax
ja 0x24425
movq %rbx, %rdi
movl 0x3c(%rsp), %esi
jmp 0x2438b
movl $0x19, %eax
cmpw $0x0, 0x48(%rsp)
movl 0x28(%rsp), %edi
jne 0x2447a
movq (%rbx), %rax
movl %r12d, %ecx
cmpw $0x1, 0x1fbe8(%rax,%rcx,2)
jne 0x24451
movw $0x0, 0x1fbe8(%rax,%rcx,2)
addl %r13d, %edi
movq 0x8(%rbx), %rax
movzbl (%rax), %ecx
movzbl 0x1(%rax), %esi
imull %ecx, %esi
movl %edi, %eax
cltd
idivl %esi
movl %edx, %edi
cmpl 0x18(%rsp), %edx
movl $0x0, %eax
movl $0x1a, %ecx
cmovel %ecx, %eax
testl %eax, %eax
je 0x241c7
cmpl $0x19, %eax
jne 0x24e40
movq 0x8(%rbx), %rax
movb $0x1, %r11b
cmpb $0x1, 0xb(%rax)
movq 0x40(%rsp), %r14
jne 0x24e48
movl 0x6c(%rsp), %eax
imull 0x58(%rsp), %eax
cmpl $0x4, %eax
jg 0x24e48
movq $0x0, 0x30(%rsp)
movq 0x8(%rbx), %rax
cmpb $0x2, 0x1(%rax)
jb 0x24bc4
movq $0x0, 0x80(%rsp)
movq $0x0, 0x60(%rsp)
movq 0x8(%rbx), %rcx
cmpb $0x2, (%rcx)
jb 0x24b90
imulq $0x64, 0x60(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0x80(%rsp), %rax
movl %eax, 0x24(%rsp)
xorl %r15d, %r15d
movq %rcx, 0x98(%rsp)
movq 0xa0(%rsp), %rbp
leaq (%r15,%rbp), %rdi
movq %r15, %r11
movq (%rbx), %r15
movl %edi, %eax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
shrq $0x25, %rax
imull $0x64, %eax, %ecx
movl %edi, %edx
subl %ecx, %edx
leaq (%rdx,%rdx,2), %rcx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
leaq (%r15,%rax), %r14
addq $0xc, %r14
movq %rcx, 0x48(%rsp)
movb (%r14,%rcx,4), %al
movb %al, 0x10(%rsp)
testb %al, %al
movl $0xffff, %esi           # imm = 0xFFFF
movq %rdi, 0x18(%rsp)
cmovnsl %edi, %esi
leaq (%r11,%rbp), %rax
incq %rax
movl %eax, %edx
imulq $0x51eb851f, %rdx, %rdx # imm = 0x51EB851F
shrq $0x25, %rdx
imull $0x64, %edx, %edi
movl %eax, %r8d
subl %edi, %r8d
leaq (%r8,%r8,2), %rdi
imulq $0x4b0, %rdx, %rdx      # imm = 0x4B0
leaq (%r15,%rdx), %r13
addq $0xc, %r13
movb (%r13,%rdi,4), %cl
movb %cl, 0x3c(%rsp)
testb %cl, %cl
cmovnsl %eax, %esi
leaq (%r11,%rbp), %rax
addq $0x64, %rax
movl %eax, %r8d
imulq $0x51eb851f, %r8, %r9   # imm = 0x51EB851F
shrq $0x25, %r9
imull $0x64, %r9d, %r8d
movl %eax, %r10d
subl %r8d, %r10d
leaq (%r10,%r10,2), %r8
imulq $0x4b0, %r9, %r9        # imm = 0x4B0
leaq (%r15,%r9), %r12
addq $0xc, %r12
movb (%r12,%r8,4), %r9b
testb %r9b, %r9b
cmovnsl %eax, %esi
leaq (%r11,%rbp), %rbx
addq $0x65, %rbx
movl %ebx, %eax
imulq $0x51eb851f, %rax, %r10 # imm = 0x51EB851F
shrq $0x25, %r10
imull $0x64, %r10d, %eax
movl %ebx, %ebp
subl %eax, %ebp
leaq (,%rbp,2), %rax
addq %rbp, %rax
imulq $0x4b0, %r10, %r10      # imm = 0x4B0
movq %r15, 0x28(%rsp)
leaq (%r15,%r10), %rbp
addq $0xc, %rbp
movq %r11, %r15
movb (%rbp,%rax,4), %r10b
testb %r10b, %r10b
cmovnsl %ebx, %esi
cmpw $-0x1, %si
je 0x24699
movq 0x28(%rsp), %rcx
leaq 0xc(%rcx), %r11
movzwl %si, %esi
imulq $0x28f5c29, %rsi, %rbx  # imm = 0x28F5C29
shrq $0x20, %rbx
imull $0x64, %ebx, %ecx
subl %ecx, %esi
imulq $0x4b0, %rbx, %rcx      # imm = 0x4B0
addq %r11, %rcx
leaq (%rsi,%rsi,2), %rsi
movzwl 0x2(%rcx,%rsi,4), %ecx
movw %cx, 0x5e(%rsp)
movzwl %cx, %edx
imulq $0x28f5c29, %rdx, %rcx  # imm = 0x28F5C29
shrq $0x20, %rcx
imull $0x64, %ecx, %esi
movq %rdx, %rbx
movq %rdx, 0x8(%rsp)
subl %esi, %ebx
leaq (%rbx,%rbx,2), %rsi
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
movq %r11, 0x50(%rsp)
addq %r11, %rcx
cmpb $0x4f, (%rcx,%rsi,4)
jle 0x246c0
incq %r15
movq 0x90(%rsp), %rbx
movq 0x8(%rbx), %rcx
movzbl (%rcx), %eax
decq %rax
incl 0x24(%rsp)
cmpq %rax, %r15
jl 0x24509
jmp 0x24b90
movq 0x48(%rsp), %rcx
leaq (%r14,%rcx,4), %rsi
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %r11
cmpw $0x3, 0x1fbe8(%r11,%rcx,2)
jl 0x246e9
movswl 0x2(%rsi), %ecx
cmpl 0x8(%rsp), %ecx
jne 0x24699
leaq (,%rdi,4), %rdi
addq %r13, %rdi
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %r11
cmpw $0x3, 0x1fbea(%r11,%rcx,2)
jl 0x24714
movswl 0x2(%rdi), %ecx
cmpl 0x8(%rsp), %ecx
jne 0x24699
leaq (%r12,%r8,4), %r8
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %r11
cmpw $0x3, 0x1fcb0(%r11,%rcx,2)
jl 0x2473d
movswl 0x2(%r8), %ecx
cmpl 0x8(%rsp), %ecx
jne 0x24699
leaq (,%rax,4), %rax
addq %rbp, %rax
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %r11
cmpw $0x3, 0x1fcb2(%r11,%rcx,2)
jl 0x2476c
movswl 0x2(%rax), %ecx
cmpl 0x8(%rsp), %ecx
jne 0x24699
cmpb $0x0, 0x10(%rsp)
js 0x24781
movswl 0x2(%rsi), %ecx
cmpl 0x8(%rsp), %ecx
jne 0x24699
cmpb $0x0, 0x3c(%rsp)
js 0x24796
movswl 0x2(%rdi), %ecx
cmpl 0x8(%rsp), %ecx
jne 0x24699
testb %r9b, %r9b
js 0x247aa
movswl 0x2(%r8), %ecx
cmpl 0x8(%rsp), %ecx
jne 0x24699
testb %r10b, %r10b
js 0x247bd
movswl 0x2(%rax), %eax
cmpl 0x8(%rsp), %eax
jne 0x24699
testq %r15, %r15
je 0x24848
movq 0x18(%rsp), %rax
decl %eax
movzwl %ax, %ecx
imulq $0x28f5c29, %rcx, %rax  # imm = 0x28F5C29
shrq $0x20, %rax
imull $0x64, %eax, %edx
subl %edx, %ecx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq 0x50(%rsp), %rax
leaq (%rcx,%rcx,2), %rcx
cmpb $0x0, (%rax,%rcx,4)
js 0x24808
leaq (%rax,%rcx,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x8(%rsp), %eax
je 0x24699
movq 0x18(%rsp), %rax
leal 0x63(%rax), %ecx
imulq $0x51eb851f, %rcx, %rax # imm = 0x51EB851F
shrq $0x25, %rax
imull $0x64, %eax, %edx
subl %edx, %ecx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq 0x50(%rsp), %rax
leaq (%rcx,%rcx,2), %rcx
cmpb $0x0, (%rax,%rcx,4)
js 0x24848
leaq (%rax,%rcx,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x8(%rsp), %eax
je 0x24699
cmpq $0x0, 0x60(%rsp)
je 0x248de
movq 0x18(%rsp), %rax
addl $0xff9c, %eax           # imm = 0xFF9C
movzwl %ax, %ecx
imulq $0x28f5c29, %rcx, %rax  # imm = 0x28F5C29
shrq $0x20, %rax
imull $0x64, %eax, %edx
subl %edx, %ecx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq 0x50(%rsp), %rax
leaq (%rcx,%rcx,2), %rcx
cmpb $0x0, (%rax,%rcx,4)
js 0x24899
leaq (%rax,%rcx,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x8(%rsp), %eax
je 0x24699
movq 0x18(%rsp), %rax
addl $0xff9d, %eax           # imm = 0xFF9D
movzwl %ax, %ecx
imulq $0x28f5c29, %rcx, %rax  # imm = 0x28F5C29
shrq $0x20, %rax
imull $0x64, %eax, %edx
subl %edx, %ecx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq 0x50(%rsp), %rax
leaq (%rcx,%rcx,2), %rcx
cmpb $0x0, (%rax,%rcx,4)
js 0x248de
leaq (%rax,%rcx,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x8(%rsp), %eax
je 0x24699
movq 0x28(%rsp), %rax
movslq (%rax), %rax
decq %rax
cmpq %rax, %r15
jge 0x24977
movq 0x18(%rsp), %rcx
leal 0x2(%rcx), %edx
imulq $0x51eb851f, %rdx, %rcx # imm = 0x51EB851F
shrq $0x25, %rcx
imull $0x64, %ecx, %esi
subl %esi, %edx
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq 0x50(%rsp), %rcx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x0, (%rcx,%rdx,4)
js 0x24932
leaq (%rcx,%rdx,4), %rcx
movswl 0x2(%rcx), %ecx
cmpl 0x8(%rsp), %ecx
je 0x24699
cmpq %rax, %r15
jge 0x24977
movq 0x18(%rsp), %rax
leal 0x66(%rax), %ecx
imulq $0x51eb851f, %rcx, %rax # imm = 0x51EB851F
shrq $0x25, %rax
imull $0x64, %eax, %edx
subl %edx, %ecx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq 0x50(%rsp), %rax
leaq (%rcx,%rcx,2), %rcx
cmpb $0x0, (%rax,%rcx,4)
js 0x24977
leaq (%rax,%rcx,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x8(%rsp), %eax
je 0x24699
movq 0x28(%rsp), %rax
movslq 0x4(%rax), %rax
decq %rax
cmpq %rax, 0x60(%rsp)
jge 0x24a1b
movq 0x18(%rsp), %rcx
leal 0xc8(%rcx), %edx
imulq $0x51eb851f, %rdx, %rcx # imm = 0x51EB851F
shrq $0x25, %rcx
imull $0x64, %ecx, %esi
subl %esi, %edx
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq 0x50(%rsp), %rcx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x0, (%rcx,%rdx,4)
js 0x249d1
leaq (%rcx,%rdx,4), %rcx
movswl 0x2(%rcx), %ecx
cmpl 0x8(%rsp), %ecx
je 0x24699
cmpq %rax, 0x60(%rsp)
jge 0x24a1b
movq 0x18(%rsp), %rax
leal 0xc9(%rax), %ecx
imulq $0x51eb851f, %rcx, %rax # imm = 0x51EB851F
shrq $0x25, %rax
imull $0x64, %eax, %edx
subl %edx, %ecx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq 0x50(%rsp), %rax
leaq (%rcx,%rcx,2), %rcx
cmpb $0x0, (%rax,%rcx,4)
js 0x24a1b
leaq (%rax,%rcx,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x8(%rsp), %eax
je 0x24699
movq 0x98(%rsp), %rax
cmpb $0x0, 0xc(%rax)
jne 0x24b3c
movq 0x28(%rsp), %rax
leaq 0x10(%rax), %r9
xorl %r10d, %r10d
xorl %r11d, %r11d
leaq 0xdb55(%rip), %rax      # 0x32598
movsbl (%r10,%rax), %eax
movq 0x18(%rsp), %rcx
leal (%rcx,%rax), %edi
addl 0x24(%rsp), %eax
movzwl %ax, %ecx
movq %rcx, %rax
movabsq $0x28f5c28f5c28f5d, %rdx # imm = 0x28F5C28F5C28F5D
mulq %rdx
imulq $0x4b0, %rdx, %rax      # imm = 0x4B0
imulq $0x28f5c29, %rcx, %rdx  # imm = 0x28F5C29
shrq $0x20, %rdx
imull $0x64, %edx, %edx
subl %edx, %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,4), %rax
addq %r9, %rax
xorl %ecx, %ecx
leaq 0xdb0a(%rip), %rbx      # 0x3259c
movl $0x27, %ebp
movq 0x50(%rsp), %r14
movq 0x8(%rsp), %r12
movsbl (%rax,%rcx), %edx
cmpl $-0x1, %edx
je 0x24af2
movsbl (%rcx,%rbx), %esi
imull %edx, %esi
addl %edi, %esi
movzwl %si, %edx
imulq $0x28f5c29, %rdx, %rsi  # imm = 0x28F5C29
shrq $0x20, %rsi
imull $0x64, %esi, %r8d
subl %r8d, %edx
leaq (%rdx,%rdx,2), %rdx
imulq $0x4b0, %rsi, %rsi      # imm = 0x4B0
addq %r14, %rsi
movsbl (%rsi,%rdx,4), %edx
movq 0x28(%rsp), %rsi
cmpw %dx, 0x1fbe8(%rsi,%r12,2)
movl $0x0, %edx
cmovel %ebp, %edx
jmp 0x24af7
movl $0x26, %edx
cmpl $0x26, %edx
je 0x24b00
testl %edx, %edx
jne 0x24b0e
incq %rcx
cmpq $0x4, %rcx
jne 0x24aa1
movl $0x24, %edx
cmpl $0x24, %edx
je 0x24b17
testl %edx, %edx
jne 0x24b32
cmpq $0x3, %r10
leaq 0x1(%r10), %rax
setae %r11b
movq %rax, %r10
cmpq $0x4, %rax
jne 0x24a3c
jmp 0x24b3c
testb $0x1, %r11b
je 0x24699
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rcx
movzwl 0x1fbe8(%rax,%rcx,2), %r14d
movzwl -0x70(%rsp,%r14,2), %eax
incl %eax
movw %ax, -0x70(%rsp,%r14,2)
movzwl %ax, %esi
movq 0x40(%rsp), %rdi
callq 0x166c8
testl %eax, %eax
jne 0x24699
addl %r14d, %r14d
movq 0x18(%rsp), %rax
movw %ax, -0x28(%rsp,%r14)
movzwl 0x5e(%rsp), %eax
movw %ax, -0x30(%rsp,%r14)
jmp 0x24699
movq 0x60(%rsp), %rdx
incq %rdx
movq 0x8(%rbx), %rax
movzbl 0x1(%rax), %eax
decq %rax
movq 0x80(%rsp), %rcx
addl $0x64, %ecx
movq %rcx, 0x80(%rsp)
movq %rdx, 0x60(%rsp)
cmpq %rax, %rdx
jl 0x244df
xorl %eax, %eax
cmpw $0x0, 0x32(%rsp)
setne %al
cmpw $0x1, 0x30(%rsp)
sbbl $-0x1, %eax
cmpw $0x1, 0x34(%rsp)
sbbl $-0x1, %eax
cmpw $0x1, 0x36(%rsp)
sbbl $-0x1, %eax
cmpl 0x58(%rsp), %eax
jne 0x24e36
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x40(%rsp), %r14
movb $0x1, %r11b
movzwl 0x30(%rsp,%rax,2), %edx
xorl %esi, %esi
xorl %edi, %edi
testw %dx, %dx
je 0x24c46
cmpw $0x0, 0x30(%rsp,%rsi,2)
je 0x24c46
movzwl 0x78(%rsp,%rax,2), %r8d
movzwl 0x78(%rsp,%rsi,2), %r9d
leal 0x1(%r9), %r10d
cmpl %r8d, %r10d
je 0x24c5d
leal 0x65(%r9), %r10d
cmpl %r8d, %r10d
je 0x24c5d
leal 0x64(%r9), %r10d
cmpl %r8d, %r10d
je 0x24c5d
addl $0x63, %r9d
cmpl %r8d, %r9d
je 0x24c5d
cmpq $0x3, %rsi
leaq 0x1(%rsi), %r8
setae %dil
movq %r8, %rsi
cmpq $0x4, %r8
jne 0x24c09
jmp 0x24c67
testb $0x1, %dil
je 0x24e53
cmpq $0x3, %rax
leaq 0x1(%rax), %rdx
setae %cl
movq %rdx, %rax
cmpq $0x4, %rdx
jne 0x24c00
movq (%rbx), %rax
xorl %ecx, %ecx
cmpw $0x0, 0x30(%rsp,%rcx,2)
je 0x24cb0
movzwl 0x78(%rsp,%rcx,2), %edx
leal 0x50(%rcx), %esi
movw %si, 0x1fbe8(%rax,%rdx,2)
movw %si, 0x1fbea(%rax,%rdx,2)
movw %si, 0x1fcb0(%rax,%rdx,2)
movw %si, 0x1fcb2(%rax,%rdx,2)
incq %rcx
cmpq $0x4, %rcx
jne 0x24c80
movw $0x50, %bp
xorl %r13d, %r13d
cmpw $0x0, 0x30(%rsp,%r13,2)
je 0x24e23
movzwl 0x78(%rsp,%r13,2), %r14d
movl %r14d, %eax
imulq $0x28f5c29, %rax, %r15  # imm = 0x28F5C29
shrq $0x20, %r15
imulq $0x4b0, %r15, %rax      # imm = 0x4B0
addq (%rbx), %rax
imull $0x64, %r15d, %ecx
movl %r14d, %r12d
subl %ecx, %r12d
leaq (%r12,%r12,2), %rcx
cmpb $0x0, 0xc(%rax,%rcx,4)
jns 0x24d1b
movzwl 0x70(%rsp,%r13,2), %ecx
movzwl %bp, %r9d
movq %rbx, %rdi
movl %r12d, %esi
movl %r15d, %edx
xorl %r8d, %r8d
callq 0x254ea
leal 0x1(%r14), %eax
movzwl %ax, %eax
imulq $0x28f5c29, %rax, %rcx  # imm = 0x28F5C29
shrq $0x20, %rcx
imulq $0x4b0, %rcx, %rdx      # imm = 0x4B0
addq (%rbx), %rdx
imull $0x64, %ecx, %ecx
subl %ecx, %eax
leaq (%rax,%rax,2), %rax
cmpb $0x0, 0xc(%rdx,%rax,4)
jns 0x24d64
leal 0x1(%r12), %esi
movzwl 0x70(%rsp,%r13,2), %ecx
movzwl %bp, %r9d
movq %rbx, %rdi
movl %r15d, %edx
xorl %r8d, %r8d
callq 0x254ea
leal 0x64(%r14), %eax
movzwl %ax, %eax
imulq $0x28f5c29, %rax, %rcx  # imm = 0x28F5C29
shrq $0x20, %rcx
imulq $0x4b0, %rcx, %rdx      # imm = 0x4B0
addq (%rbx), %rdx
imull $0x64, %ecx, %ecx
subl %ecx, %eax
leaq (%rax,%rax,2), %rax
cmpb $0x0, 0xc(%rdx,%rax,4)
jns 0x24dac
leal 0x1(%r15), %edx
movzwl 0x70(%rsp,%r13,2), %ecx
movzwl %bp, %r9d
movq %rbx, %rdi
movl %r12d, %esi
xorl %r8d, %r8d
callq 0x254ea
addl $0x65, %r14d
movzwl %r14w, %eax
imulq $0x28f5c29, %rax, %rcx  # imm = 0x28F5C29
shrq $0x20, %rcx
imulq $0x4b0, %rcx, %rdx      # imm = 0x4B0
addq (%rbx), %rdx
imull $0x64, %ecx, %ecx
subl %ecx, %eax
leaq (%rax,%rax,2), %rax
cmpb $0x0, 0xc(%rdx,%rax,4)
jns 0x24dfa
incl %r12d
incl %r15d
movzwl 0x70(%rsp,%r13,2), %ecx
movzwl %bp, %r9d
movq %rbx, %rdi
movl %r12d, %esi
movl %r15d, %edx
xorl %r8d, %r8d
callq 0x254ea
movzwl 0x70(%rsp,%r13,2), %eax
imulq $0x28f5c29, %rax, %rcx  # imm = 0x28F5C29
shrq $0x20, %rcx
imulq $0x4b0, %rcx, %rdx      # imm = 0x4B0
addq (%rbx), %rdx
imull $0x64, %ecx, %ecx
subl %ecx, %eax
leaq (%rax,%rax,2), %rax
movb %bpl, 0xc(%rdx,%rax,4)
incq %r13
incl %ebp
cmpq $0x4, %r13
jne 0x24cc0
incl 0x6c(%rsp)
movq 0x40(%rsp), %r14
movb $0x1, %r11b
jmp 0x24e48
xorl %r11d, %r11d
movq 0x40(%rsp), %r14
testb %r11b, %r11b
jne 0x24152
jmp 0x24e5e
testb $0x1, %cl
jne 0x24c7b
jmp 0x24e48
movq (%rbx), %rax
movslq 0x4(%rax), %rcx
testq %rcx, %rcx
jle 0x24e97
movl (%rax), %edx
xorl %esi, %esi
xorl %edi, %edi
movq %rdx, %r8
movq %rsi, %r9
testl %edx, %edx
jle 0x24e8b
movw %r9w, 0x1fbe8(%rax,%r9,2)
incq %r9
decq %r8
jne 0x24e7a
incq %rdi
addq $0x64, %rsi
cmpq %rcx, %rdi
jne 0x24e70
movq (%rbx), %rax
cmpl $0x0, 0x4(%rax)
jle 0x25163
movq $-0xc, 0x48(%rsp)
movq $0x0, 0x8(%rsp)
movq $-0x4b0, 0x10(%rsp)     # imm = 0xFB50
xorl %r10d, %r10d
movq (%rbx), %r14
cmpl $0x0, (%r14)
jle 0x2513c
imulq $0x64, %r10, %rax
movq %rax, 0x18(%rsp)
imulq $0x4b0, %r10, %rax      # imm = 0x4B0
movq %rax, 0x28(%rsp)
movq 0x10(%rsp), %r12
movq 0x48(%rsp), %r13
movq 0x8(%rsp), %rdx
xorl %r8d, %r8d
movq 0x28(%rsp), %rax
addq %r14, %rax
addq $0xc, %rax
leaq (%r8,%r8,2), %rcx
cmpb $0x0, (%rax,%rcx,4)
js 0x2511e
leaq 0xc(%r14), %rsi
leaq (%rax,%rcx,4), %rdi
movq 0x18(%rsp), %rax
addq %r8, %rax
movzwl 0x1fbe8(%r14,%rax,2), %ecx
movswq 0x2(%rdi), %r9
movzwl 0x1fbe8(%r14,%r9,2), %r9d
movw %r9w, 0x1fbe8(%r14,%rax,2)
movswq 0x2(%rdi), %rax
movw %cx, 0x1fbe8(%r14,%rax,2)
movzwl 0x2(%rdi), %eax
imulq $0x28f5c29, %rax, %rcx  # imm = 0x28F5C29
shrq $0x20, %rcx
imull $0x64, %ecx, %r9d
subl %r9d, %eax
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rsi, %rcx
leaq (%rax,%rax,2), %rax
movzbl (%rcx,%rax,4), %eax
movb %al, (%rdi)
cmpb $0x50, %al
movl $0x10, %ecx
cmovgel %ecx, %eax
movb %al, 0x1(%rdi)
movq $-0x1, %rax
movq %r13, %r9
movq %rdx, %rbp
xorl %r11d, %r11d
leaq (%r8,%r11), %rcx
testq %rcx, %rcx
jle 0x25041
movq %r11, %rsi
movq %r9, %r15
movzbl (%r14,%rbp), %ecx
incq %rax
decq %r11
addq $-0xc, %rbp
addq $-0xc, %r9
cmpl $0xff, %ecx
je 0x24f95
cmpl $0xfe, %ecx
je 0x25041
negb %r11b
movb %r11b, 0x6(%rdi)
movq (%rbx), %rcx
movb %r11b, 0x10(%rcx,%rbp)
movq %r8, %rcx
subq %rax, %rcx
cmpq %r8, %rcx
jge 0x2501d
negq %rsi
movb $0x1, %r14b
movq (%rbx), %rcx
movb %sil, 0x1c(%rcx,%r15)
movq (%rbx), %rcx
movb %r14b, 0x1e(%rcx,%r15)
movb 0xa(%rdi), %cl
movq (%rbx), %r9
movb %cl, 0x20(%r9,%r15)
movb 0xa(%rdi), %cl
movq (%rbx), %r9
movb %cl, 0x22(%r9,%r15)
addq $0xc, %r15
incb %r14b
decq %rsi
jne 0x24feb
movq (%rbx), %rcx
movzwl 0xe(%rcx,%rbp), %ecx
cmpw 0x2(%rdi), %cx
sete %cl
testl %eax, %eax
sete %al
testb %al, %cl
je 0x25041
movb $0x3, %cl
movb %cl, 0xa(%rdi)
movq (%rbx), %rax
movb %cl, 0x14(%rax,%rbp)
movq (%rbx), %rbp
movq $-0x1, %rax
movq %r12, %r15
movq %rdx, %r14
xorl %r11d, %r11d
leaq (%r10,%r11), %rcx
testq %rcx, %rcx
jle 0x2511e
movq %r11, %rsi
movq %r15, %r9
movzbl -0x4a4(%rbp,%r14), %ecx
incq %rax
decq %r11
movq $-0x4b0, %r15           # imm = 0xFB50
addq %r15, %r14
addq %r9, %r15
cmpl $0xff, %ecx
je 0x25054
cmpl $0xfe, %ecx
je 0x2511e
negb %r11b
movb %r11b, 0x5(%rdi)
movq (%rbx), %rcx
movb %r11b, 0x13(%rcx,%r14)
movq %r10, %rcx
subq %rax, %rcx
cmpq %r10, %rcx
jge 0x250f8
negq %rsi
movb $0x1, %bpl
movq (%rbx), %rcx
movb %bpl, 0x4c1(%rcx,%r9)
movq (%rbx), %rcx
movb %sil, 0x4c3(%rcx,%r9)
movb 0x9(%rdi), %cl
movq (%rbx), %r11
movb %cl, 0x4c5(%r11,%r9)
movb 0x9(%rdi), %cl
movq (%rbx), %r11
movb %cl, 0x4c7(%r11,%r9)
addq $0x4b0, %r9             # imm = 0x4B0
incb %bpl
decq %rsi
jne 0x250b7
movq (%rbx), %rcx
movzwl 0xe(%rcx,%r14), %ecx
cmpw 0x2(%rdi), %cx
sete %cl
testl %eax, %eax
sete %al
testb %al, %cl
je 0x2511e
movb $0x3, %cl
movb %cl, 0x9(%rdi)
movq (%rbx), %rax
movb %cl, 0x17(%rax,%r14)
incq %r8
movq (%rbx), %r14
movslq (%r14), %rax
addq $0xc, %rdx
addq $0xc, %r13
addq $0xc, %r12
cmpq %rax, %r8
jl 0x24ef6
incq %r10
movq (%rbx), %rax
movslq 0x4(%rax), %rax
movl $0x4b0, %ecx            # imm = 0x4B0
addq %rcx, 0x8(%rsp)
addq %rcx, 0x48(%rsp)
addq %rcx, 0x10(%rsp)
cmpq %rax, %r10
jl 0x24ec2
movq (%rbx), %rax
cmpl $0x0, 0x4(%rax)
jle 0x252c4
movq $0x0, 0x48(%rsp)
movq (%rbx), %rax
cmpl $0x0, (%rax)
jle 0x252a7
movq 0x48(%rsp), %rcx
imulq $0x64, %rcx, %r8
imulq $0x4b0, %rcx, %r9       # imm = 0x4B0
xorl %r15d, %r15d
movq %r8, 0x28(%rsp)
movq %r9, 0x18(%rsp)
leaq (%rax,%r9), %rcx
leaq (%r15,%r15,2), %rdx
cmpb $0x0, 0xc(%rcx,%rdx,4)
js 0x25295
leaq (%r15,%r8), %r14
movswq 0x1fbe8(%rax,%r14,2), %rax
movl %eax, %eax
cmpq %rax, %r14
je 0x25295
xorl %ebp, %ebp
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r14d, %r12d
movzwl %r12w, %eax
imulq $0x28f5c29, %rax, %rcx  # imm = 0x28F5C29
shrq $0x20, %rcx
imulq $0x4b0, %rcx, %rdx      # imm = 0x4B0
addq (%rbx), %rdx
imull $0x64, %ecx, %ecx
subl %ecx, %eax
leaq (%rax,%rax,2), %rcx
movb 0x14(%rdx,%rcx,4), %al
cmpb $0x50, 0xc(%rdx,%rcx,4)
movb 0x17(%rdx,%rcx,4), %cl
jl 0x25215
xorb $0x3, %cl
xorb $0x3, %al
orb %cl, %al
sete %al
jmp 0x25222
cmpb $0x3, %cl
sete %cl
cmpb $0x3, %al
sete %al
orb %cl, %al
testb %al, %al
je 0x2523a
incl %ebp
movq 0x40(%rsp), %rdi
movl %ebp, %esi
callq 0x166c8
testl %eax, %eax
cmovel %r12d, %r13d
movq (%rbx), %rax
movslq %r12d, %rcx
movswl 0x1fbe8(%rax,%rcx,2), %r12d
cmpq %r12, %r14
jne 0x251d8
leaq 0xc(%rax), %rcx
movq 0x28(%rsp), %r8
movq 0x18(%rsp), %r9
movzwl %r12w, %edx
imulq $0x28f5c29, %rdx, %rsi  # imm = 0x28F5C29
shrq $0x20, %rsi
imull $0x64, %esi, %edi
subl %edi, %edx
imulq $0x4b0, %rsi, %rsi      # imm = 0x4B0
addq %rcx, %rsi
leaq (%rdx,%rdx,2), %rdx
movw %r13w, 0x2(%rsi,%rdx,4)
movslq %r12d, %rdx
movswl 0x1fbe8(%rax,%rdx,2), %r12d
cmpq %r12, %r14
jne 0x2525c
incq %r15
movq (%rbx), %rax
movslq (%rax), %rcx
cmpq %rcx, %r15
jl 0x251a2
movq 0x48(%rsp), %rdx
incq %rdx
movq (%rbx), %rax
movslq 0x4(%rax), %rax
movq %rdx, 0x48(%rsp)
cmpq %rax, %rdx
jl 0x25179
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq