// File: /workspace/github_cpp_makefile_star2_O2/lotuskip[P]yuxtapa/server/game.cpp
// Function: Game::remove_player(std::_List_iterator<Player>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
list<Player>::iterator Game::remove_player(list<Player>::iterator pit,
	const string &reason)
{
	// last_seen was updated when the player connected (and
	// adjusted after each intermission):
	if(intermission)
		pit->stats_i->last_seen += time(NULL) - pit->last_switched_cl;
	else
	{
		del_owneds(pit);
		// Remove any poisoning caused by this player!
		for(list<Player>::iterator it = cur_players.begin();
			it != cur_players.end(); ++it)
		{
			if(it->poisoner == pit)
				it->poisoner = cur_players.end();
		}
	}
	pit->stats_i->total_time += time(NULL) - pit->stats_i->last_seen;
	time(&(pit->stats_i->last_seen));

	if(pit->team != T_SPEC)
	{
		pit->own_vp->move_watchers();
		--num_players[pit->team - T_GREEN];
		send_team_upds(cur_players.end());
	}

	if(pit->is_alive())
		kill_player(pit); // this records time spent as a class
	else
	{
		pit->viewn_vp->drop_watcher(pit->stats_i->ID);
		// if is spec, record time spent as spec:
		if(pit->team == T_SPEC && !intermission)
			pit->stats_i->time_specced += time(NULL) - pit->last_switched_cl;
	}
	
	// If it is a bot, kill the process and ditch stats:
	if(pit->botpid != -1)
	{
		known_players.erase(pit->stats_i);
		Network::send_buffer.clear();
		Network::send_buffer.add((unsigned char)MID_QUIT);
		Network::send_to_player(*pit);
		int cet;
		waitpid(pit->botpid, &cet, 0);
	}
	
	string msg = pit->nick + reason;
	list<Player>::iterator retval = cur_players.erase(pit);
	Network::to_chat(msg);

	// minplayers != 0 implies (by checks in settings.cpp) that bots are around
	if(cur_players.size() < int_settings[IS_MINPLAYERS])
	{
		/* if ALL remaining players are now bots, drop them all */
		if((unsigned int)num_bots() == cur_players.size())
		{
			while(drop_a_bot()); // not fast, but simple
		}
		else // otherwise fill up with a bot
			spawn_bot();
	}

	if(cur_players.empty())
		timed_log("no more players, awaiting connections.");
	else
		active_teambal_check();

	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x26848(%rip), %r12     # 0x3d400
cmpb $0x1, (%r12)
jne 0x16c53
xorl %edi, %edi
callq 0x43c0
subq 0xc8(%rbx), %rax
movq 0x90(%rbx), %rcx
addq %rax, 0x138(%rcx)
xorl %edi, %edi
callq 0x43c0
leaq 0x10(%rbx), %r15
movq 0x90(%rbx), %rcx
subq 0x138(%rcx), %rax
leaq 0x138(%rcx), %rdi
addq %rax, 0xb0(%rcx)
callq 0x43c0
cmpl $0x2, 0xbc(%rbx)
je 0x16c3d
movq 0xd0(%rbx), %rdi
callq 0x19584
movslq 0xbc(%rbx), %rax
leaq 0x2a5e3(%rip), %rcx     # 0x41211
decb (%rax,%rcx)
leaq 0x29478(%rip), %rdi     # 0x400b0
callq 0x152e9
movq %r15, %rdi
callq 0xe68e
testb %al, %al
je 0x16c83
movq %rbx, %rdi
callq 0x1fe5c
jmp 0x16cc6
movq %rbx, %rdi
callq 0x17b0c
leaq 0x2944e(%rip), %rax     # 0x400b0
movq %rax, %rcx
movq (%rcx), %rcx
cmpq %rax, %rcx
je 0x16bdf
cmpq %rbx, 0x160(%rcx)
jne 0x16c65
movq %rax, 0x160(%rcx)
jmp 0x16c65
movq 0x90(%rbx), %rax
movq 0xd8(%rbx), %rdi
movzwl 0x10(%rax), %esi
callq 0x1954a
cmpl $0x2, 0xbc(%rbx)
jne 0x16cc6
cmpb $0x0, (%r12)
jne 0x16cc6
xorl %edi, %edi
callq 0x43c0
subq 0xc8(%rbx), %rax
movq 0x90(%rbx), %rcx
addq %rax, 0xb8(%rcx)
cmpl $-0x1, 0x174(%rbx)
je 0x16d18
movq 0x90(%rbx), %rsi
leaq 0x293bb(%rip), %rdi     # 0x40098
callq 0xfe68
leaq 0x2742f(%rip), %r12     # 0x3e118
movq %r12, %rdi
callq 0x24712
pushq $0x2
popq %rsi
movq %r12, %rdi
callq 0x24724
movq %r15, %rdi
movq %r12, %rsi
callq 0xc3a6
movl 0x174(%rbx), %edi
leaq -0x68(%rbp), %rsi
xorl %edx, %edx
callq 0x4300
leaq 0x98(%rbx), %rsi
leaq -0x68(%rbp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0xfe1f
leaq 0x2937b(%rip), %r14     # 0x400b0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x17f44
movq %rax, %rbx
movq %r15, %rdi
callq 0xc248
leaq 0x28b3e(%rip), %rax     # 0x3f890
movl 0x2c(%rax), %eax
cmpq %rax, 0x10(%r14)
jae 0x16d7c
callq 0xf89e
movswq %ax, %rax
movl %eax, %eax
cmpq 0x10(%r14), %rax
jne 0x16d77
callq 0x23ecd
testb %al, %al
jne 0x16d6c
jmp 0x16d7c
callq 0x23dd2
cmpq %r14, (%r14)
je 0x16d88
callq 0x17cd0
jmp 0x16dae
leaq 0x12348(%rip), %rsi     # 0x290d7
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0xb292
leaq -0x48(%rbp), %rdi
callq 0x10c94
leaq -0x48(%rbp), %rdi
callq 0x47e8
leaq -0x68(%rbp), %rdi
callq 0x47e8
movq %rbx, %rax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x47e8
jmp 0x16ddc
jmp 0x16dd9
jmp 0x16dd9
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x47e8
movq %rbx, %rdi
callq 0x4710