// File: lotuskip[P]yuxtapa/server/actives.cpp
// Function: do_placement()
void do_placement()
{
	short tmp;
	// empty previous stuff
	for(tmp = 0; tmp < MAX_NOE; ++tmp)
		noccents[tmp].clear();
	traps.clear();
	boulders.clear();
	PCs.clear();
	MMs.clear();
	arrows.clear();
	zaps.clear();
	team_flags[T_GREEN].clear();
	team_flags[T_PURPLE].clear();

	// we'll be using the nearby search in placement; see spiral.h
	short msize = Game::curmap->get_size();
	nearby_set_dim(msize);

	vector<Coords> used_coords;
	Coords c, d;
	// First place blocks (occent) and traps (noccent) in a single loop:
	// anywhere on a floor/ground/road tile
	for(c.y = 0; c.y < msize; c.y++)
	{
		for(c.x = 0; c.x < msize; c.x++)
		{
			// traps & blocks go only at open spaces:
			if(Game::curmap->get_tile(c).symbol == '.')
			{
				if(!(random()%TRAP_ONE_IN))
				{
					// random trap type:
					traps.push_back(Trap(c, random()%MAX_TRAP_TYPE, cur_players.end()));
					Game::curmap->mod_tile(c)->flags |= TF_TRAP;
					used_coords.push_back(c);
				}
				if(!(random()%BLOCK_ONE_IN))
				{
					add_block(c);
					// we might end up adding the same coords twice, but that
					// doesn't matter:
					used_coords.push_back(c);
				}
			}
		}
	}
	// Torches in a grid, but not if uninhabited
	if(Game::curmap->is_inhabited())
	{
		for(c.y = TORCH_GRID/2; c.y < msize; c.y += TORCH_GRID)
		{
			for(c.x = TORCH_GRID/2; c.x < msize; c.x += TORCH_GRID)
			{
				if(random()%100 >= CHANCE_NO_TORCH)
				{
					d = c;
					next_unused_tile(d, used_coords);
					add_noccent(d, NOE_TORCH);
				}
			}
		}
	}
	// Flags.
	// One green flag in a random corner:
	e_Dir green_corner = e_Dir(1 + 2*(random()%3));
	d = Game::curmap->get_center_of_sector(green_corner);
	next_unused_tile(d, used_coords, true);
	add_noccent(d, NOE_FLAG, T_GREEN);
	// A purple flag at the opposite side of the map:
	e_Dir purple_corner = !green_corner;
	// possibly rotate so that this flag won't be in a corner:
	switch(random()%3)
	{
	case 0: ++purple_corner; break;
	case 1: --purple_corner; break;
	// case 2: nothing
	}
	d = Game::curmap->get_center_of_sector(purple_corner);
	next_unused_tile(d, used_coords, true);
	add_noccent(d, NOE_FLAG, T_PURPLE);
	/* The result so far is either
	 * G..      G..
	 * ...   or ...   (or some rotated or mirrored version of these)
	 * ..P      .P.
	 */
	// Some more flags depending on mapsize & game mode:
	e_Dir tmpd;
	switch(gamemode)
	{
	case GM_DESTR:
	case GM_DOM:
		// Two neutral flags more always:
		tmpd = green_corner;
		++tmpd;
		if(random()%2) ++tmpd;
		d = Game::curmap->get_center_of_sector(tmpd);
		next_unused_tile(d, used_coords, true);
		add_noccent(d, NOE_FLAG, T_NO_TEAM);
		/* This makes it either
		 * GN.       G.N
		 * ..p   or  ..p   (or some rotation/mirroring of these,
		 * .pp       .pp    + the purple flag in one of the p:s)
		 */
		tmpd = green_corner;
		--tmpd;
		if(random()%2) --tmpd;
		d = Game::curmap->get_center_of_sector(tmpd);
		next_unused_tile(d, used_coords, true);
		add_noccent(d, NOE_FLAG, T_NO_TEAM);
		/* And that added another 'N' on the other side of 'G' */
		// On large maps, one more in central area:
		if(msize >= BIG_MAP_LIM)
		{
			d.y = d.x = msize/2;
			next_unused_tile(d, used_coords, true);
			add_noccent(d, NOE_FLAG, T_NO_TEAM);
		}
		break;
	case GM_CONQ:
		// add one purple-own 3rd flag in central area:
		d.y = d.x = msize/2;
		next_unused_tile(d, used_coords, true);
		add_noccent(d, NOE_FLAG, T_PURPLE);
		break;
	case GM_STEAL:
		/* Give the purples another flag, and also position the item here.
		 * It's going to be:
		 * GN.       G..
		 * .Pi   or  N.P    (where 'i' is the item)
		 * ..P       .Pi
		 */
		if(!(int(purple_corner)%2)) // existing P is not in the corner
		{
			// item:
			tmpd = !green_corner;
			d = Game::curmap->get_center_of_sector(tmpd);
			next_unused_tile(d, used_coords);
			the_item.setpos(d);
			obj_sector = tmpd;
			// flag:
			if(++tmpd == purple_corner)
				--(--tmpd);
			d = Game::curmap->get_center_of_sector(tmpd);
			next_unused_tile(d, used_coords, true);
			add_noccent(d, NOE_FLAG, T_PURPLE);
		}
		else // purple flag is in the corner
		{
			// flag:
			d.y = d.x = msize/2;
			next_unused_tile(d, used_coords, true);
			add_noccent(d, NOE_FLAG, T_PURPLE);
			// item:
			tmpd = !green_corner;
			if(random()%2) ++tmpd;
			else --tmpd;
			d = Game::curmap->get_center_of_sector(tmpd);
			next_unused_tile(d, used_coords);
			the_item.setpos(d);
			obj_sector = tmpd;
		}
		the_item.set_col(C_LIGHT_TRAP);
		// Give the greens a neutral vantage-point (always):
		tmpd = green_corner;
		if(random()%2) ++tmpd;
		else --tmpd;
		d = Game::curmap->get_center_of_sector(tmpd);
		next_unused_tile(d, used_coords, true);
		add_noccent(d, NOE_FLAG, T_NO_TEAM);
		break;
	case GM_TDM: break; // no additional flags
	} // switch game-mode (for flag positioning)
	//
	// Portals:
	// The possibilities are:
	// 2 portals:
	//      * 2 two-ways
	//      * 1 entry, 1 exit
	// 3 portals:
	//      * 3 two-ways
	//      * 2 entries, 1 exit
	//      * 1 entry, 2 exits
	// 	4 portals:
	//      * 4 two-ways
	//      * 2 two-ways, 1 entry, 1 exit
	//      * 1+n entries, 3-n exits (n=0..2)
	// 1. Determine the number of portals to place, if any.
	if(random()%100 < CHANCE_PORTALS)
	{
		vector<Coords> portals(2+random()%3);
		// 2. Collect the coordinates for the portals.
		// First one is just a random point:
		portals[0].x = random()%msize;
		portals[0].y = random()%msize;
		// Second one in the corner furthest away from the first:
		if(portals[0].x < msize/2)
			portals[1].x = msize - 2 - random()%PORTALS_FROM_EDGE;
		else
			portals[1].x = 2 + random()%PORTALS_FROM_EDGE;
		if(portals[0].y < msize/2)
			portals[1].y = msize - 2 - random()%PORTALS_FROM_EDGE;
		else
			portals[1].y = 2 + random()%PORTALS_FROM_EDGE;
		// Third one, if needed:
		if(portals.size() > 2)
		{
			portals[2].x = (portals[0].x + portals[1].x)/2;
			portals[2].y = (portals[0].y + portals[1].y)%msize;
			// Fourth one, if needed:
			if(portals.size() > 3)
			{
				portals[3].x = (portals[0].x + portals[1].x)%msize;
				portals[3].y = (portals[0].y + portals[1].y)/2;
			}
		}
		// 3. Determine what kind of portals to place in these coordinates (above)
		bool twoways = random()%2;
		// place at "the last and second to last coordinates" (either
		// 2 two-ways or 1 entry and 1 exit
		d = portals[portals.size()-1];
		next_unused_tile(d, used_coords);
		if(twoways)
			add_noccent(d, NOE_PORTAL_2WAY);
		else
			add_noccent(d, NOE_PORTAL_ENTRY);
		d = portals[portals.size()-2];
		next_unused_tile(d, used_coords);
		if(twoways)
			add_noccent(d, NOE_PORTAL_2WAY);
		else
			add_noccent(d, NOE_PORTAL_EXIT);
		// If there are 3 portals, add a third two-way, an entry, or an exit:
		if(portals.size()==3)
		{
			d = portals[0];
			next_unused_tile(d, used_coords);
			if(twoways)
				add_noccent(d, NOE_PORTAL_2WAY);
			else if(random()%2)
				add_noccent(d, NOE_PORTAL_ENTRY);
			else
				add_noccent(d, NOE_PORTAL_EXIT);
		}
		else if(portals.size()==4)
		{
			// We have so far either (A) 2 two-ways or (B) 1 one-way entry and 1 exit.
			// In case (A), may add 2 more two-ways or 1 entry & 1 exit.
			// In case (B) may add 2 more two-ways or 2 elements from {entry, exit}.
			// Hence, check if we want more 2-ways:
			if(random()%2) // yes!
			{
				for(char ch = 0; ch < 2; ++ch)
				{
					d = portals[ch];
					next_unused_tile(d, used_coords);
					add_noccent(d, NOE_PORTAL_2WAY);
				}
			}
			else if(twoways) // need 1 entry and 1 exit
			{
				d = portals[0];
				next_unused_tile(d, used_coords);
				add_noccent(d, NOE_PORTAL_ENTRY);
				d = portals[1];
				next_unused_tile(d, used_coords);
				add_noccent(d, NOE_PORTAL_EXIT);
			}
			else // may add freely entries/exits
			{
				for(char ch = 0; ch < 2; ++ch)
				{
					d = portals[ch];
					next_unused_tile(d, used_coords);
					if(random()%2)
						add_noccent(d, NOE_PORTAL_ENTRY);
					else
						add_noccent(d, NOE_PORTAL_EXIT);
				}
			}
		} // four portals
	}
	// Blocks for block destroying objective:
	if(gamemode == GM_DESTR)
	{
		// put blocks in a sector not too close to the green flag
		do
			obj_sector = e_Dir(random()%(MAX_D+1));
		while(obj_sector == green_corner || obj_sector == purple_corner);
		c = Game::curmap->get_center_of_sector(obj_sector);
		for(char j = 0; j < NUM_DESTROY_BLOCKS; ++j)
		{
			d = c;
			// These blocks can go anywhere where other entities can:
			next_unused_tile(d, used_coords);
			add_block(d);
		}
	}
	// Block sources (0-2 at random locations)
	for(tmp = random()%3; tmp > 0; --tmp)
	{
		c.x = 5 + random()%(Game::curmap->get_size()-10);
		c.y = 5 + random()%(Game::curmap->get_size()-10);
		next_unused_tile(c, used_coords);
		add_noccent(c, NOE_BLOCK_SOURCE);
	}	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movw $0x0, -0x2(%rbp)
movswl -0x2(%rbp), %eax
cmpl $0x7, %eax
jge 0x465e0
movswq -0x2(%rbp), %rax
leaq 0x4c96a(%rip), %rdi     # 0x92f30
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x49de0
movw -0x2(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x2(%rbp)
jmp 0x465b1
leaq 0x4c9f1(%rip), %rdi     # 0x92fd8
callq 0x49e10
leaq 0x4c9fd(%rip), %rdi     # 0x92ff0
callq 0x49e40
leaq 0x4ca51(%rip), %rdi     # 0x93050
callq 0x49e70
leaq 0x4ca15(%rip), %rdi     # 0x93020
callq 0x49ea0
leaq 0x4c9f1(%rip), %rdi     # 0x93008
callq 0x49ed0
leaq 0x4ca15(%rip), %rdi     # 0x93038
callq 0x49f00
leaq 0x4ca41(%rip), %rdi     # 0x93070
callq 0x3dc50
leaq 0x4ca4d(%rip), %rdi     # 0x93088
callq 0x3dc50
leaq 0x4b791(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
callq 0x3c930
movw %ax, -0x4(%rbp)
movswl -0x4(%rbp), %edi
callq 0x4ebd0
leaq -0x20(%rbp), %rdi
callq 0x49f30
leaq -0x24(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x60430
jmp 0x46674
leaq -0x38(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x60430
jmp 0x46683
movw $0x0, -0x22(%rbp)
movswl -0x22(%rbp), %eax
movswl -0x4(%rbp), %ecx
cmpl %ecx, %eax
jge 0x46860
movw $0x0, -0x24(%rbp)
movswl -0x24(%rbp), %eax
movswl -0x4(%rbp), %ecx
cmpl %ecx, %eax
jge 0x4684d
leaq 0x4b722(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
leaq -0x24(%rbp), %rsi
callq 0x3dcd0
movl %eax, -0xc0(%rbp)
jmp 0x466ca
movl -0xc0(%rbp), %eax
movl %eax, -0x3c(%rbp)
movsbl -0x3a(%rbp), %eax
cmpl $0x2e, %eax
jne 0x4683a
callq 0x5270
movl $0x55, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
jne 0x46807
callq 0x5270
movq %rax, -0xd0(%rbp)
movabsq $0x2aaaaaaaaaaaaaab, %rcx # imm = 0x2AAAAAAAAAAAAAAB
imulq %rcx
movq -0xd0(%rbp), %rax
movq %rdx, %rcx
movl %ecx, %edx
shrq $0x3f, %rcx
addl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
movl %eax, -0xc4(%rbp)
leaq 0x49af6(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, %rcx
movl -0xc4(%rbp), %eax
movq %rcx, -0x68(%rbp)
movq -0x68(%rbp), %rcx
movzbl %al, %edx
leaq -0x60(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x4d7d0
jmp 0x46762
leaq 0x4c86f(%rip), %rdi     # 0x92fd8
leaq -0x60(%rbp), %rsi
callq 0x49f50
jmp 0x46774
leaq -0x60(%rbp), %rdi
callq 0x49f90
leaq 0x4b654(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
leaq -0x24(%rbp), %rsi
callq 0x3d2d0
movq %rax, -0xd8(%rbp)
jmp 0x46799
movq -0xd8(%rbp), %rax
movb 0x1(%rax), %cl
orb $0x8, %cl
movb %cl, 0x1(%rax)
leaq -0x20(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x2e630
jmp 0x467b8
jmp 0x46807
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x478a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x4789b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x47892
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x49f90
jmp 0x47892
callq 0x5270
movl $0xbe, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
jne 0x46838
leaq -0x24(%rbp), %rdi
callq 0x478c0
jmp 0x46827
leaq -0x20(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x2e630
jmp 0x46836
jmp 0x46838
jmp 0x4683a
jmp 0x4683c
movw -0x24(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x24(%rbp)
jmp 0x4669f
jmp 0x4684f
movw -0x22(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x22(%rbp)
jmp 0x46689
leaq 0x4b571(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
callq 0x49fb0
movb %al, -0xd9(%rbp)
jmp 0x46877
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0x46886
jmp 0x4690a
movw $0x8, -0x22(%rbp)
movswl -0x22(%rbp), %eax
movswl -0x4(%rbp), %ecx
cmpl %ecx, %eax
jge 0x46908
movw $0x8, -0x24(%rbp)
movswl -0x24(%rbp), %eax
movswl -0x4(%rbp), %ecx
cmpl %ecx, %eax
jge 0x468f9
callq 0x5270
movl $0x64, %ecx
cqto
idivq %rcx
cmpq $0x1e, %rdx
jl 0x468ea
movl -0x24(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47950
jmp 0x468d6
leaq -0x38(%rbp), %rdi
movl $0x6, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x468e8
jmp 0x468ea
jmp 0x468ec
movswl -0x24(%rbp), %eax
addl $0x11, %eax
movw %ax, -0x24(%rbp)
jmp 0x4689e
jmp 0x468fb
movswl -0x22(%rbp), %eax
addl $0x11, %eax
movw %ax, -0x22(%rbp)
jmp 0x4688c
jmp 0x4690a
callq 0x5270
movq %rax, %rcx
movabsq $0x5555555555555556, %rdx # imm = 0x5555555555555556
movq %rcx, %rax
imulq %rdx
movq %rdx, %rax
movl %eax, %edx
shrq $0x3f, %rax
addl %eax, %edx
movl %edx, %eax
leal (%rax,%rax,2), %eax
subl %eax, %ecx
movl %ecx, %eax
leal 0x1(%rax,%rax), %eax
movl %eax, -0x6c(%rbp)
leaq 0x4b494(%rip), %rax     # 0x91dd8
movq (%rax), %rsi
movl -0x6c(%rbp), %edx
leaq -0x70(%rbp), %rdi
callq 0x2bab0
jmp 0x46955
movl -0x70(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x60460
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x47950
jmp 0x46978
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x4698a
movl -0x6c(%rbp), %edi
callq 0x60410
movl %eax, -0xe0(%rbp)
jmp 0x4699a
movl -0xe0(%rbp), %eax
movl %eax, -0x74(%rbp)
callq 0x5270
movq %rax, -0xf0(%rbp)
movabsq $0x5555555555555556, %rcx # imm = 0x5555555555555556
imulq %rcx
movq -0xf0(%rbp), %rax
movq %rdx, %rcx
shrq $0x3f, %rcx
addq %rcx, %rdx
leaq (%rdx,%rdx,2), %rcx
subq %rcx, %rax
movq %rax, -0xe8(%rbp)
je 0x469ee
jmp 0x469df
movq -0xe8(%rbp), %rax
subq $0x1, %rax
je 0x469fb
jmp 0x46a08
leaq -0x74(%rbp), %rdi
callq 0x60390
jmp 0x469f9
jmp 0x46a08
leaq -0x74(%rbp), %rdi
callq 0x603d0
jmp 0x46a06
jmp 0x46a08
leaq 0x4b3c9(%rip), %rax     # 0x91dd8
movq (%rax), %rsi
movl -0x74(%rbp), %edx
leaq -0x78(%rbp), %rdi
callq 0x2bab0
jmp 0x46a20
movl -0x78(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x60460
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x47950
jmp 0x46a43
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
movl $0x1, %edx
callq 0x47b10
jmp 0x46a58
leaq 0x4a935(%rip), %rax     # 0x91394
movl (%rax), %eax
movq %rax, -0xf8(%rbp)
subq $0x4, %rax
ja 0x46ee1
movq -0xf8(%rbp), %rax
leaq 0x1f840(%rip), %rcx     # 0x662c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x6c(%rbp), %eax
movl %eax, -0x7c(%rbp)
leaq -0x7c(%rbp), %rdi
callq 0x60390
jmp 0x46a9a
callq 0x5270
movl $0x2, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0x46abc
leaq -0x7c(%rbp), %rdi
callq 0x60390
jmp 0x46aba
jmp 0x46abc
leaq 0x4b315(%rip), %rax     # 0x91dd8
movq (%rax), %rsi
movl -0x7c(%rbp), %edx
leaq -0x80(%rbp), %rdi
callq 0x2bab0
jmp 0x46ad4
movl -0x80(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x60460
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x47950
jmp 0x46af7
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
movl $0x3, %edx
callq 0x47b10
jmp 0x46b0c
movl -0x6c(%rbp), %eax
movl %eax, -0x7c(%rbp)
leaq -0x7c(%rbp), %rdi
callq 0x603d0
jmp 0x46b1d
callq 0x5270
movl $0x2, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0x46b3f
leaq -0x7c(%rbp), %rdi
callq 0x603d0
jmp 0x46b3d
jmp 0x46b3f
leaq 0x4b292(%rip), %rax     # 0x91dd8
movq (%rax), %rsi
movl -0x7c(%rbp), %edx
leaq -0x84(%rbp), %rdi
callq 0x2bab0
jmp 0x46b5a
movl -0x84(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x84(%rbp), %rdi
callq 0x60460
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x47950
jmp 0x46b83
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
movl $0x3, %edx
callq 0x47b10
jmp 0x46b98
movswl -0x4(%rbp), %eax
cmpl $0x96, %eax
jl 0x46be3
movswl -0x4(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
shrl %eax
movw %ax, -0x38(%rbp)
movw %ax, -0x36(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x47950
jmp 0x46bcc
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
movl $0x3, %edx
callq 0x47b10
jmp 0x46be1
jmp 0x46be3
jmp 0x46ee1
movswl -0x4(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
shrl %eax
movw %ax, -0x38(%rbp)
movw %ax, -0x36(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x47950
jmp 0x46c11
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
movl $0x1, %edx
callq 0x47b10
jmp 0x46c26
jmp 0x46ee1
movl -0x74(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x46d57
movl -0x6c(%rbp), %edi
callq 0x60410
movl %eax, -0xfc(%rbp)
jmp 0x46c4f
movl -0xfc(%rbp), %eax
movl %eax, -0x7c(%rbp)
leaq 0x4b179(%rip), %rax     # 0x91dd8
movq (%rax), %rsi
movl -0x7c(%rbp), %edx
leaq -0x88(%rbp), %rdi
callq 0x2bab0
jmp 0x46c73
movl -0x88(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x60460
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47950
jmp 0x46c99
leaq 0x4c4e8(%rip), %rdi     # 0x93188
leaq -0x38(%rbp), %rsi
callq 0x49fd0
jmp 0x46cab
movl -0x7c(%rbp), %ecx
leaq 0x468db(%rip), %rax     # 0x8d590
movl %ecx, (%rax)
leaq -0x7c(%rbp), %rdi
callq 0x60390
movq %rax, -0x108(%rbp)
jmp 0x46cc9
movq -0x108(%rbp), %rax
movl (%rax), %eax
cmpl -0x74(%rbp), %eax
jne 0x46cf9
leaq -0x7c(%rbp), %rdi
callq 0x603d0
movq %rax, -0x110(%rbp)
jmp 0x46ce9
movq -0x110(%rbp), %rdi
callq 0x603d0
jmp 0x46cf7
jmp 0x46cf9
leaq 0x4b0d8(%rip), %rax     # 0x91dd8
movq (%rax), %rsi
movl -0x7c(%rbp), %edx
leaq -0x8c(%rbp), %rdi
callq 0x2bab0
jmp 0x46d14
movl -0x8c(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x8c(%rbp), %rdi
callq 0x60460
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x47950
jmp 0x46d3d
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
movl $0x1, %edx
callq 0x47b10
jmp 0x46d52
jmp 0x46e3c
movswl -0x4(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
shrl %eax
movw %ax, -0x38(%rbp)
movw %ax, -0x36(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x47950
jmp 0x46d80
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
movl $0x1, %edx
callq 0x47b10
jmp 0x46d95
movl -0x6c(%rbp), %edi
callq 0x60410
movl %eax, -0x114(%rbp)
jmp 0x46da5
movl -0x114(%rbp), %eax
movl %eax, -0x7c(%rbp)
callq 0x5270
movl $0x2, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0x46dd0
leaq -0x7c(%rbp), %rdi
callq 0x60390
jmp 0x46dce
jmp 0x46ddd
leaq -0x7c(%rbp), %rdi
callq 0x603d0
jmp 0x46ddb
jmp 0x46ddd
leaq 0x4aff4(%rip), %rax     # 0x91dd8
movq (%rax), %rsi
movl -0x7c(%rbp), %edx
leaq -0x90(%rbp), %rdi
callq 0x2bab0
jmp 0x46df8
movl -0x90(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x60460
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47950
jmp 0x46e1e
leaq 0x4c363(%rip), %rdi     # 0x93188
leaq -0x38(%rbp), %rsi
callq 0x49fd0
jmp 0x46e30
movl -0x7c(%rbp), %ecx
leaq 0x46756(%rip), %rax     # 0x8d590
movl %ecx, (%rax)
leaq 0x4c345(%rip), %rdi     # 0x93188
movl $0x22, %esi
callq 0x49ff0
jmp 0x46e4f
movl -0x6c(%rbp), %eax
movl %eax, -0x7c(%rbp)
callq 0x5270
movl $0x2, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0x46e77
leaq -0x7c(%rbp), %rdi
callq 0x60390
jmp 0x46e75
jmp 0x46e84
leaq -0x7c(%rbp), %rdi
callq 0x603d0
jmp 0x46e82
jmp 0x46e84
leaq 0x4af4d(%rip), %rax     # 0x91dd8
movq (%rax), %rsi
movl -0x7c(%rbp), %edx
leaq -0x94(%rbp), %rdi
callq 0x2bab0
jmp 0x46e9f
movl -0x94(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x94(%rbp), %rdi
callq 0x60460
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x47950
jmp 0x46ec8
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
movl $0x3, %edx
callq 0x47b10
jmp 0x46edd
jmp 0x46ee1
jmp 0x46ee1
callq 0x5270
movl $0x64, %ecx
cqto
idivq %rcx
cmpq $0x2d, %rdx
jge 0x476a3
callq 0x5270
movq %rax, -0x130(%rbp)
movabsq $0x5555555555555556, %rcx # imm = 0x5555555555555556
imulq %rcx
movq -0x130(%rbp), %rax
movq %rdx, %rcx
shrq $0x3f, %rcx
addq %rcx, %rdx
leaq (%rdx,%rdx,2), %rcx
negq %rcx
leaq 0x2(%rax,%rcx), %rax
movq %rax, -0x128(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x2e440
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x2e740
jmp 0x46f66
leaq -0xb1(%rbp), %rdi
callq 0x2e4e0
callq 0x5270
movswq -0x4(%rbp), %rcx
cqto
idivq %rcx
movw %dx, %ax
movw %ax, -0x138(%rbp)
leaq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2e610
movw -0x138(%rbp), %cx
movw %cx, (%rax)
callq 0x5270
movswq -0x4(%rbp), %rcx
cqto
idivq %rcx
movw %dx, %ax
movw %ax, -0x136(%rbp)
leaq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2e610
movw -0x136(%rbp), %cx
movw %cx, 0x2(%rax)
leaq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2e610
movswl (%rax), %eax
movl %eax, -0x134(%rbp)
movswl -0x4(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x134(%rbp), %eax
cmpl %ecx, %eax
jge 0x47074
movswl -0x4(%rbp), %eax
subl $0x2, %eax
cltq
movq %rax, -0x148(%rbp)
callq 0x5270
movl $0xf, %ecx
cqto
idivq %rcx
movq -0x148(%rbp), %rax
subq %rdx, %rax
movw %ax, -0x13a(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x2e610
movw -0x13a(%rbp), %cx
movw %cx, (%rax)
jmp 0x470ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xb1(%rbp), %rdi
callq 0x2e4e0
jmp 0x47892
callq 0x5270
movl $0xf, %ecx
cqto
idivq %rcx
addq $0x2, %rdx
movw %dx, %ax
movw %ax, -0x14a(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x2e610
movw -0x14a(%rbp), %cx
movw %cx, (%rax)
leaq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2e610
movswl 0x2(%rax), %eax
movl %eax, -0x150(%rbp)
movswl -0x4(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x150(%rbp), %eax
cmpl %ecx, %eax
jge 0x4712c
movswl -0x4(%rbp), %eax
subl $0x2, %eax
cltq
movq %rax, -0x160(%rbp)
callq 0x5270
movl $0xf, %ecx
cqto
idivq %rcx
movq -0x160(%rbp), %rax
subq %rdx, %rax
movw %ax, -0x152(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x2e610
movw -0x152(%rbp), %cx
movw %cx, 0x2(%rax)
jmp 0x47165
callq 0x5270
movl $0xf, %ecx
cqto
idivq %rcx
addq $0x2, %rdx
movw %dx, %ax
movw %ax, -0x162(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x2e610
movw -0x162(%rbp), %cx
movw %cx, 0x2(%rax)
leaq -0xb0(%rbp), %rdi
callq 0x2e5f0
cmpq $0x2, %rax
jbe 0x47325
leaq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2e610
movswl (%rax), %eax
movl %eax, -0x170(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x2e610
movq %rax, %rcx
movl -0x170(%rbp), %eax
movswl (%rcx), %ecx
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movw %ax, -0x16a(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x2, %esi
callq 0x2e610
movw -0x16a(%rbp), %cx
movw %cx, (%rax)
leaq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2e610
movswl 0x2(%rax), %eax
movl %eax, -0x168(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x2e610
movq %rax, %rcx
movl -0x168(%rbp), %eax
movswl 0x2(%rcx), %ecx
addl %ecx, %eax
movswl -0x4(%rbp), %ecx
cltd
idivl %ecx
movw %dx, %ax
movw %ax, -0x164(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x2, %esi
callq 0x2e610
movw -0x164(%rbp), %cx
movw %cx, 0x2(%rax)
leaq -0xb0(%rbp), %rdi
callq 0x2e5f0
cmpq $0x3, %rax
jbe 0x47323
leaq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2e610
movswl (%rax), %eax
movl %eax, -0x180(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x2e610
movq %rax, %rcx
movl -0x180(%rbp), %eax
movswl (%rcx), %ecx
addl %ecx, %eax
movswl -0x4(%rbp), %ecx
cltd
idivl %ecx
movw %dx, %ax
movw %ax, -0x17a(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x3, %esi
callq 0x2e610
movw -0x17a(%rbp), %cx
movw %cx, (%rax)
leaq -0xb0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2e610
movswl 0x2(%rax), %eax
movl %eax, -0x178(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x2e610
movq %rax, %rcx
movl -0x178(%rbp), %eax
movswl 0x2(%rcx), %ecx
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movw %ax, -0x172(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x3, %esi
callq 0x2e610
movw -0x172(%rbp), %cx
movw %cx, 0x2(%rax)
jmp 0x47325
callq 0x5270
movq %rax, %rdx
shrq $0x3f, %rdx
movq %rax, %rcx
addq %rdx, %rcx
andq $-0x2, %rcx
subq %rcx, %rax
setne -0xb2(%rbp)
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x2e5f0
movq -0x188(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x2e610
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47950
jmp 0x47380
testb $0x1, -0xb2(%rbp)
je 0x473ba
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x4739b
jmp 0x473ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x2e6e0
jmp 0x47892
leaq -0x38(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x473cc
jmp 0x473ce
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x2e5f0
movq -0x190(%rbp), %rdi
movq %rax, %rsi
addq $-0x2, %rsi
callq 0x2e610
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47950
jmp 0x4740a
testb $0x1, -0xb2(%rbp)
je 0x47427
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x47425
jmp 0x4743b
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x47439
jmp 0x4743b
leaq -0xb0(%rbp), %rdi
callq 0x2e5f0
cmpq $0x3, %rax
jne 0x474e2
xorl %eax, %eax
movl %eax, -0x194(%rbp)
movl %eax, %esi
leaq -0xb0(%rbp), %rdi
callq 0x2e610
movl -0x194(%rbp), %edx
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x47950
jmp 0x47481
testb $0x1, -0xb2(%rbp)
je 0x4749e
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x4749c
jmp 0x474dd
callq 0x5270
movl $0x2, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0x474c7
leaq -0x38(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x474c5
jmp 0x474db
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x474d9
jmp 0x474db
jmp 0x474dd
jmp 0x47697
leaq -0xb0(%rbp), %rdi
callq 0x2e5f0
cmpq $0x4, %rax
jne 0x47695
callq 0x5270
movl $0x2, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0x47573
movb $0x0, -0xb3(%rbp)
movsbl -0xb3(%rbp), %eax
cmpl $0x2, %eax
jge 0x4756e
movsbq -0xb3(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x2e610
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47950
jmp 0x4754a
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x4755c
jmp 0x4755e
movb -0xb3(%rbp), %al
addb $0x1, %al
movb %al, -0xb3(%rbp)
jmp 0x47514
jmp 0x47693
testb $0x1, -0xb2(%rbp)
je 0x47600
xorl %eax, %eax
movl %eax, -0x198(%rbp)
movl %eax, %esi
leaq -0xb0(%rbp), %rdi
callq 0x2e610
movl -0x198(%rbp), %edx
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x47950
jmp 0x475b0
leaq -0x38(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x475c2
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x2e610
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47950
jmp 0x475e9
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x475fb
jmp 0x47691
movb $0x0, -0xb4(%rbp)
movsbl -0xb4(%rbp), %eax
cmpl $0x2, %eax
jge 0x4768f
movsbq -0xb4(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x2e610
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47950
jmp 0x4763d
callq 0x5270
movl $0x2, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0x47666
leaq -0x38(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x47664
jmp 0x4767a
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x47678
jmp 0x4767a
jmp 0x4767c
movb -0xb4(%rbp), %al
addb $0x1, %al
movb %al, -0xb4(%rbp)
jmp 0x47607
jmp 0x47691
jmp 0x47693
jmp 0x47695
jmp 0x47697
leaq -0xb0(%rbp), %rdi
callq 0x2e6e0
leaq 0x49cea(%rip), %rax     # 0x91394
cmpl $0x3, (%rax)
jne 0x47783
jmp 0x476b5
callq 0x5270
movl $0x9, %ecx
cqto
idivq %rcx
movl %edx, %ecx
leaq 0x45ec3(%rip), %rax     # 0x8d590
movl %ecx, (%rax)
leaq 0x45eba(%rip), %rax     # 0x8d590
movl (%rax), %ecx
movb $0x1, %al
cmpl -0x6c(%rbp), %ecx
movb %al, -0x199(%rbp)
je 0x476fa
leaq 0x45ea4(%rip), %rax     # 0x8d590
movl (%rax), %eax
cmpl -0x74(%rbp), %eax
sete %al
movb %al, -0x199(%rbp)
movb -0x199(%rbp), %al
testb $0x1, %al
jne 0x476b5
leaq 0x4a6cd(%rip), %rax     # 0x91dd8
movq (%rax), %rsi
leaq 0x45e7b(%rip), %rax     # 0x8d590
movl (%rax), %edx
leaq -0xb8(%rbp), %rdi
callq 0x2bab0
jmp 0x47725
movl -0xb8(%rbp), %eax
movl %eax, -0x24(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x60460
movb $0x0, -0xb9(%rbp)
movsbl -0xb9(%rbp), %eax
cmpl $0xa, %eax
jge 0x47781
movl -0x24(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47950
jmp 0x47764
leaq -0x38(%rbp), %rdi
callq 0x478c0
jmp 0x4776f
jmp 0x47771
movb -0xb9(%rbp), %al
addb $0x1, %al
movb %al, -0xb9(%rbp)
jmp 0x47741
jmp 0x47783
callq 0x5270
movl $0x3, %ecx
cqto
idivq %rcx
movw %dx, %ax
movw %ax, -0x2(%rbp)
movswl -0x2(%rbp), %eax
cmpl $0x0, %eax
jle 0x4786e
callq 0x5270
movq %rax, -0x1a8(%rbp)
leaq 0x4a61f(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
callq 0x3c930
movw %ax, -0x19c(%rbp)
jmp 0x477ca
movq -0x1a8(%rbp), %rax
movw -0x19c(%rbp), %cx
movswl %cx, %ecx
addl $-0xa, %ecx
movslq %ecx, %rcx
cqto
idivq %rcx
movl %edx, %eax
addl $0x5, %eax
movw %ax, -0x24(%rbp)
callq 0x5270
movq %rax, -0x1b8(%rbp)
leaq 0x4a5d6(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
callq 0x3c930
movw %ax, -0x1aa(%rbp)
jmp 0x47813
movq -0x1b8(%rbp), %rax
movw -0x1aa(%rbp), %cx
movswl %cx, %ecx
addl $-0xa, %ecx
movslq %ecx, %rcx
cqto
idivq %rcx
movl %edx, %eax
addl $0x5, %eax
movw %ax, -0x22(%rbp)
leaq -0x24(%rbp), %rdi
leaq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x47950
jmp 0x47849
leaq -0x24(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x47b10
jmp 0x4785b
jmp 0x4785d
movw -0x2(%rbp), %ax
addw $-0x1, %ax
movw %ax, -0x2(%rbp)
jmp 0x47799
leaq -0x38(%rbp), %rdi
callq 0x60460
leaq -0x24(%rbp), %rdi
callq 0x60460
leaq -0x20(%rbp), %rdi
callq 0x2e6e0
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x60460
leaq -0x24(%rbp), %rdi
callq 0x60460
leaq -0x20(%rbp), %rdi
callq 0x2e6e0
movq -0x30(%rbp), %rdi
callq 0x5920
nopw %cs:(%rax,%rax)