// File: lotuskip[P]yuxtapa/server/game.cpp
// Function: Game::process_turn()
bool Game::process_turn()
{
	/* Turn processing process:
	 * 1. check teammates wanting to change places
	 * 2. update each entity, process poisonings
	 * 3. do "garbage collection"
	 * 4. process spawning
	 * 5. process an action in each player's action queue, if any
	 * 6. render the situation to the players
	 * 7. possible active teambalance check
	 * 8. see if map should end
	 */
#ifdef TIME_SERVER_TURN
	// Timing the turn process, for performance purposes:
	timeval tv;	
	long start_usecs;
	gettimeofday(&tv, 0);
	start_usecs = tv.tv_sec*1000000 + tv.tv_usec;
#endif

	// All player movement actions have been processed, finish by checking
	// teammates swapping places:
	process_swaps();

	// Update entities that need it:
	list<Arrow>::iterator a_it; 
	for(a_it = arrows.begin(); a_it != arrows.end(); ++a_it)
		a_it->update();
	list<MM>::iterator m_it; 
	for(m_it = MMs.begin(); m_it != MMs.end(); ++m_it)
		m_it->update();
	list<Zap>::iterator z_it; 
	for(z_it = zaps.begin(); z_it != zaps.end(); ++z_it)
		z_it->update();
	list<NOccEnt>::iterator ne_it;
	for(ne_it = noccents[NOE_CORPSE].begin();
		ne_it != noccents[NOE_CORPSE].end(); ++ne_it)
		ne_it->update();

	// Check poisoning:
	list<Player>::iterator it;
	if(!(curturn % POISON_EVERY_N_TURN))
	{
		for(it = cur_players.begin(); it != cur_players.end(); ++it)
		{
			// a valid poisoner implies player is dead!
			if(it->poisoner != cur_players.end())
			{
				if(--(it->cl_props.hp) <= 0)
					player_poisoned(it);
				else
					it->needs_state_upd = true;
			}
		}
	}

	// Destroy voided entities: (perhaps due to bad design, I don't see an easy
	// way to use templates here, so it's kind of repetitive...)
	a_it = arrows.begin();
	while(a_it != arrows.end())
	{
		if(a_it->isvoid()) a_it = arrows.erase(a_it);
		else ++a_it;
	}
	m_it = MMs.begin();
	while(m_it != MMs.end())
	{
		if(m_it->isvoid()) m_it = MMs.erase(m_it);
		else ++m_it;
	}
	z_it = zaps.begin();
	while(z_it != zaps.end())
	{
		if(z_it->isvoid()) z_it = zaps.erase(z_it);
		else ++z_it;
	}
	list<PCEnt>::iterator pc_it = PCs.begin();
	while(pc_it != PCs.end())
	{
		if(pc_it->isvoid()) pc_it = PCs.erase(pc_it);
		// With PCs, save time and update torches at the same time:
		else
		{
			if(pc_it->torch_is_lit())
			{
				if(pc_it->get_owner()->burn_torch())
				{
					string msg = "Suddenly your torch burns out.";
					Network::construct_msg(msg, C_LIGHT_TRAP_LIT);
					Network::send_to_player(*(pc_it->get_owner()));
					pc_it->toggle_torch();
					event_set.insert(pc_it->getpos());
				}
			}
			++pc_it;
		}
	}
	list<OccEnt>::iterator b_it = boulders.begin();
	while(b_it != boulders.end())
	{
		if(b_it->isvoid()) b_it = boulders.erase(b_it);
		else ++b_it;
	}
	ne_it = noccents[NOE_CORPSE].begin();
	while(ne_it != noccents[NOE_CORPSE].end())
	{
		if(ne_it->isvoid()) ne_it = noccents[NOE_CORPSE].erase(ne_it);
		else ++ne_it;
	}
	
	// Handle spawning:
	if(!(curturn % spawn_cycle))
	{
		if(spawn_team(T_PURPLE))
			return true;
	}
	else if(!((curturn + spawn_cycle/2) % spawn_cycle))
	{
		if(spawn_team(T_GREEN))
			return true;
	}
	
	// Go through non-spectators, checking who acted and who didn't:
	for(it = cur_players.begin(); it != cur_players.end(); ++it)
	{
		// If we haven't heard from a player for MAX_PING_TURNS turns,
		// assume that the client has disconnected.
		if(curturn - it->last_heard_of > MAX_PING_TURNS)
		{
			it = remove_player(it, " dropped.");
			continue;
		}

		if(it->is_alive())
		{
			// First check for drowning. If is in water and could've
			// moved away, drowning damage.
			if(!it->wait_turns &&
				(curmap->mod_tile(it->own_pc->getpos())->flags & TF_DROWNS))
			{
				string s = "You are drowning!";
				Network::construct_msg(s, C_WATER_LIT);
				Network::send_to_player(*it);
				it->cl_props.hp -= random()%(classes[it->cl].hp/2 + (classes[it->cl].hp%2));
				if(it->cl_props.hp <= 0)
				{
					player_death(it, " drowned.", false);
					continue;
				}
				// else (needs_state_upd is set in player_death otherwise)
				it->needs_state_upd = true;
				// splashing sounds for drowning regardless of class:
				add_sound(it->own_pc->getpos(), S_SPLASH);
			}
			// if here, did not die of drowning:
			if(!it->acted_this_turn)
			{
				if(it->wait_turns) // lost turn(s) due to something
					it->wait_turns--;
				else if(it->doing_a_chore) // working on something
					progress_chore(it);
				else if(it->action_queue.empty())
				{
					if(it->cl != C_ASSASSIN && it->cl != C_PLANEWALKER
						&& it->limiter)
						it->limiter--;
					// Being blind prevents trap detection and is not considered idling:
					if(!it->own_vp->is_blind())
					{
						it->turns_without_axn++;
						trap_detection(it);
					}
				}
				else
				{
					validate_and_process(it->action_queue.front(), it);
					if(!it->action_queue.empty()) /* Might've been cleared
							in processing! */
						it->action_queue.pop_front();
				}
			}
			else
			{
				it->acted_this_turn = false; // for next turn
				it->turns_without_axn = 0;
			}
		} // if alive
	} // loop players
	
	/// Render&Send
	using Network::send_buffer;
	vector<string> shouts;
	short i, j;
	for(it = cur_players.begin(); it != cur_players.end(); ++it)
	{
		// check if this player's viewpoint has any watchers (if not, no point
		// in rendering!)
		if(it->own_vp->has_watchers())
		{
			send_buffer.clear();
			send_buffer.add((unsigned char)MID_VIEW_UPD);
			send_buffer.add(curturn);

			/* Check if there have been any events during this turn in the
			 * vicinity of this viewpoint. If there are none, we don't
			 * need to render, but must anyway send a "tick message"
			 * indicating that a turn has passed. Also always rerender for
			 * poisoned PCs. */
			if(it->own_vp->pos_changed() || events_around(it->own_vp->get_pos())
				|| it->poisoner != cur_players.end())
			{
				i = it->own_vp->render(renderbuffer, shouts);
				if(it->poisoner != cur_players.end())
				{
					// if poisoned, draw random tiles sickly green
					for(j = 0; j < 2*VIEWSIZE*VIEWSIZE; j += 2)
					{
						if(renderbuffer[j+1] != '?' && !(random()%3))
							renderbuffer[j] = C_ACID_TRAP;
					}
				}
				send_buffer.write_compressed(renderbuffer, i);
			}

			// Send to all watchers:
			for(vector< list<Player>::iterator >::const_iterator wi =
				it->own_vp->foll_beg(); wi != it->own_vp->foll_end(); ++wi)
				Network::send_to_player(**wi);
			// Send possible shouts:
			while(!shouts.empty())
			{
				Network::construct_msg(shouts.back(), DEF_MSG_COL);
				for(vector< list<Player>::iterator >::const_iterator wi =
					it->own_vp->foll_beg(); wi != it->own_vp->foll_end(); ++wi)
					Network::send_to_player(**wi);
				shouts.pop_back();
			}
		}
		// If the viewpoint is blinded, reduce time left:
		it->own_vp->reduce_blind();
		// Check if the player needs a state update:
		if(it->needs_state_upd)
			send_state_upd(it);
	}
	event_set.clear();
	clear_action_inds();
	clear_sounds();
	fball_centers.clear();

	// Teams need shuffled?
	if(team_unbalance && time(NULL) - teams_unbal_since >= SECS_TO_SHUFFLE)
	{
		shuffle_teams();
		team_unbalance = false;
	}

#ifdef TIME_SERVER_TURN
	// Timing the turn process, for performance purposes:
	gettimeofday(&tv, 0);
	cout << tv.tv_sec*1000000 + tv.tv_usec - start_usecs << "µs" << endl;
#endif

	return (++curturn == map_over_turn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3c0, %rsp            # imm = 0x3C0
callq 0x54c60
leaq -0x10(%rbp), %rdi
callq 0x3caa0
leaq 0x5aa18(%rip), %rdi     # 0x93008
callq 0x3cac0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq 0x5aa00(%rip), %rdi     # 0x93008
callq 0x3cb20
movq %rax, -0x20(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3caf0
testb $0x1, %al
jne 0x38624
jmp 0x38641
leaq -0x10(%rbp), %rdi
callq 0x3cb50
movq %rax, %rdi
movq (%rdi), %rax
callq *0x10(%rax)
leaq -0x10(%rbp), %rdi
callq 0x3cb80
jmp 0x38601
leaq -0x28(%rbp), %rdi
callq 0x3cba0
leaq 0x5a9cf(%rip), %rdi     # 0x93020
callq 0x3cbc0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0x5a9b7(%rip), %rdi     # 0x93020
callq 0x3cc20
movq %rax, -0x38(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3cbf0
testb $0x1, %al
jne 0x38685
jmp 0x386a2
leaq -0x28(%rbp), %rdi
callq 0x3cc50
movq %rax, %rdi
movq (%rdi), %rax
callq *0x10(%rax)
leaq -0x28(%rbp), %rdi
callq 0x3cc80
jmp 0x38662
leaq -0x40(%rbp), %rdi
callq 0x3cca0
leaq 0x5a986(%rip), %rdi     # 0x93038
callq 0x3ccc0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0x5a96e(%rip), %rdi     # 0x93038
callq 0x3cd20
movq %rax, -0x50(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3ccf0
testb $0x1, %al
jne 0x386e6
jmp 0x38703
leaq -0x40(%rbp), %rdi
callq 0x3cd50
movq %rax, %rdi
movq (%rdi), %rax
callq *0x10(%rax)
leaq -0x40(%rbp), %rdi
callq 0x3cd80
jmp 0x386c3
leaq -0x58(%rbp), %rdi
callq 0x3cda0
leaq 0x5a81d(%rip), %rdi     # 0x92f30
callq 0x3c950
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq 0x5a805(%rip), %rdi     # 0x92f30
callq 0x3c9d0
movq %rax, -0x68(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3cdc0
testb $0x1, %al
jne 0x38747
jmp 0x38764
leaq -0x58(%rbp), %rdi
callq 0x3cdf0
movq %rax, %rdi
movq (%rdi), %rax
callq *0x10(%rax)
leaq -0x58(%rbp), %rdi
callq 0x3ce20
jmp 0x38724
leaq -0x70(%rbp), %rdi
callq 0x1b010
movzwl 0x5965c(%rip), %eax     # 0x91dd0
movl $0x28, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x38864
leaq 0x57aa4(%rip), %rdi     # 0x90230
callq 0x1b360
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq 0x57a8c(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, -0x80(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1b100
testb $0x1, %al
jne 0x387c3
jmp 0x38862
leaq -0x70(%rbp), %rdi
callq 0x1b050
addq $0x150, %rax            # imm = 0x150
movq %rax, -0x2e8(%rbp)
leaq 0x57a50(%rip), %rdi     # 0x90230
callq 0x189f0
movq -0x2e8(%rbp), %rdi
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rsi
callq 0x1b100
testb $0x1, %al
jne 0x38805
jmp 0x38852
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq %rax, %rcx
movb 0x143(%rcx), %al
addb $-0x1, %al
movb %al, 0x143(%rcx)
movsbl %al, %eax
cmpl $0x0, %eax
jg 0x38840
movq -0x70(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x51c20
jmp 0x38850
leaq -0x70(%rbp), %rdi
callq 0x1b050
movb $0x1, 0x14d(%rax)
jmp 0x38852
jmp 0x38854
leaq -0x70(%rbp), %rdi
callq 0x1b3c0
jmp 0x3879d
jmp 0x38864
leaq 0x5a79d(%rip), %rdi     # 0x93008
callq 0x3cac0
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq 0x5a77f(%rip), %rdi     # 0x93008
callq 0x3cb20
movq %rax, -0xa0(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3caf0
testb $0x1, %al
jne 0x388ab
jmp 0x38907
leaq -0x10(%rbp), %rdi
callq 0x3cb50
movq %rax, %rdi
callq 0x3ce40
testb $0x1, %al
jne 0x388c2
jmp 0x388f9
leaq -0xb0(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x3ceb0
movq -0xb0(%rbp), %rsi
leaq 0x5a728(%rip), %rdi     # 0x93008
callq 0x3ce60
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x38902
leaq -0x10(%rbp), %rdi
callq 0x3cb80
jmp 0x38882
leaq 0x5a712(%rip), %rdi     # 0x93020
callq 0x3cbc0
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0x5a6f4(%rip), %rdi     # 0x93020
callq 0x3cc20
movq %rax, -0xc0(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3cbf0
testb $0x1, %al
jne 0x3894e
jmp 0x389aa
leaq -0x28(%rbp), %rdi
callq 0x3cc50
movq %rax, %rdi
callq 0x3ce40
testb $0x1, %al
jne 0x38965
jmp 0x3899c
leaq -0xd0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x3cf20
movq -0xd0(%rbp), %rsi
leaq 0x5a69d(%rip), %rdi     # 0x93020
callq 0x3ced0
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x389a5
leaq -0x28(%rbp), %rdi
callq 0x3cc80
jmp 0x38925
leaq 0x5a687(%rip), %rdi     # 0x93038
callq 0x3ccc0
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0x5a669(%rip), %rdi     # 0x93038
callq 0x3cd20
movq %rax, -0xe0(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3ccf0
testb $0x1, %al
jne 0x389f1
jmp 0x38a4d
leaq -0x40(%rbp), %rdi
callq 0x3cd50
movq %rax, %rdi
callq 0x3ce40
testb $0x1, %al
jne 0x38a08
jmp 0x38a3f
leaq -0xf0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3cf90
movq -0xf0(%rbp), %rsi
leaq 0x5a612(%rip), %rdi     # 0x93038
callq 0x3cf40
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x38a48
leaq -0x40(%rbp), %rdi
callq 0x3cd80
jmp 0x389c8
leaq 0x5a5fc(%rip), %rdi     # 0x93050
callq 0x3cfb0
movq %rax, -0xf8(%rbp)
leaq 0x5a5e9(%rip), %rdi     # 0x93050
callq 0x3d010
movq %rax, -0x100(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x3cfe0
testb $0x1, %al
jne 0x38a8f
jmp 0x38cd6
leaq -0xf8(%rbp), %rdi
callq 0x3d040
movq %rax, %rdi
callq 0x3ce40
testb $0x1, %al
jne 0x38aa9
jmp 0x38ae9
leaq -0x110(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x3d0b0
movq -0x110(%rbp), %rsi
leaq 0x5a586(%rip), %rdi     # 0x93050
callq 0x3d060
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0xf8(%rbp)
jmp 0x38cd1
leaq -0xf8(%rbp), %rdi
callq 0x3d040
movq %rax, %rdi
callq 0x3d0d0
testb $0x1, %al
jne 0x38b06
jmp 0x38cc5
leaq -0xf8(%rbp), %rdi
callq 0x3d040
movq %rax, %rdi
callq 0x3d0f0
movq %rax, -0x118(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
callq 0x21df0
testb $0x1, %al
jne 0x38b3e
jmp 0x38cc3
leaq -0x139(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x5930
movq -0x2f0(%rbp), %rdx
leaq 0x2b57f(%rip), %rsi     # 0x640de
leaq -0x138(%rbp), %rdi
callq 0x18880
jmp 0x38b6d
leaq -0x139(%rbp), %rdi
callq 0x5590
leaq -0x138(%rbp), %rdi
movl $0x36, %esi
callq 0x1ab10
jmp 0x38b8c
leaq -0xf8(%rbp), %rdi
callq 0x3d040
movq %rax, %rdi
callq 0x3d0f0
movq %rax, -0x2f8(%rbp)
jmp 0x38ba9
movq -0x2f8(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x28450
movq %rax, %rdi
leaq 0x556cb(%rip), %rsi     # 0x8e298
callq 0x1af60
jmp 0x38bd4
leaq -0xf8(%rbp), %rdi
callq 0x3d040
movq %rax, %rdi
callq 0x4da90
jmp 0x38bea
leaq -0xf8(%rbp), %rdi
callq 0x3d040
movq %rax, %rsi
leaq -0x15c(%rbp), %rdi
callq 0x1b190
jmp 0x38c07
leaq 0x5a53a(%rip), %rdi     # 0x93148
leaq -0x15c(%rbp), %rsi
callq 0x1b1e0
movb %dl, -0x301(%rbp)
movq %rax, -0x300(%rbp)
jmp 0x38c29
movb -0x301(%rbp), %al
movq -0x300(%rbp), %rcx
movq %rcx, -0x170(%rbp)
movb %al, -0x168(%rbp)
leaq -0x15c(%rbp), %rdi
callq 0x60460
leaq -0x138(%rbp), %rdi
callq 0x5a48
jmp 0x38cc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
leaq -0x139(%rbp), %rdi
callq 0x5590
jmp 0x39b39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x38cb2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
leaq -0x15c(%rbp), %rdi
callq 0x60460
leaq -0x138(%rbp), %rdi
callq 0x5a48
jmp 0x39b39
jmp 0x38cc5
leaq -0xf8(%rbp), %rdi
callq 0x3d110
jmp 0x38a60
leaq 0x5a313(%rip), %rdi     # 0x92ff0
callq 0x3d130
movq %rax, -0x178(%rbp)
leaq 0x5a300(%rip), %rdi     # 0x92ff0
callq 0x3d190
movq %rax, -0x180(%rbp)
leaq -0x178(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x3d160
testb $0x1, %al
jne 0x38d15
jmp 0x38d7d
leaq -0x178(%rbp), %rdi
callq 0x3d1c0
movq %rax, %rdi
callq 0x3ce40
testb $0x1, %al
jne 0x38d2f
jmp 0x38d6c
leaq -0x190(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x3d240
movq -0x190(%rbp), %rsi
leaq 0x5a2a0(%rip), %rdi     # 0x92ff0
callq 0x3d1f0
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x178(%rbp)
jmp 0x38d78
leaq -0x178(%rbp), %rdi
callq 0x3d260
jmp 0x38ce9
leaq 0x5a1ac(%rip), %rdi     # 0x92f30
callq 0x3c950
movq %rax, -0x198(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq 0x5a18e(%rip), %rdi     # 0x92f30
callq 0x3c9d0
movq %rax, -0x1a0(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x3cdc0
testb $0x1, %al
jne 0x38dc4
jmp 0x38e20
leaq -0x58(%rbp), %rdi
callq 0x3cdf0
movq %rax, %rdi
callq 0x3ce40
testb $0x1, %al
jne 0x38ddb
jmp 0x38e12
leaq -0x1b0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3c980
movq -0x1b0(%rbp), %rsi
leaq 0x5a137(%rip), %rdi     # 0x92f30
callq 0x3d280
movq %rax, -0x1a8(%rbp)
movq -0x1a8(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x38e1b
leaq -0x58(%rbp), %rdi
callq 0x3ce20
jmp 0x38d9b
movzwl 0x58fa9(%rip), %eax     # 0x91dd0
movzbl 0x58fb6(%rip), %ecx     # 0x91de4
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x38e51
movl $0x1, %edi
callq 0x39b50
testb $0x1, %al
jne 0x38e46
jmp 0x38e4f
movb $0x1, -0x1(%rbp)
jmp 0x39b2b
jmp 0x38ea0
movzwl 0x58f78(%rip), %eax     # 0x91dd0
movl %eax, -0x308(%rbp)
movzbl 0x58f7f(%rip), %eax     # 0x91de4
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x308(%rbp), %eax
addl %ecx, %eax
movzbl 0x58f66(%rip), %ecx     # 0x91de4
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x38e9e
xorl %edi, %edi
callq 0x39b50
testb $0x1, %al
jne 0x38e93
jmp 0x38e9c
movb $0x1, -0x1(%rbp)
jmp 0x39b2b
jmp 0x38e9e
jmp 0x38ea0
leaq 0x57389(%rip), %rdi     # 0x90230
callq 0x1b360
movq %rax, -0x1b8(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq 0x5736b(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, -0x1c0(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x1b100
testb $0x1, %al
jne 0x38eea
jmp 0x39590
movzwl 0x58edf(%rip), %eax     # 0x91dd0
movl %eax, -0x30c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq %rax, %rcx
movl -0x30c(%rbp), %eax
movzwl 0xa8(%rcx), %ecx
subl %ecx, %eax
cmpl $0x14, %eax
jle 0x38fea
movq -0x70(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0x1f1(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x5930
movq -0x318(%rbp), %rdx
leaq 0x2b1b6(%rip), %rsi     # 0x640fd
leaq -0x1f0(%rbp), %rdi
callq 0x18880
jmp 0x38f55
movq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x3a100
movq %rax, -0x320(%rbp)
jmp 0x38f71
movq -0x320(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x5a48
leaq -0x1f1(%rbp), %rdi
callq 0x5590
jmp 0x39582
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x38fd9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x5a48
leaq -0x1f1(%rbp), %rdi
callq 0x5590
jmp 0x39b39
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
callq 0x21cd0
testb $0x1, %al
jne 0x39004
jmp 0x39580
leaq -0x70(%rbp), %rdi
callq 0x1b050
movb 0x131(%rax), %cl
movb $0x0, -0x1f7(%rbp)
xorl %eax, %eax
cmpb $0x0, %cl
movb %al, -0x321(%rbp)
jne 0x39096
movq 0x58daa(%rip), %rax     # 0x91dd8
movq %rax, -0x340(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0x138(%rax), %rsi
leaq -0x1f6(%rbp), %rdi
movq %rdi, -0x338(%rbp)
callq 0x1b190
movq -0x340(%rbp), %rdi
movq -0x338(%rbp), %rsi
movb $0x1, -0x1f7(%rbp)
callq 0x3d2d0
movq %rax, -0x330(%rbp)
jmp 0x3907b
movq -0x330(%rbp), %rax
movzwl (%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
setne %al
movb %al, -0x321(%rbp)
movb -0x321(%rbp), %al
movb %al, -0x341(%rbp)
testb $0x1, -0x1f7(%rbp)
jne 0x390ad
jmp 0x390b9
leaq -0x1f6(%rbp), %rdi
callq 0x60460
movb -0x341(%rbp), %al
testb $0x1, %al
jne 0x390c8
jmp 0x393bf
leaq -0x219(%rbp), %rdi
movq %rdi, -0x350(%rbp)
callq 0x5930
movq -0x350(%rbp), %rdx
leaq 0x2b01e(%rip), %rsi     # 0x64107
leaq -0x218(%rbp), %rdi
callq 0x18880
jmp 0x390f7
leaq -0x219(%rbp), %rdi
callq 0x5590
leaq -0x218(%rbp), %rdi
movl $0x31, %esi
callq 0x1ab10
jmp 0x39116
leaq -0x70(%rbp), %rdi
callq 0x28450
movq %rax, %rdi
leaq 0x5516f(%rip), %rsi     # 0x8e298
callq 0x1af60
jmp 0x39130
callq 0x5270
movq %rax, -0x360(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x1b050
movl 0xb0(%rax), %eax
movl %eax, %ecx
leaq 0x2addc(%rip), %rax     # 0x63f30
imulq $0xd, %rcx, %rcx
addq %rcx, %rax
movsbl 0x3(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x364(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x1b050
movl -0x364(%rbp), %ecx
movl 0xb0(%rax), %eax
movl %eax, %edx
leaq 0x2ada5(%rip), %rax     # 0x63f30
imulq $0xd, %rdx, %rdx
addq %rdx, %rax
movsbl 0x3(%rax), %eax
movl $0x2, %esi
cltd
idivl %esi
movq -0x360(%rbp), %rax
addl %edx, %ecx
movslq %ecx, %rcx
cqto
idivq %rcx
movq %rdx, -0x358(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq -0x358(%rbp), %rdx
movsbq 0x143(%rax), %rcx
subq %rdx, %rcx
movb %cl, 0x143(%rax)
leaq -0x70(%rbp), %rdi
callq 0x1b050
movsbl 0x143(%rax), %eax
cmpl $0x0, %eax
jg 0x39313
movq -0x70(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq -0x249(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0x5930
movq -0x370(%rbp), %rdx
leaq 0x2aefd(%rip), %rsi     # 0x64119
leaq -0x248(%rbp), %rdi
callq 0x18880
jmp 0x3922a
movq -0x228(%rbp), %rdi
leaq -0x248(%rbp), %rsi
xorl %edx, %edx
callq 0x517d0
jmp 0x39241
leaq -0x248(%rbp), %rdi
callq 0x5a48
leaq -0x249(%rbp), %rdi
callq 0x5590
movl $0x1f, -0x250(%rbp)
jmp 0x39371
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
testb $0x1, -0x1f7(%rbp)
jne 0x39285
jmp 0x39291
leaq -0x1f6(%rbp), %rdi
callq 0x60460
jmp 0x39b39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
leaq -0x219(%rbp), %rdi
callq 0x5590
jmp 0x39b39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x393ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x39302
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x5a48
leaq -0x249(%rbp), %rdi
callq 0x5590
jmp 0x393ae
leaq -0x70(%rbp), %rdi
movq %rdi, -0x378(%rbp)
callq 0x1b050
movq -0x378(%rbp), %rdi
movb $0x1, 0x14d(%rax)
callq 0x1b050
movq 0x138(%rax), %rsi
leaq -0x254(%rbp), %rdi
callq 0x1b190
jmp 0x3934b
leaq -0x254(%rbp), %rdi
xorl %esi, %esi
callq 0x48080
jmp 0x3935b
leaq -0x254(%rbp), %rdi
callq 0x60460
movl $0x0, -0x250(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x5a48
movl -0x250(%rbp), %eax
testl %eax, %eax
je 0x3938e
jmp 0x39389
jmp 0x39582
jmp 0x393bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
leaq -0x254(%rbp), %rdi
callq 0x60460
leaq -0x218(%rbp), %rdi
callq 0x5a48
jmp 0x39b39
leaq -0x70(%rbp), %rdi
callq 0x1b050
testb $0x1, 0x128(%rax)
jne 0x3955c
leaq -0x70(%rbp), %rdi
callq 0x1b050
cmpb $0x0, 0x131(%rax)
je 0x39404
leaq -0x70(%rbp), %rdi
callq 0x1b050
movb 0x131(%rax), %cl
addb $-0x1, %cl
movb %cl, 0x131(%rax)
jmp 0x3955a
leaq -0x70(%rbp), %rdi
callq 0x1b050
cmpb $0x0, 0x132(%rax)
je 0x39432
movq -0x70(%rbp), %rax
movq %rax, -0x260(%rbp)
movq -0x260(%rbp), %rdi
callq 0x55040
jmp 0x39558
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
addq $0xd8, %rdi
callq 0x3d310
testb $0x1, %al
jne 0x39453
jmp 0x394ee
leaq -0x70(%rbp), %rdi
callq 0x1b050
cmpl $0x1, 0xb0(%rax)
je 0x394a1
leaq -0x70(%rbp), %rdi
callq 0x1b050
cmpl $0xa, 0xb0(%rax)
je 0x394a1
leaq -0x70(%rbp), %rdi
callq 0x1b050
cmpb $0x0, 0x130(%rax)
je 0x394a1
leaq -0x70(%rbp), %rdi
callq 0x1b050
movb 0x130(%rax), %cl
addb $-0x1, %cl
movb %cl, 0x130(%rax)
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
callq 0x3d340
testb $0x1, %al
jne 0x394ec
leaq -0x70(%rbp), %rdi
callq 0x1b050
movw 0x12a(%rax), %cx
addw $0x1, %cx
movw %cx, 0x12a(%rax)
movq -0x70(%rbp), %rax
movq %rax, -0x268(%rbp)
movq -0x268(%rbp), %rdi
callq 0x57290
jmp 0x39556
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
addq $0xd8, %rdi
callq 0x3d360
movq %rax, %rdi
movq -0x70(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x270(%rbp), %rsi
callq 0x3a690
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
addq $0xd8, %rdi
callq 0x3d310
testb $0x1, %al
jne 0x39554
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq %rax, %rdi
addq $0xd8, %rdi
callq 0x3d390
jmp 0x39556
jmp 0x39558
jmp 0x3955a
jmp 0x3957e
leaq -0x70(%rbp), %rdi
callq 0x1b050
movb $0x0, 0x128(%rax)
leaq -0x70(%rbp), %rdi
callq 0x1b050
movw $0x0, 0x12a(%rax)
jmp 0x39580
jmp 0x39582
leaq -0x70(%rbp), %rdi
callq 0x1b3c0
jmp 0x38ebe
leaq -0x288(%rbp), %rdi
callq 0x1b3e0
leaq 0x56c8d(%rip), %rdi     # 0x90230
callq 0x1b360
movq %rax, -0x298(%rbp)
movq -0x298(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq 0x56c6f(%rip), %rdi     # 0x90230
callq 0x189f0
movq %rax, -0x2a0(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x1b100
testb $0x1, %al
jne 0x395e6
jmp 0x39a8c
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
callq 0x3d400
movb %al, -0x379(%rbp)
jmp 0x39603
movb -0x379(%rbp), %al
testb $0x1, %al
jne 0x39612
jmp 0x39a38
leaq 0x54c7f(%rip), %rdi     # 0x8e298
callq 0x5f370
jmp 0x39620
leaq 0x54c71(%rip), %rdi     # 0x8e298
movl $0x3, %esi
callq 0x5f390
jmp 0x39633
movzwl 0x58796(%rip), %esi     # 0x91dd0
leaq 0x54c57(%rip), %rdi     # 0x8e298
callq 0x5f3d0
jmp 0x39648
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
movb $0x0, -0x2a5(%rbp)
callq 0x3d430
movb %al, -0x37a(%rbp)
jmp 0x3966c
movb -0x37a(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x37b(%rbp)
jne 0x39715
jmp 0x39685
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rsi
leaq -0x2a4(%rbp), %rdi
callq 0x3d450
jmp 0x396a3
movb $0x1, -0x2a5(%rbp)
leaq -0x2a4(%rbp), %rdi
callq 0x46520
movb %al, -0x37c(%rbp)
jmp 0x396be
movb -0x37c(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x37b(%rbp)
jne 0x39715
jmp 0x396d3
leaq -0x70(%rbp), %rdi
callq 0x1b050
addq $0x150, %rax            # imm = 0x150
movq %rax, -0x388(%rbp)
leaq 0x56b40(%rip), %rdi     # 0x90230
callq 0x189f0
movq -0x388(%rbp), %rdi
movq %rax, -0x2b0(%rbp)
leaq -0x2b0(%rbp), %rsi
callq 0x1b100
movb %al, -0x37b(%rbp)
movb -0x37b(%rbp), %al
movb %al, -0x389(%rbp)
testb $0x1, -0x2a5(%rbp)
jne 0x3972c
jmp 0x39738
leaq -0x2a4(%rbp), %rdi
callq 0x60460
movb -0x389(%rbp), %al
testb $0x1, %al
jne 0x39747
jmp 0x398a5
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
leaq 0x58692(%rip), %rsi     # 0x91df0
leaq -0x288(%rbp), %rdx
callq 0x41530
movw %ax, -0x38c(%rbp)
jmp 0x39773
movw -0x38c(%rbp), %ax
movw %ax, -0x28a(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x1b050
addq $0x150, %rax            # imm = 0x150
movq %rax, -0x398(%rbp)
leaq 0x56a92(%rip), %rdi     # 0x90230
callq 0x189f0
movq -0x398(%rbp), %rdi
movq %rax, -0x2b8(%rbp)
leaq -0x2b8(%rbp), %rsi
callq 0x1b100
testb $0x1, %al
jne 0x397c6
jmp 0x39887
movw $0x0, -0x28c(%rbp)
movswl -0x28c(%rbp), %eax
cmpl $0x422, %eax            # imm = 0x422
jge 0x39885
movswl -0x28c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x585fb(%rip), %rax     # 0x91df0
movsbl (%rax,%rcx), %eax
cmpl $0x3f, %eax
je 0x3986d
callq 0x5270
movl $0x3, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
jne 0x3986d
movswq -0x28c(%rbp), %rcx
leaq 0x585ce(%rip), %rax     # 0x91df0
movb $0x26, (%rax,%rcx)
jmp 0x3986d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x39b1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
testb $0x1, -0x2a5(%rbp)
jne 0x3985c
jmp 0x39868
leaq -0x2a4(%rbp), %rdi
callq 0x60460
jmp 0x39b1d
jmp 0x3986f
movswl -0x28c(%rbp), %eax
addl $0x2, %eax
movw %ax, -0x28c(%rbp)
jmp 0x397cf
jmp 0x39887
movzwl -0x28a(%rbp), %edx
leaq 0x54a03(%rip), %rdi     # 0x8e298
leaq 0x58554(%rip), %rsi     # 0x91df0
callq 0x5f4e0
jmp 0x398a3
jmp 0x398a5
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
callq 0x3d470
movq %rax, -0x3a0(%rbp)
jmp 0x398c3
movq -0x3a0(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
callq 0x3d4e0
movq %rax, -0x3a8(%rbp)
jmp 0x398ef
movq -0x3a8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
leaq -0x2c0(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x3d4a0
testb $0x1, %al
jne 0x39916
jmp 0x3994b
leaq -0x2c0(%rbp), %rdi
callq 0x3d510
movq %rax, %rdi
callq 0x28450
movq %rax, %rdi
leaq 0x54964(%rip), %rsi     # 0x8e298
callq 0x1af60
jmp 0x3993b
jmp 0x3993d
leaq -0x2c0(%rbp), %rdi
callq 0x3d530
jmp 0x398d1
jmp 0x3994d
leaq -0x288(%rbp), %rdi
callq 0x1f710
xorb $-0x1, %al
testb $0x1, %al
jne 0x39964
jmp 0x39a36
leaq -0x288(%rbp), %rdi
callq 0x1c8b0
movq %rax, %rdi
movl $0xf, %esi
callq 0x1ab10
jmp 0x3997f
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
callq 0x3d470
movq %rax, -0x3b0(%rbp)
jmp 0x3999d
movq -0x3b0(%rbp), %rax
movq %rax, -0x2d0(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
callq 0x3d4e0
movq %rax, -0x3b8(%rbp)
jmp 0x399c9
movq -0x3b8(%rbp), %rax
movq %rax, -0x2d8(%rbp)
leaq -0x2d0(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x3d4a0
testb $0x1, %al
jne 0x399f0
jmp 0x39a25
leaq -0x2d0(%rbp), %rdi
callq 0x3d510
movq %rax, %rdi
callq 0x28450
movq %rax, %rdi
leaq 0x5488a(%rip), %rsi     # 0x8e298
callq 0x1af60
jmp 0x39a15
jmp 0x39a17
leaq -0x2d0(%rbp), %rdi
callq 0x3d530
jmp 0x399ab
leaq -0x288(%rbp), %rdi
callq 0x3d550
jmp 0x3994d
jmp 0x39a38
leaq -0x70(%rbp), %rdi
callq 0x1b050
movq 0xc0(%rax), %rdi
callq 0x42740
jmp 0x39a4f
leaq -0x70(%rbp), %rdi
callq 0x1b050
testb $0x1, 0x14d(%rax)
je 0x39a7c
movq -0x70(%rbp), %rax
movq %rax, -0x2e0(%rbp)
movq -0x2e0(%rbp), %rdi
callq 0x3a720
jmp 0x39a7a
jmp 0x39a7c
jmp 0x39a7e
leaq -0x70(%rbp), %rdi
callq 0x1b3c0
jmp 0x395ba
leaq 0x596b5(%rip), %rdi     # 0x93148
callq 0x3c8a0
callq 0x47f90
jmp 0x39a9f
callq 0x48160
jmp 0x39aa6
leaq 0x59683(%rip), %rdi     # 0x93130
callq 0x3c900
testb $0x1, 0x58b37(%rip)     # 0x925f0
je 0x39adf
xorl %eax, %eax
movl %eax, %edi
callq 0x54c0
subq 0x58b2d(%rip), %rax     # 0x925f8
cmpq $0x1e, %rax
jl 0x39adf
callq 0x5cc50
jmp 0x39ad8
movb $0x0, 0x58b11(%rip)     # 0x925f0
movw 0x582ea(%rip), %ax      # 0x91dd0
addw $0x1, %ax
movw %ax, 0x582df(%rip)      # 0x91dd0
movzwl %ax, %eax
movzwl 0x53a99(%rip), %ecx     # 0x8d594
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0x1, -0x250(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x1b4e0
jmp 0x39b2b
leaq -0x288(%rbp), %rdi
callq 0x1b4e0
jmp 0x39b39
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbp
retq
movq -0x148(%rbp), %rdi
callq 0x5920
nopw %cs:(%rax,%rax)