// File: /workspace/github_cpp_makefile_star2_O3/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 $0x98, %rsp
movq %rdi, %rbp
leaq 0x10(%rdi), %r13
movq %rsi, 0x10(%rdi)
movq %r13, %rdi
callq 0x16828
movq (%rbp), %rcx
movq 0x8(%rbp), %rax
movzbl (%rax), %r8d
movl %r8d, (%rcx)
movzbl 0x1(%rax), %edx
movl %edx, 0x4(%rcx)
movl $0x0, 0x8(%rcx)
testl %edx, %edx
je 0x23ad6
movl $0x6, %eax
xorl %edx, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edi, %edi
testl %r8d, %r8d
jle 0x23abc
movq %rax, %r9
movq %rdx, %r10
xorl %r11d, %r11d
movw $0xff, (%rcx,%r9,2)
movw %r10w, 0x2(%rcx,%r9,2)
movq %rsi, 0x4(%rcx,%r9,2)
movq (%rbp), %rcx
movw $0x0, 0x1fbe8(%rcx,%r10,2)
incq %r11
movslq (%rcx), %r8
incq %r10
addq $0x6, %r9
cmpq %r8, %r11
jl 0x23a89
incq %rdi
movslq 0x4(%rcx), %r9
addq $0x64, %rdx
addq $0x258, %rax            # imm = 0x258
cmpq %r9, %rdi
jl 0x23a7b
movq 0x8(%rbp), %rax
movq $-0x1, 0x1d4d0(%rcx)
movb 0xb(%rax), %dl
testb %dl, %dl
movq %rbp, 0x8(%rsp)
jne 0x23b54
movzbl (%rax), %esi
movq %r13, %rdi
callq 0x16944
movl %eax, %ebp
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movzbl 0x1(%rax), %esi
movq %r13, %rdi
callq 0x16944
imull $0x64, %eax, %ecx
addl %ebp, %ecx
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
movw %cx, 0x1d4ce(%rdx)
movzwl %cx, %ecx
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movq 0x8(%rsp), %rbp
movl %eax, %edx
xorl %r8d, %r8d
movl $0x3, %r9d
callq 0x25530
movq (%rbp), %rcx
movb $0x0, 0x1d4cc(%rcx)
movq 0x8(%rbp), %rax
movb 0xb(%rax), %dl
movl $0x0, 0x30(%rsp)
testb $0x1, %dl
movq %r13, 0x38(%rsp)
je 0x23d73
movq %r13, %rdi
movl $0x3, %esi
callq 0x16944
movl %eax, %ebp
movl $0x53525150, 0x28(%rsp) # imm = 0x53525150
movl $0x5, %ebx
leaq -0x1(%rbx), %r15
movq %r13, %rdi
movl %r15d, %esi
callq 0x16944
movb 0x26(%rsp,%rbx), %cl
cltq
movb 0x28(%rsp,%rax), %dl
movb %dl, 0x26(%rsp,%rbx)
movb %cl, 0x28(%rsp,%rax)
movq %r15, %rbx
cmpq $0x1, %r15
ja 0x23b86
movq 0x8(%rsp), %rax
movq (%rax), %rcx
movb $0x1, 0x1d4cc(%rcx)
movq 0x8(%rax), %rax
movb (%rax), %dl
cmpb $0x7, %dl
jae 0x23be2
cmpb $0x3, %dl
movq 0x8(%rsp), %rbp
jb 0x23c04
movb 0x1(%rax), %sil
movl $0x2, 0x30(%rsp)
jmp 0x23bfe
addl $0x2, %ebp
movb 0x1(%rax), %sil
cmpb $0x7, %sil
movl $0x2, %edi
cmovael %ebp, %edi
movl %edi, 0x30(%rsp)
movq 0x8(%rsp), %rbp
cmpb $0x2, %sil
ja 0x23c0c
movl $0x1, 0x30(%rsp)
cmpb $0x4, %dl
ja 0x23c1c
movl $0x1, %esi
cmpb $0x5, 0x1(%rax)
jb 0x23c2a
movl 0x30(%rsp), %edx
movl %edx, %esi
testl %edx, %edx
jle 0x23d73
movl %esi, 0x48(%rsp)
movl %esi, %eax
movq %rax, 0x18(%rsp)
xorl %r14d, %r14d
movq 0x8(%rbp), %rax
movzbl (%rax), %esi
decl %esi
movq %r13, %rdi
callq 0x16944
movl %eax, %r15d
movq 0x8(%rbp), %rax
movzbl 0x1(%rax), %esi
decl %esi
movq %r13, %rdi
callq 0x16944
movl %eax, %r12d
movq (%rbp), %rax
imull $0x64, %r12d, %ecx
addl %r15d, %ecx
movslq %ecx, %rbx
cmpw $0x1, 0x1fbe8(%rax,%rbx,2)
jg 0x23c38
cmpw $0x1, 0x1fbea(%rax,%rbx,2)
jg 0x23c38
cmpw $0x1, 0x1fcb0(%rax,%rbx,2)
jg 0x23c38
cmpw $0x1, 0x1fcb2(%rax,%rbx,2)
jg 0x23c38
movzbl 0x28(%rsp,%r14), %r13d
movzwl %bx, %ebp
movq 0x8(%rsp), %rdi
movl %r15d, %esi
movl %r12d, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
movl %r13d, %r9d
callq 0x25530
leal 0x1(%r15), %esi
movl %esi, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movl %r12d, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
movl %r13d, %r9d
callq 0x25530
leal 0x1(%r12), %edx
movq 0x8(%rsp), %rdi
movl %r15d, %esi
movq %r14, 0x20(%rsp)
movl %edx, %r14d
movl %ebp, %ecx
xorl %r8d, %r8d
movl %r13d, %r9d
callq 0x25530
movq 0x8(%rsp), %rdi
movl 0x10(%rsp), %esi
movl %r14d, %edx
movq 0x20(%rsp), %r14
movl %ebp, %ecx
movq 0x8(%rsp), %rbp
xorl %r8d, %r8d
movl %r13d, %r9d
callq 0x25530
movq (%rbp), %rcx
movslq %r12d, %rax
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq %rcx, %rax
movslq %r15d, %rdx
leaq (%rdx,%rdx,2), %rdx
movb %r13b, 0xc(%rax,%rdx,4)
movw %r13w, 0x1fbe8(%rcx,%rbx,2)
movw %bx, 0x1d4ce(%rcx)
movw %bx, 0x1d430(%rcx,%r13,2)
movq 0x38(%rsp), %r13
incq %r14
cmpq 0x18(%rsp), %r14
jne 0x23c38
movq 0x8(%rbp), %rax
movl 0x48(%rsp), %edx
movl %edx, 0x30(%rsp)
cmpb $0x1, 0x9(%rax)
jne 0x23dff
cmpl $0x0, 0x4(%rcx)
jle 0x23dff
movl (%rcx), %eax
movl $0x1fbe8, %ebx          # imm = 0x1FBE8
movl $0xc, %r14d
xorl %r15d, %r15d
testl %eax, %eax
jle 0x23de1
movq %r14, %r12
xorl %r13d, %r13d
movq 0x38(%rsp), %rdi
movl $0x64, %esi
callq 0x16944
movq (%rbp), %rcx
cmpl $0x3, %eax
ja 0x23dcd
leaq (%rcx,%rbx), %rax
cmpw $0x2, (%rax,%r13,2)
jg 0x23dcd
movw $0x3, (%rax,%r13,2)
movb $-0x2, (%rcx,%r12)
incq %r13
movslq (%rcx), %rax
addq $0xc, %r12
cmpq %rax, %r13
jl 0x23d9d
movq 0x38(%rsp), %r13
incq %r15
movslq 0x4(%rcx), %rdx
addq $0xc8, %rbx
addq $0x4b0, %r14            # imm = 0x4B0
cmpq %rdx, %r15
jl 0x23d93
movq 0x8(%rbp), %rax
movzbl (%rax), %ecx
movzbl 0x1(%rax), %edx
imull %ecx, %edx
cvtsi2ss %edx, %xmm0
mulss 0x4(%rax), %xmm0
cvttss2si %xmm0, %ebx
movq %r13, %rdi
movl $0x64, %esi
callq 0x16944
addl $0x32, %eax
imull %ebx, %eax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
shrq $0x25, %rax
cmpl $0x5, %eax
movl $0x4, %edx
cmovael %eax, %edx
movq (%rbp), %rcx
movl %edx, 0x7c(%rsp)
cmpl %edx, 0x8(%rcx)
jge 0x24b6a
movl $0x1, 0x54(%rsp)
movq 0x8(%rbp), %rax
movzbl (%rax), %ecx
movzbl 0x1(%rax), %esi
imull %ecx, %esi
movq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0x16944
movl %eax, 0x10(%rsp)
movq 0x8(%rbp), %rax
movzbl (%rax), %ecx
movzbl 0x1(%rax), %ebx
imull %ecx, %ebx
leal -0x1(%rbx), %esi
movq %r14, %rdi
callq 0x16944
movl %eax, %r15d
incl %r15d
movl %r15d, %ecx
testl %ebx, %ebx
je 0x23eae
movl %ebx, %edx
movl %r15d, %eax
movl %edx, %ecx
xorl %edx, %edx
divl %ecx
movl %ecx, %eax
testl %edx, %edx
jne 0x23ea2
movl %r15d, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %r15d
cmpl $0x1, %ecx
ja 0x23e96
movq (%rbp), %rcx
movq 0x8(%rbp), %rax
movb (%rax), %sil
movl 0x10(%rsp), %r9d
movl %r9d, %r13d
movl $0xffff, %r8d           # imm = 0xFFFF
movzbl %sil, %esi
movl %r13d, %eax
cltd
idivl %esi
movl %eax, %r12d
movl %edx, %ebp
andl %r8d, %ebp
andl %r8d, %r12d
imull $0x64, %r12d, %ebx
addl %ebp, %ebx
movl %ebx, %eax
andl %r8d, %eax
cmpw $0x1, 0x1fbe8(%rcx,%rax,2)
jne 0x23f34
movw $0xffff, 0x28(%rsp)     # imm = 0xFFFF
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
xorl %ecx, %ecx
leaq 0x28(%rsp), %r8
callq 0x25942
testw %ax, %ax
jne 0x23f78
movq (%r14), %rcx
movl $0xffff, %r8d           # imm = 0xFFFF
movl 0x10(%rsp), %r9d
movl %ebx, %eax
cmpw $0x1, 0x1fbe8(%rcx,%rax,2)
jne 0x23f4b
movw $0x0, 0x1fbe8(%rcx,%rax,2)
addl %r15d, %r13d
movq 0x8(%rsp), %rbp
movq 0x8(%rbp), %rax
movzbl (%rax), %esi
movzbl 0x1(%rax), %edi
imull %esi, %edi
movl %r13d, %eax
cltd
idivl %edi
movl %edx, %r13d
cmpl %r9d, %edx
jne 0x23ed6
jmp 0x24b6a
movzwl 0x28(%rsp), %r15d
movzwl %bx, %r13d
movq %r14, %rdi
movl %ebp, %esi
movl %r12d, %edx
movl %r13d, %ecx
movl $0x1, %r8d
movl %r15d, %r9d
callq 0x25530
movq 0x8(%r14), %rax
cmpb $0x1, 0xa(%rax)
movl $0xffff, %r14d          # imm = 0xFFFF
jne 0x24172
movq 0x38(%rsp), %rdi
movl $0x64, %esi
callq 0x16944
cmpl $0x31, %eax
ja 0x24172
movq 0x38(%rsp), %rdi
movl $0xa, %esi
callq 0x16944
cmpl $0x9, %eax
ja 0x24172
movl %eax, %eax
leaq 0xe698(%rip), %rcx      # 0x32680
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leal 0x1(%rbp), %esi
movq 0x8(%rsp), %rdi
movl %r12d, %edx
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x25d0c
testb %al, %al
je 0x24172
addl $0x2, %ebp
jmp 0x240ac
leal 0x1(%r12), %edx
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x25d0c
testb %al, %al
je 0x24172
addl $0x2, %r12d
jmp 0x240ac
leal 0x1(%rbp), %esi
jmp 0x24111
leal 0x1(%rbp), %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl %r12d, %edx
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x25d0c
decl %ebp
jmp 0x240d0
leal -0x1(%r12), %edx
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x25d0c
testb %al, %al
je 0x24172
addl $-0x2, %r12d
jmp 0x240ac
leal 0x1(%rbp), %esi
jmp 0x240eb
leal -0x1(%rbp), %esi
movq 0x8(%rsp), %rdi
movl %r12d, %edx
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x25d0c
testb %al, %al
je 0x24172
addl $-0x2, %ebp
movq 0x8(%rsp), %rdi
jmp 0x240d3
leal -0x1(%r12), %edx
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %esi
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x25d0c
incl %r12d
movq %rbx, %rdi
movl %ebp, %esi
movl %r12d, %edx
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x25d0c
jmp 0x24172
leal -0x1(%rbp), %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl %esi, 0x20(%rsp)
movl %r12d, %edx
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x25d0c
movb %al, 0x10(%rsp)
decl %r12d
jmp 0x24132
leal -0x1(%rbp), %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl %esi, 0x20(%rsp)
movl %r12d, %edx
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x25d0c
movb %al, 0x10(%rsp)
incl %r12d
movq %rbx, %rdi
movl %ebp, %esi
movl %r12d, %edx
movl %r13d, %ecx
movl %r15d, %r8d
callq 0x25d0c
cmpb $0x0, 0x10(%rsp)
jne 0x24150
testb %al, %al
je 0x24172
movq 0x38(%rsp), %rdi
movl $0x64, %esi
callq 0x16944
cmpl $0x4a, %eax
ja 0x24172
movq 0x8(%rsp), %rdi
movl 0x20(%rsp), %esi
jmp 0x240d5
movq 0x8(%rsp), %rbp
movq 0x8(%rbp), %rdi
cmpb $0x1, 0xb(%rdi)
jne 0x24b59
movl 0x54(%rsp), %eax
imull 0x30(%rsp), %eax
cmpl $0x4, %eax
jg 0x24b59
movq $0x0, 0x28(%rsp)
xorl %eax, %eax
cmpb $0x2, 0x1(%rdi)
jb 0x248a9
movb (%rdi), %al
xorl %edx, %edx
xorl %esi, %esi
cmpb $0x2, %al
jb 0x24868
movq %rsi, 0x68(%rsp)
imulq $0x64, %rsi, %rax
movq %rax, 0x90(%rsp)
movq %rdx, 0x80(%rsp)
movl %edx, %r15d
xorl %edx, %edx
movq %rdi, 0x88(%rsp)
movq 0x90(%rsp), %rax
movq %rdx, 0x20(%rsp)
leaq (%rdx,%rax), %r12
movl %r12d, %eax
andl %r14d, %eax
movq (%rbp), %r8
shrl $0x2, %eax
imull $0x147b, %eax, %eax     # imm = 0x147B
shrl $0x11, %eax
imull $0x64, %eax, %ecx
movl %r12d, %edx
subl %ecx, %edx
andl %r14d, %edx
leaq (%rdx,%rdx,2), %r9
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
leaq (%r8,%rax), %r10
addq $0xc, %r10
movb (%r10,%r9,4), %al
movb %al, 0x70(%rsp)
testb %al, %al
movl $0xffff, %ecx           # imm = 0xFFFF
cmovnsl %r12d, %ecx
leal 0x1(%r12), %eax
movl %eax, %edx
andl %r14d, %edx
shrl $0x2, %edx
imull $0x147b, %edx, %edx     # imm = 0x147B
shrl $0x11, %edx
imull $0x64, %edx, %esi
negl %esi
addl %r12d, %esi
incl %esi
andl %r14d, %esi
leaq (%rsi,%rsi,2), %rsi
imulq $0x4b0, %rdx, %rdx      # imm = 0x4B0
movl $0xffff, %ebp           # imm = 0xFFFF
leaq (%r8,%rdx), %r14
addq $0xc, %r14
movq %rsi, 0x48(%rsp)
movb (%r14,%rsi,4), %dl
movb %dl, 0x37(%rsp)
testb %dl, %dl
cmovsl %ecx, %eax
leal 0x64(%r12), %esi
movl %esi, %ecx
andl %ebp, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %edi
negl %edi
addl %r12d, %edi
addl $0x64, %edi
andl %ebp, %edi
leaq (%rdi,%rdi,2), %rdi
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
leaq (%r8,%rcx), %r13
addq $0xc, %r13
movb (%r13,%rdi,4), %cl
movb %cl, 0x36(%rsp)
testb %cl, %cl
cmovsl %eax, %esi
leal 0x65(%r12), %ecx
movl %ecx, %eax
andl %ebp, %eax
shrl $0x2, %eax
imull $0x147b, %eax, %r11d    # imm = 0x147B
shrl $0x11, %r11d
imull $0x64, %r11d, %eax
negl %eax
addl %r12d, %eax
addl $0x65, %eax
andl %ebp, %eax
leaq (%rax,%rax,2), %rax
imulq $0x4b0, %r11, %r11      # imm = 0x4B0
movq %r8, 0x10(%rsp)
leaq (%r8,%r11), %rbp
addq $0xc, %rbp
movb (%rbp,%rax,4), %dl
movb %dl, 0x35(%rsp)
testb %dl, %dl
cmovsl %esi, %ecx
cmpw $-0x1, %cx
je 0x24387
movq 0x10(%rsp), %rdx
leaq 0xc(%rdx), %r8
movzwl %cx, %esi
shrl $0x2, %esi
imull $0x147b, %esi, %esi     # imm = 0x147B
shrl $0x11, %esi
imull $0x64, %esi, %edx
subl %edx, %ecx
movl $0xffff, %ebx           # imm = 0xFFFF
andl %ebx, %ecx
imulq $0x4b0, %rsi, %rdx      # imm = 0x4B0
addq %r8, %rdx
leaq (%rcx,%rcx,2), %rcx
movzwl 0x2(%rdx,%rcx,4), %r11d
movl %r11d, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %edx
movq %r11, %rsi
movq %r11, 0x18(%rsp)
subl %edx, %esi
andl %ebx, %esi
leaq (%rsi,%rsi,2), %rdx
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
movq %r8, 0x40(%rsp)
addq %r8, %rcx
cmpb $0x4f, (%rcx,%rdx,4)
jle 0x243b6
movq 0x20(%rsp), %rdx
incq %rdx
movq 0x8(%rsp), %rbp
movq 0x8(%rbp), %rdi
movzbl (%rdi), %eax
leaq -0x1(%rax), %rcx
incl %r15d
cmpq %rcx, %rdx
movl $0xffff, %r14d          # imm = 0xFFFF
jl 0x241d8
jmp 0x2485b
leaq (%r10,%r9,4), %rcx
movq 0x10(%rsp), %rdx
cmpw $0x3, 0x1fbe8(%rdx,%r12,2)
jl 0x243d5
movswl 0x2(%rcx), %edx
cmpl 0x18(%rsp), %edx
jne 0x24387
movq 0x48(%rsp), %rdx
leaq (%r14,%rdx,4), %rsi
movq 0x10(%rsp), %rdx
cmpw $0x3, 0x1fbea(%rdx,%r12,2)
jl 0x243f9
movswl 0x2(%rsi), %edx
cmpl 0x18(%rsp), %edx
jne 0x24387
leaq (,%rdi,4), %rdi
addq %r13, %rdi
movq 0x10(%rsp), %rdx
cmpw $0x3, 0x1fcb0(%rdx,%r12,2)
jl 0x24423
movswl 0x2(%rdi), %edx
cmpl 0x18(%rsp), %edx
jne 0x24387
leaq (,%rax,4), %rax
addq %rbp, %rax
movq 0x10(%rsp), %rdx
cmpw $0x3, 0x1fcb2(%rdx,%r12,2)
jl 0x2444d
movswl 0x2(%rax), %edx
cmpl 0x18(%rsp), %edx
jne 0x24387
cmpb $0x0, 0x70(%rsp)
js 0x24462
movswl 0x2(%rcx), %ecx
cmpl 0x18(%rsp), %ecx
jne 0x24387
cmpb $0x0, 0x37(%rsp)
js 0x24477
movswl 0x2(%rsi), %ecx
cmpl 0x18(%rsp), %ecx
jne 0x24387
cmpb $0x0, 0x36(%rsp)
js 0x2448c
movswl 0x2(%rdi), %ecx
cmpl 0x18(%rsp), %ecx
jne 0x24387
cmpb $0x0, 0x35(%rsp)
js 0x244a1
movswl 0x2(%rax), %eax
cmpl 0x18(%rsp), %eax
jne 0x24387
cmpq $0x0, 0x20(%rsp)
je 0x2453a
leal -0x1(%r12), %eax
movl %eax, %ecx
movl $0xffff, %esi           # imm = 0xFFFF
andl %esi, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %edx
subl %edx, %eax
andl %esi, %eax
leaq (%rax,%rax,2), %rax
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq 0x40(%rsp), %rcx
cmpb $0x0, (%rcx,%rax,4)
js 0x244f6
leaq (%rcx,%rax,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x18(%rsp), %eax
je 0x24387
leal 0x63(%r12), %eax
movl %eax, %ecx
andl %esi, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %edx
subl %edx, %eax
andl %esi, %eax
leaq (%rax,%rax,2), %rax
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq 0x40(%rsp), %rcx
cmpb $0x0, (%rcx,%rax,4)
js 0x2453a
leaq (%rcx,%rax,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x18(%rsp), %eax
je 0x24387
cmpq $0x0, 0x68(%rsp)
je 0x245d3
leal -0x64(%r12), %eax
movl %eax, %ecx
movl $0xffff, %esi           # imm = 0xFFFF
andl %esi, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %edx
subl %edx, %eax
andl %esi, %eax
leaq (%rax,%rax,2), %rax
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq 0x40(%rsp), %rcx
cmpb $0x0, (%rcx,%rax,4)
js 0x2458f
leaq (%rcx,%rax,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x18(%rsp), %eax
je 0x24387
leal -0x63(%r12), %eax
movl %eax, %ecx
andl %esi, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %edx
subl %edx, %eax
andl %esi, %eax
leaq (%rax,%rax,2), %rax
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq 0x40(%rsp), %rcx
cmpb $0x0, (%rcx,%rax,4)
js 0x245d3
leaq (%rcx,%rax,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x18(%rsp), %eax
je 0x24387
movq 0x10(%rsp), %rax
movslq (%rax), %rax
decq %rax
cmpq %rax, 0x20(%rsp)
jge 0x24676
leal 0x2(%r12), %eax
movl %eax, %ecx
movl $0xffff, %esi           # imm = 0xFFFF
andl %esi, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %edx
subl %edx, %eax
andl %esi, %eax
leaq (%rax,%rax,2), %rax
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq 0x40(%rsp), %rcx
cmpb $0x0, (%rcx,%rax,4)
js 0x24632
leaq (%rcx,%rax,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x18(%rsp), %eax
je 0x24387
leal 0x66(%r12), %eax
movl %eax, %ecx
andl %esi, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %edx
subl %edx, %eax
andl %esi, %eax
leaq (%rax,%rax,2), %rax
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq 0x40(%rsp), %rcx
cmpb $0x0, (%rcx,%rax,4)
js 0x24676
leaq (%rcx,%rax,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x18(%rsp), %eax
je 0x24387
movq 0x10(%rsp), %rax
movslq 0x4(%rax), %rax
decq %rax
cmpq %rax, 0x68(%rsp)
jge 0x24720
leal 0xc8(%r12), %eax
movl %eax, %ecx
movl $0xffff, %esi           # imm = 0xFFFF
andl %esi, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %edx
subl %edx, %eax
andl %esi, %eax
leaq (%rax,%rax,2), %rax
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq 0x40(%rsp), %rcx
cmpb $0x0, (%rcx,%rax,4)
js 0x246d9
leaq (%rcx,%rax,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x18(%rsp), %eax
je 0x24387
leal 0xc9(%r12), %eax
movl %eax, %ecx
andl %esi, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %edx
subl %edx, %eax
andl %esi, %eax
leaq (%rax,%rax,2), %rax
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq 0x40(%rsp), %rcx
cmpb $0x0, (%rcx,%rax,4)
js 0x24720
leaq (%rcx,%rax,4), %rax
movswl 0x2(%rax), %eax
cmpl 0x18(%rsp), %eax
je 0x24387
movq 0x88(%rsp), %rax
cmpb $0x0, 0xc(%rax)
je 0x24778
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movzwl 0x1fbe8(%rax,%rcx,2), %ebx
movzwl -0x78(%rsp,%rbx,2), %eax
incl %eax
movw %ax, -0x78(%rsp,%rbx,2)
movzwl %ax, %esi
movq 0x38(%rsp), %rdi
callq 0x16944
testl %eax, %eax
jne 0x24387
addl %ebx, %ebx
movw %r12w, -0x40(%rsp,%rbx)
movq 0x18(%rsp), %rax
movw %ax, -0x48(%rsp,%rbx)
jmp 0x24387
movq 0x10(%rsp), %rax
leaq 0x10(%rax), %rdi
xorl %ebx, %ebx
leaq 0xdeee(%rip), %rax      # 0x32678
movsbl (%rbx,%rax), %esi
leal (%r12,%rsi), %r9d
addl %r15d, %esi
movl %esi, %ecx
movl $0xffff, %r10d          # imm = 0xFFFF
andl %r10d, %ecx
movq %rcx, %rax
movabsq $0x28f5c28f5c28f5d, %rdx # imm = 0x28F5C28F5C28F5D
mulq %rdx
imulq $0x4b0, %rdx, %rax      # imm = 0x4B0
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imull $0x64, %ecx, %ecx
subl %ecx, %esi
andl %r10d, %esi
leaq (%rsi,%rsi,2), %rcx
leaq (%rax,%rcx,4), %rax
addq %rdi, %rax
xorl %ecx, %ecx
movsbl (%rax,%rcx), %edx
cmpl $-0x1, %edx
je 0x24840
leaq 0xde94(%rip), %rsi      # 0x3267c
movsbl (%rcx,%rsi), %esi
imull %edx, %esi
addl %r9d, %esi
movl %esi, %edx
movl $0xffff, %r11d          # imm = 0xFFFF
andl %r11d, %edx
shrl $0x2, %edx
imull $0x147b, %edx, %edx     # imm = 0x147B
shrl $0x11, %edx
imull $0x64, %edx, %r10d
subl %r10d, %esi
andl %r11d, %esi
leaq (%rsi,%rsi,2), %rsi
imulq $0x4b0, %rdx, %rdx      # imm = 0x4B0
addq 0x40(%rsp), %rdx
movsbl (%rdx,%rsi,4), %edx
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %r10
cmpw %dx, 0x1fbe8(%rsi,%r10,2)
je 0x24387
incq %rcx
cmpq $0x4, %rcx
jne 0x247d8
incq %rbx
cmpq $0x4, %rbx
jne 0x24783
jmp 0x2472e
movq 0x80(%rsp), %rdx
movq 0x68(%rsp), %rsi
incq %rsi
movzbl 0x1(%rdi), %ecx
decq %rcx
addl $0x64, %edx
cmpq %rcx, %rsi
jl 0x241b2
movq 0x28(%rsp), %xmm0
punpcklwd %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3]
pcmpeqw 0xa8e0(%rip), %xmm0     # 0x2f170
movmskps %xmm0, %ecx
xorl $0xf, %ecx
shll $0x2, %ecx
movabsq $0x4332322132212110, %rax # imm = 0x4332322132212110
shrq %cl, %rax
andl $0x7, %eax
cmpl 0x30(%rsp), %eax
jne 0x24b59
xorl %eax, %eax
movzwl 0x28(%rsp,%rax,2), %ecx
xorl %edx, %edx
testw %cx, %cx
je 0x24904
cmpw $0x0, 0x28(%rsp,%rdx,2)
je 0x24904
movzwl 0x60(%rsp,%rax,2), %esi
movzwl 0x60(%rsp,%rdx,2), %edi
movd %edi, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
paddd 0xdd3c(%rip), %xmm0     # 0x32620
movd %esi, %xmm1
pshuflw $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0,4,5,6,7]
punpcklwd 0xa87b(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1],xmm1[2],mem[2],xmm1[3],mem[3]
pcmpeqd %xmm0, %xmm1
movmskps %xmm1, %esi
testl %esi, %esi
jne 0x24b59
incq %rdx
cmpq $0x4, %rdx
jne 0x248bc
incq %rax
cmpq $0x4, %rax
jne 0x248b5
movq (%rbp), %rax
xorl %ecx, %ecx
cmpw $0x0, 0x28(%rsp,%rcx,2)
je 0x2494c
movzwl 0x60(%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 0x2491c
movw $0x50, %bp
xorl %r12d, %r12d
cmpw $0x0, 0x28(%rsp,%r12,2)
je 0x24b41
movzwl 0x60(%rsp,%r12,2), %r13d
movq 0x8(%rsp), %rax
movq (%rax), %rax
movzwl %r13w, %esi
movl %esi, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %r15d    # imm = 0x147B
shrl $0x11, %r15d
imulq $0x4b0, %r15, %rcx      # imm = 0x4B0
addq %rax, %rcx
imull $0x64, %r15d, %edx
subl %edx, %esi
movq %rsi, 0x10(%rsp)
movzwl %si, %r8d
leaq (%r8,%r8,2), %rdx
cmpb $0x0, 0xc(%rcx,%rdx,4)
jns 0x249dd
movzwl %r15w, %edx
movzwl 0x58(%rsp,%r12,2), %ecx
movzwl %bp, %r9d
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl %r8d, %esi
movq %r8, 0x20(%rsp)
xorl %r8d, %r8d
callq 0x25530
movq 0x20(%rsp), %r8
movq (%rbx), %rax
leal 0x1(%r13), %ecx
movl %ecx, %edx
andl %r14d, %edx
shrl $0x2, %edx
imull $0x147b, %edx, %edx     # imm = 0x147B
shrl $0x11, %edx
imulq $0x4b0, %rdx, %rsi      # imm = 0x4B0
addq %rax, %rsi
imull $0x64, %edx, %edx
subl %edx, %ecx
andl %r14d, %ecx
leaq (%rcx,%rcx,2), %rcx
cmpb $0x0, 0xc(%rsi,%rcx,4)
jns 0x24a44
movq 0x10(%rsp), %rax
incl %eax
movzwl %ax, %esi
movzwl %r15w, %edx
movzwl 0x58(%rsp,%r12,2), %ecx
movzwl %bp, %r9d
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r8, 0x20(%rsp)
xorl %r8d, %r8d
callq 0x25530
movq 0x20(%rsp), %r8
movq (%rbx), %rax
leal 0x64(%r13), %ecx
movl %ecx, %edx
andl %r14d, %edx
shrl $0x2, %edx
imull $0x147b, %edx, %edx     # imm = 0x147B
shrl $0x11, %edx
imulq $0x4b0, %rdx, %rsi      # imm = 0x4B0
addq %rax, %rsi
imull $0x64, %edx, %edx
subl %edx, %ecx
andl %r14d, %ecx
leaq (%rcx,%rcx,2), %rcx
cmpb $0x0, 0xc(%rsi,%rcx,4)
jns 0x24a9c
movzwl %r15w, %edx
incl %edx
movzwl 0x58(%rsp,%r12,2), %ecx
movzwl %bp, %r9d
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl %r8d, %esi
xorl %r8d, %r8d
callq 0x25530
movq (%rbx), %rax
addl $0x65, %r13d
movl %r13d, %ecx
andl %r14d, %ecx
shrl $0x2, %ecx
imull $0x147b, %ecx, %ecx     # imm = 0x147B
shrl $0x11, %ecx
imulq $0x4b0, %rcx, %rdx      # imm = 0x4B0
addq %rax, %rdx
imull $0x64, %ecx, %ecx
subl %ecx, %r13d
andl %r14d, %r13d
leaq (,%r13,2), %rcx
addq %r13, %rcx
cmpb $0x0, 0xc(%rdx,%rcx,4)
js 0x24adf
movzwl 0x58(%rsp,%r12,2), %ebx
jmp 0x24b15
movq 0x10(%rsp), %rax
incl %eax
movzwl %ax, %esi
movzwl %r15w, %edx
incl %edx
movzwl 0x58(%rsp,%r12,2), %ebx
movzwl %bp, %r9d
movzwl %bx, %ecx
movq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %r8d, %r8d
callq 0x25530
movq (%r14), %rax
movl $0xffff, %r14d          # imm = 0xFFFF
movzwl %bx, %ecx
movl %ecx, %edx
shrl $0x2, %edx
imull $0x147b, %edx, %edx     # imm = 0x147B
shrl $0x11, %edx
imulq $0x4b0, %rdx, %rsi      # imm = 0x4B0
addq %rax, %rsi
imull $0x64, %edx, %eax
subl %eax, %ecx
movzwl %cx, %eax
leaq (%rax,%rax,2), %rax
movb %bpl, 0xc(%rsi,%rax,4)
incq %r12
incl %ebp
cmpq $0x4, %r12
jne 0x2495c
incl 0x54(%rsp)
movq 0x8(%rsp), %rbp
movq (%rbp), %rcx
movl 0x7c(%rsp), %eax
cmpl %eax, 0x8(%rcx)
jl 0x23e58
movslq 0x4(%rcx), %rax
testq %rax, %rax
jle 0x2530e
movl (%rcx), %edx
leal 0x7(%rdx), %esi
andl $-0x8, %esi
movq %rdx, %rdi
decq %rdi
movq %rdi, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq 0x1fbf6(%rcx), %rdi
xorl %r8d, %r8d
movdqa 0xda9f(%rip), %xmm2     # 0x32640
movdqa 0xae07(%rip), %xmm3     # 0x2f9b0
movdqa 0xa7bf(%rip), %xmm4     # 0x2f370
movdqa 0xae07(%rip), %xmm5     # 0x2f9c0
pxor %xmm5, %xmm0
pcmpeqd %xmm6, %xmm6
movdqa 0xda87(%rip), %xmm7     # 0x32650
xorl %r9d, %r9d
testl %edx, %edx
jle 0x24e7e
xorl %r10d, %r10d
movdqa %xmm4, %xmm8
movdqa %xmm3, %xmm9
movdqa %xmm2, %xmm10
movdqa 0xda41(%rip), %xmm11    # 0x32630
movdqa %xmm8, %xmm12
pxor %xmm5, %xmm12
movdqa %xmm12, %xmm14
pcmpgtd %xmm0, %xmm14
pshufd $0xa0, %xmm14, %xmm13   # xmm13 = xmm14[0,0,2,2]
pshuflw $0xe8, %xmm13, %xmm15   # xmm15 = xmm13[0,2,2,3,4,5,6,7]
pcmpeqd %xmm0, %xmm12
pshufd $0xf5, %xmm12, %xmm12   # xmm12 = xmm12[1,1,3,3]
pshuflw $0xe8, %xmm12, %xmm1    # xmm1 = xmm12[0,2,2,3,4,5,6,7]
pand %xmm15, %xmm1
pshufd $0xf5, %xmm14, %xmm14   # xmm14 = xmm14[1,1,3,3]
pshuflw $0xe8, %xmm14, %xmm15   # xmm15 = xmm14[0,2,2,3,4,5,6,7]
por %xmm1, %xmm15
pxor %xmm6, %xmm15
packssdw %xmm15, %xmm15
movd %xmm15, %r11d
testb $0x1, %r11b
je 0x24c55
leal (%r8,%r10), %r11d
movw %r11w, -0xe(%rdi,%r10,2)
pand %xmm13, %xmm12
por %xmm14, %xmm12
packssdw %xmm12, %xmm12
pxor %xmm6, %xmm12
packssdw %xmm12, %xmm12
movd %xmm12, %r11d
shrl $0x10, %r11d
testb $0x1, %r11b
je 0x24c8a
leal (%r8,%r10), %r11d
incl %r11d
movw %r11w, -0xc(%rdi,%r10,2)
movdqa %xmm9, %xmm1
pxor %xmm5, %xmm1
movdqa %xmm1, %xmm14
pcmpgtd %xmm0, %xmm14
pshufd $0xa0, %xmm14, %xmm12   # xmm12 = xmm14[0,0,2,2]
pcmpeqd %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm13    # xmm13 = xmm1[1,1,3,3]
movdqa %xmm13, %xmm1
pand %xmm12, %xmm1
pshufd $0xf5, %xmm14, %xmm14   # xmm14 = xmm14[1,1,3,3]
por %xmm14, %xmm1
packssdw %xmm1, %xmm1
pxor %xmm6, %xmm1
packssdw %xmm1, %xmm1
pextrw $0x2, %xmm1, %r11d
testb $0x1, %r11b
je 0x24ce8
leal (%r8,%r10), %r11d
addl $0x2, %r11d
movw %r11w, -0xa(%rdi,%r10,2)
pshufhw $0x84, %xmm12, %xmm1    # xmm1 = xmm12[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm13, %xmm12   # xmm12 = xmm13[0,1,2,3,4,5,4,6]
pand %xmm1, %xmm12
pshufhw $0x84, %xmm14, %xmm1    # xmm1 = xmm14[0,1,2,3,4,5,4,6]
por %xmm12, %xmm1
pxor %xmm6, %xmm1
packssdw %xmm1, %xmm1
pextrw $0x3, %xmm1, %r11d
testb $0x1, %r11b
je 0x24d26
leal (%r8,%r10), %r11d
addl $0x3, %r11d
movw %r11w, -0x8(%rdi,%r10,2)
movdqa %xmm10, %xmm1
pxor %xmm5, %xmm1
movdqa %xmm1, %xmm14
pcmpgtd %xmm0, %xmm14
pshufd $0xa0, %xmm14, %xmm13   # xmm13 = xmm14[0,0,2,2]
pshuflw $0xe8, %xmm13, %xmm15   # xmm15 = xmm13[0,2,2,3,4,5,6,7]
pcmpeqd %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm12    # xmm12 = xmm1[1,1,3,3]
pshuflw $0xe8, %xmm12, %xmm1    # xmm1 = xmm12[0,2,2,3,4,5,6,7]
pand %xmm15, %xmm1
pshufd $0xf5, %xmm14, %xmm14   # xmm14 = xmm14[1,1,3,3]
pshuflw $0xe8, %xmm14, %xmm15   # xmm15 = xmm14[0,2,2,3,4,5,6,7]
por %xmm1, %xmm15
pxor %xmm6, %xmm15
packssdw %xmm15, %xmm1
pextrw $0x4, %xmm1, %r11d
testb $0x1, %r11b
je 0x24d8f
leal (%r8,%r10), %r11d
addl $0x4, %r11d
movw %r11w, -0x6(%rdi,%r10,2)
pand %xmm13, %xmm12
por %xmm14, %xmm12
packssdw %xmm12, %xmm12
pxor %xmm6, %xmm12
packssdw %xmm12, %xmm1
pextrw $0x5, %xmm1, %r11d
testb $0x1, %r11b
je 0x24dc2
leal (%r8,%r10), %r11d
addl $0x5, %r11d
movw %r11w, -0x4(%rdi,%r10,2)
movdqa %xmm11, %xmm1
pxor %xmm5, %xmm1
movdqa %xmm1, %xmm14
pcmpgtd %xmm0, %xmm14
pshufd $0xa0, %xmm14, %xmm12   # xmm12 = xmm14[0,0,2,2]
pcmpeqd %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm13    # xmm13 = xmm1[1,1,3,3]
movdqa %xmm13, %xmm1
pand %xmm12, %xmm1
pshufd $0xf5, %xmm14, %xmm14   # xmm14 = xmm14[1,1,3,3]
por %xmm14, %xmm1
packssdw %xmm1, %xmm1
pxor %xmm6, %xmm1
packssdw %xmm1, %xmm1
pextrw $0x6, %xmm1, %r11d
testb $0x1, %r11b
je 0x24e20
leal (%r8,%r10), %r11d
addl $0x6, %r11d
movw %r11w, -0x2(%rdi,%r10,2)
pshufhw $0x84, %xmm12, %xmm1    # xmm1 = xmm12[0,1,2,3,4,5,4,6]
pshufhw $0x84, %xmm13, %xmm12   # xmm12 = xmm13[0,1,2,3,4,5,4,6]
pand %xmm1, %xmm12
pshufhw $0x84, %xmm14, %xmm1    # xmm1 = xmm14[0,1,2,3,4,5,4,6]
por %xmm12, %xmm1
pxor %xmm6, %xmm1
packssdw %xmm1, %xmm1
pextrw $0x7, %xmm1, %r11d
testb $0x1, %r11b
je 0x24e5d
leal (%r8,%r10), %r11d
addl $0x7, %r11d
movw %r11w, (%rdi,%r10,2)
addq $0x8, %r10
paddq %xmm7, %xmm8
paddq %xmm7, %xmm9
paddq %xmm7, %xmm10
paddq %xmm7, %xmm11
cmpq %r10, %rsi
jne 0x24bef
incq %r9
addq $0x64, %r8
addq $0xc8, %rdi
cmpq %rax, %r9
jne 0x24bcc
testl %eax, %eax
jle 0x2530e
movq $-0xc, %rsi
movq $-0x4b0, %rdx           # imm = 0xFB50
xorl %edi, %edi
movq $-0x4b0, %r13           # imm = 0xFB50
xorl %r11d, %r11d
cmpl $0x0, (%rcx)
movq %rsi, 0x18(%rsp)
movq %rdi, 0x48(%rsp)
movq %r13, 0x70(%rsp)
jle 0x25168
imulq $0x64, %r11, %rax
movq %rax, 0x20(%rsp)
imulq $0x4b0, %r11, %rax      # imm = 0x4B0
movq %rax, 0x10(%rsp)
movq %rsi, %rbp
movq %rdi, %rsi
xorl %r8d, %r8d
movq 0x10(%rsp), %rax
addq %rcx, %rax
addq $0xc, %rax
leaq (%r8,%r8,2), %rdi
cmpb $0x0, (%rax,%rdi,4)
js 0x25143
leaq 0xc(%rcx), %r9
leaq (%rax,%rdi,4), %rdi
movq 0x20(%rsp), %rax
addq %r8, %rax
movzwl 0x1fbe8(%rcx,%rax,2), %r10d
movswq 0x2(%rdi), %rbx
movzwl 0x1fbe8(%rcx,%rbx,2), %ebx
movw %bx, 0x1fbe8(%rcx,%rax,2)
movswq 0x2(%rdi), %rax
movw %r10w, 0x1fbe8(%rcx,%rax,2)
movzwl 0x2(%rdi), %eax
movl %eax, %r10d
shrl $0x2, %r10d
imull $0x147b, %r10d, %r10d   # imm = 0x147B
shrl $0x11, %r10d
imull $0x64, %r10d, %ebx
subl %ebx, %eax
movzwl %ax, %eax
imulq $0x4b0, %r10, %r10      # imm = 0x4B0
addq %r9, %r10
leaq (%rax,%rax,2), %rax
movzbl (%r10,%rax,4), %eax
movb %al, (%rdi)
cmpb $0x50, %al
movl $0x10, %r9d
cmovgel %r9d, %eax
movb %al, 0x1(%rdi)
movq $-0x1, %r14
movq %rbp, %r9
movq %rsi, %rbx
xorl %r10d, %r10d
movq %r9, %r15
leaq (%r8,%r10), %r9
testq %r9, %r9
jle 0x25055
movq %r10, %rax
movzbl (%rcx,%rbx), %r12d
incq %r14
decq %r10
addq $-0xc, %rbx
leaq -0xc(%r15), %r9
cmpl $0xff, %r12d
je 0x24f96
cmpl $0xfe, %r12d
je 0x25055
negb %r10b
movb %r10b, 0x6(%rdi)
movq 0x8(%rsp), %r12
movq (%r12), %rcx
movb %r10b, 0x10(%rcx,%rbx)
movq %r8, %rcx
subq %r14, %rcx
cmpq %r8, %rcx
jge 0x2502a
negq %rax
movb $0x1, %cl
movq (%r12), %r9
movb %al, 0x1c(%r9,%r15)
movq (%r12), %r9
movb %cl, 0x1e(%r9,%r15)
movb 0xa(%rdi), %r9b
movq (%r12), %r10
movb %r9b, 0x20(%r10,%r15)
movq (%r12), %r10
movb %r9b, 0x22(%r10,%r15)
addq $0xc, %r15
incb %cl
decq %rax
jne 0x24ff7
movq (%r12), %rax
movzwl 0xe(%rax,%rbx), %eax
cmpw 0x2(%rdi), %ax
sete %al
testl %r14d, %r14d
sete %cl
testb %cl, %al
je 0x25055
movb $0x3, %cl
movb %cl, 0xa(%rdi)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movb %cl, 0x14(%rax,%rbx)
movq 0x8(%rsp), %rax
movq (%rax), %r14
movq $-0x1, %rbx
movq %r13, %r15
movq %rsi, %rcx
xorl %r10d, %r10d
movq %r10, %rax
addq %r11, %r10
testq %r10, %r10
jle 0x25143
movq %r15, %r9
movzbl -0x4a4(%r14,%rcx), %r12d
incq %rbx
leaq -0x1(%rax), %r10
addq %rdx, %rcx
addq %rdx, %r15
cmpl $0xff, %r12d
je 0x2506d
cmpl $0xfe, %r12d
je 0x25143
negb %r10b
movb %r10b, 0x5(%rdi)
movq 0x8(%rsp), %r12
movq (%r12), %r14
movb %r10b, 0x13(%r14,%rcx)
movq %r11, %r10
subq %rbx, %r10
cmpq %r11, %r10
jge 0x25114
negq %rax
movb $0x1, %r14b
movq (%r12), %r10
movb %r14b, 0x4c1(%r10,%r9)
movq (%r12), %r10
movb %al, 0x4c3(%r10,%r9)
movb 0x9(%rdi), %r10b
movq (%r12), %r15
movb %r10b, 0x4c5(%r15,%r9)
movq (%r12), %r15
movb %r10b, 0x4c7(%r15,%r9)
addq $0x4b0, %r9             # imm = 0x4B0
incb %r14b
decq %rax
jne 0x250d1
movq (%r12), %rax
movzwl 0xe(%rax,%rcx), %eax
cmpw 0x2(%rdi), %ax
sete %al
testl %ebx, %ebx
sete %r9b
testb %r9b, %al
je 0x25143
movb $0x3, %r9b
movb %r9b, 0x9(%rdi)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movb %r9b, 0x17(%rax,%rcx)
incq %r8
movq 0x8(%rsp), %rax
movq (%rax), %rcx
movslq (%rcx), %rax
addq $0xc, %rsi
addq $0xc, %rbp
addq $0xc, %r13
cmpq %rax, %r8
jl 0x24eed
jmp 0x2516c
movq (%rbp), %rcx
incq %r11
movslq 0x4(%rcx), %rax
movq 0x48(%rsp), %rdi
movl $0x4b0, %r8d            # imm = 0x4B0
addq %r8, %rdi
movq 0x18(%rsp), %rsi
addq %r8, %rsi
movq 0x70(%rsp), %r13
addq %r8, %r13
cmpq %rax, %r11
movq 0x8(%rsp), %rbp
jl 0x24eb7
testl %eax, %eax
jle 0x2530e
xorl %edx, %edx
movl $0xffff, %r12d          # imm = 0xFFFF
movl (%rcx), %eax
testl %eax, %eax
movq %rdx, 0x18(%rsp)
jle 0x252f9
imulq $0x64, %rdx, %rdi
imulq $0x4b0, %rdx, %r8       # imm = 0x4B0
xorl %r13d, %r13d
movq %rdi, 0x10(%rsp)
movq %r8, 0x20(%rsp)
leaq (%rcx,%r8), %rdx
leaq (,%r13,2), %rsi
addq %r13, %rsi
cmpb $0x0, 0xc(%rdx,%rsi,4)
js 0x252ea
leaq (%rdi,%r13), %rbx
movswq 0x1fbe8(%rcx,%rbx,2), %rdx
movl %edx, %edx
cmpq %rdx, %rbx
je 0x252ea
xorl %ebp, %ebp
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %ebx, %r15d
movl %r15d, %eax
andl %r12d, %eax
shrl $0x2, %eax
imull $0x147b, %eax, %eax     # imm = 0x147B
shrl $0x11, %eax
imulq $0x4b0, %rax, %rdx      # imm = 0x4B0
addq %rcx, %rdx
imull $0x64, %eax, %eax
movl %r15d, %esi
subl %eax, %esi
andl %r12d, %esi
leaq (%rsi,%rsi,2), %rsi
movb 0x14(%rdx,%rsi,4), %al
cmpb $0x50, 0xc(%rdx,%rsi,4)
movb 0x17(%rdx,%rsi,4), %dl
jl 0x25258
xorb $0x3, %dl
xorb $0x3, %al
orb %dl, %al
je 0x25269
jmp 0x25285
cmpb $0x3, %dl
sete %dl
cmpb $0x3, %al
sete %al
orb %dl, %al
cmpb $0x1, %al
jne 0x25285
incl %ebp
movq 0x38(%rsp), %rdi
movl %ebp, %esi
callq 0x16944
testl %eax, %eax
cmovel %r15d, %r14d
movq 0x8(%rsp), %rax
movq (%rax), %rcx
movslq %r15d, %rax
movswl 0x1fbe8(%rcx,%rax,2), %r15d
cmpq %r15, %rbx
jne 0x25213
leaq 0xc(%rcx), %rax
movl %r15d, %edx
andl %r12d, %edx
shrl $0x2, %edx
imull $0x147b, %edx, %edx     # imm = 0x147B
shrl $0x11, %edx
imull $0x64, %edx, %esi
movslq %r15d, %rdi
subl %esi, %r15d
andl %r12d, %r15d
imulq $0x4b0, %rdx, %rdx      # imm = 0x4B0
addq %rax, %rdx
leaq (%r15,%r15,2), %rsi
movw %r14w, 0x2(%rdx,%rsi,4)
movswl 0x1fbe8(%rcx,%rdi,2), %r15d
cmpq %r15, %rbx
jne 0x2529e
movl (%rcx), %eax
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %r8
incq %r13
movslq %eax, %rdx
cmpq %rdx, %r13
jl 0x251d6
movq 0x18(%rsp), %rdx
incq %rdx
movslq 0x4(%rcx), %rax
cmpq %rax, %rdx
jl 0x251af
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq