// File: /workspace/github_cpp_makefile_star2_O2/lotuskip[P]yuxtapa/server/game.cpp
// Function: (anonymous namespace)::spawn_team(e_Team)
bool spawn_team(const e_Team t)
{
	// If there are no flags, this means the other team has won!
	if(team_flags[t].empty())
		return true;

	// Do the check for boulder destruction:
	if(gamemode == GM_DESTR && t == T_PURPLE)
	{
		unsigned short obl = boulders_left;
		upd_num_boulders();
		if(!boulders_left)
		{
			team_flags[T_PURPLE].clear();
			return true; // Green has won!
		}
		if(obl != boulders_left) // amount changed!
			Game::send_team_upds(cur_players.end());
	}

	list<list<NOccEnt>::iterator>::const_iterator fit
		= --(team_flags[t].end());
	char spawned = 0;

	nearby_set_dim(Game::curmap->get_size());
	Coords c = (*fit)->getpos();
	init_nearby(c);

	for(list<Player>::iterator it = cur_players.begin();
		it != cur_players.end(); ++it)
	{
		// Player is to spawn if she is in this team and dead:
		if(it->team == t && !it->is_alive())
		{
			// Spawn this player around 'c';
			// For spawning, must be unoccupied & walkthru
			while(Game::curmap->get_tile(c).flags
				& (TF_OCCUPIED|TF_KILLS|TF_DROWNS)
				|| !(Game::curmap->get_tile(c).flags & TF_WALKTHRU))
				c = next_nearby();
			Game::curmap->mod_tile(c)->flags |= TF_OCCUPIED;
			PCs.push_back(PCEnt(c, it));
			it->own_pc = &(*(--PCs.end()));
			it->own_vp->set_pos(c);
			it->sector = Game::curmap->coords_in_sector(c);
			follow_change(it, it);

			it->action_queue.clear();
			it->set_class();
			it->own_vp->set_losr(it->cl_props.losr);
			it->init_torch();
			send_state_upd(it);

			// After placing 9 players, place the next 9 at the next spawn
			// place, if any:
			if(++spawned == 9)
			{
				if(fit == team_flags[t].begin())
					fit = --(team_flags[t].end());
				else
					--fit;
				c = (*fit)->getpos();
				init_nearby(c);
				spawned = 0;
			}
			else
				c = next_nearby();
		} // player in this team and dead
	} // go through players
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edi, %eax
imulq $0x18, %rax, %rax
leaq 0x2c5e0(%rip), %r15     # 0x42ef0
leaq (%r15,%rax), %r13
movb $0x1, %r14b
cmpq %r13, (%r15,%rax)
je 0x16b4e
movl %edi, -0x30(%rbp)
cmpl $0x1, %edi
jne 0x16961
cmpl $0x3, 0x2a8e4(%rip)     # 0x41214
jne 0x16961
movzwl 0x2bb46(%rip), %r12d    # 0x42480
callq 0x15d3a
movzwl 0x2bb3a(%rip), %eax     # 0x42480
testw %ax, %ax
je 0x16b60
cmpw %ax, %r12w
je 0x16961
leaq 0x29754(%rip), %rdi     # 0x400b0
callq 0x152e9
movq %r13, -0x40(%rbp)
movq 0x8(%r13), %r12
movq 0x2b2e8(%rip), %rax     # 0x41c58
movswl (%rax), %edi
callq 0x1d4f4
movq 0x10(%r12), %rax
movl 0x18(%rax), %eax
leaq -0x2c(%rbp), %rdi
movl %eax, (%rdi)
callq 0x1d501
leaq 0x2971e(%rip), %rcx     # 0x400b0
leaq 0x2c537(%rip), %rax     # 0x42ed0
movq %rcx, %r13
movl -0x30(%rbp), %edx
movq %r12, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movq (%r13), %r13
cmpq %rcx, %r13
je 0x16b42
cmpl %edx, 0xbc(%r13)
jne 0x169aa
movq %rcx, %rbx
movq %rax, %r14
leaq 0x10(%r13), %r12
movq %r12, %rdi
callq 0xe68e
testb %al, %al
movq %r14, %rax
movq %rbx, %rcx
movl -0x30(%rbp), %edx
jne 0x169aa
jmp 0x169fb
leaq -0x70(%rbp), %r15
movq %r15, %rdi
callq 0x1d529
movl -0x70(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq %r15, %rdi
callq 0x24d9e
movq 0x2b256(%rip), %rax     # 0x41c58
movswq -0x2a(%rbp), %rcx
movq 0x8(%rax), %rdx
imulq $0x18, %rcx, %rcx
movswq -0x2c(%rbp), %rax
movq (%rdx,%rcx), %rcx
movl (%rcx,%rax,4), %edx
movl %edx, %esi
andl $0x641, %esi            # imm = 0x641
cmpl $0x1, %esi
jne 0x169e1
orl $0x40, %edx
movw %dx, (%rcx,%rax,4)
leaq -0x70(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
movq %r13, %rdx
callq 0x1cb3a
movq %r14, %rdi
movq %r14, %r15
leaq -0x70(%rbp), %rsi
callq 0x17f96
leaq -0x70(%rbp), %rdi
callq 0x1c9c8
movq 0x8(%r15), %rax
addq $0x10, %rax
movq %rax, 0x148(%r13)
movq 0xd0(%r13), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x194b2
movq 0x2b1db(%rip), %rdi     # 0x41c58
leaq -0x2c(%rbp), %rsi
callq 0x128ac
movl %eax, 0x16c(%r13)
movq %r13, %rdi
movq %r13, %rsi
callq 0x1716c
leaq 0xe8(%r13), %rdi
callq 0x17e6e
movq %r12, %rdi
callq 0xe6aa
movq 0xd0(%r13), %rax
movb 0x15a(%r13), %cl
movb %cl, (%rax)
movq %r12, %rdi
callq 0xe6fc
movq %r13, %rdi
callq 0x16e3c
movl -0x34(%rbp), %eax
incb %al
movl %eax, -0x34(%rbp)
cmpb $0x9, %al
je 0x16b00
leaq -0x70(%rbp), %r12
movq %r12, %rdi
callq 0x1d529
movl -0x70(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq %r12, %rdi
callq 0x24d9e
movq %r14, %rax
movq %rbx, %rcx
movl -0x30(%rbp), %edx
jmp 0x169aa
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %r12
cmpq (%rax), %r12
cmoveq %rax, %r12
movq 0x8(%r12), %r12
movq 0x10(%r12), %rax
movl 0x18(%rax), %eax
movl %eax, -0x70(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x24d9e
leaq -0x2c(%rbp), %rdi
callq 0x1d501
movq %r14, %rax
movq %rbx, %rcx
movl -0x30(%rbp), %edx
jmp 0x1699f
leaq -0x2c(%rbp), %rdi
callq 0x24d9e
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x18, %r15
movq %r15, %rdi
callq 0x17f74
jmp 0x16b4e
jmp 0x16b88
jmp 0x16b88
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x1c9c8
jmp 0x16b8b
jmp 0x16b88
jmp 0x16b88
jmp 0x16b88
jmp 0x16b88
movq %rax, %rbx
leaq -0x2c(%rbp), %rdi
callq 0x24d9e
movq %rbx, %rdi
callq 0x4710