// File: /workspace/github_cpp_makefile_star2_O1/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 $0x40, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x24402(%rip), %r12     # 0x40410
cmpb $0x1, (%r12)
jne 0x1c0a9
xorl %edi, %edi
callq 0x43b0
subq 0xc8(%rbx), %rax
movq 0x90(%rbx), %rcx
addq %rax, 0x138(%rcx)
xorl %edi, %edi
callq 0x43b0
leaq 0x10(%rbx), %r15
movq 0x90(%rbx), %rcx
subq 0x138(%rcx), %rax
leaq 0x138(%rcx), %rdi
addq %rax, 0xb0(%rcx)
callq 0x43b0
cmpl $0x2, 0xbc(%rbx)
je 0x1c093
movq 0xd0(%rbx), %rdi
callq 0x1ee1c
movslq 0xbc(%rbx), %rax
leaq 0x2819d(%rip), %rcx     # 0x44221
decb (%rax,%rcx)
leaq 0x27032(%rip), %rdi     # 0x430c0
callq 0x19f7b
movq %r15, %rdi
callq 0x125e6
testb %al, %al
je 0x1c0d9
movq %rbx, %rdi
callq 0x2589b
jmp 0x1c11c
movq %rbx, %rdi
callq 0x1d361
leaq 0x27008(%rip), %rax     # 0x430c0
movq (%rax), %rcx
cmpq %rax, %rcx
je 0x1c035
cmpq %rbx, 0x160(%rcx)
jne 0x1c0d4
movq %rax, 0x160(%rcx)
movq (%rcx), %rcx
jmp 0x1c0bb
movq 0x90(%rbx), %rax
movq 0xd8(%rbx), %rdi
movzwl 0x10(%rax), %esi
callq 0x1edc2
cmpl $0x2, 0xbc(%rbx)
jne 0x1c11c
cmpb $0x0, (%r12)
jne 0x1c11c
xorl %edi, %edi
callq 0x43b0
subq 0xc8(%rbx), %rax
movq 0x90(%rbx), %rcx
addq %rax, 0xb8(%rcx)
cmpl $-0x1, 0x174(%rbx)
je 0x1c170
movq 0x90(%rbx), %rsi
leaq 0x26f75(%rip), %rdi     # 0x430a8
callq 0x14ed0
leaq 0x24fe9(%rip), %r12     # 0x41128
movq %r12, %rdi
callq 0x2b340
movq %r12, %rdi
movl $0x2, %esi
callq 0x2b354
movq %r15, %rdi
movq %r12, %rsi
callq 0xf816
movl 0x174(%rbx), %edi
leaq -0x60(%rbp), %rsi
xorl %edx, %edx
callq 0x42f0
leaq 0x98(%rbx), %rsi
leaq -0x60(%rbp), %r12
movq %r12, %rdi
movq %r14, %rdx
callq 0x1483d
movq (%rbx), %r14
leaq 0x26f30(%rip), %r15     # 0x430c0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1de3c
movq %r12, %rdi
callq 0xf676
leaq 0x266f6(%rip), %rax     # 0x428a0
movl 0x2c(%rax), %eax
cmpq %rax, 0x10(%r15)
jae 0x1c1d4
callq 0x13ebc
movswq %ax, %rax
movl %eax, %eax
cmpq 0x10(%r15), %rax
jne 0x1c1cf
callq 0x2abe8
testb %al, %al
jne 0x1c1c4
jmp 0x1c1d4
callq 0x2aaab
cmpq %r15, (%r15)
je 0x1c1e0
callq 0x1d51a
jmp 0x1c21d
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x12eaf(%rip), %rsi     # 0x2f09e
leaq 0x12ece(%rip), %rdx     # 0x2f0c4
leaq -0x40(%rbp), %rdi
callq 0xdfec
leaq -0x40(%rbp), %rdi
callq 0x15254
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x1c21d
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1c236
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43f0
movq %r14, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x1c267
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0x1c267
jmp 0x1c264
jmp 0x1c264
movq %rax, %rbx
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1c280
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43f0
movq %rbx, %rdi
callq 0x4750