// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_ctffunc.c
// Function: ctf_findplayer
edict_t * ctf_findplayer(edict_t * ent_after, edict_t * ignore, int teamnum_wanted)
{
	edict_t * temp;

	if (ent_after == NULL)
		temp = g_edicts + 1;
	else
		temp = ent_after + 1;

	while ( (temp - (g_edicts + 1)) < game.maxclients)
	{
		if (ctf_validateplayer(temp, CTF_TEAM_IGNORETEAM) ) //make sure we're looking at something valid
		{
			if (temp != ignore) //null ignore would get caught by the outer loop
			{
				if (teamnum_wanted == CTF_TEAM_IGNORETEAM) //just want to find players
				{
					return temp;
				}
				else if (teamnum_wanted == CTF_TEAM_ANYTEAM) //want to find players on teams
				{
					if (temp->client->ctf.teamnum > CTF_TEAM_UNDEFINED) //CTF_TEAM_UNDEFINED or less are not real teams
						return temp;
				}
				else if (temp->client->ctf.teamnum == teamnum_wanted) //want player on specific team
				{
					return temp;
				}
			}
		}
		temp++;
	}
		
		
/*
	edict_t * temp;

	temp = G_Find (ent_after, FOFS(classname), "player");
	while ( temp != NULL )
	{
		if (ctf_validateplayer(temp, CTF_TEAM_IGNORETEAM) ) //make sure we're looking at something valid
		{
			if (temp != ignore) //null ignore would get caught by the outer loop
			{
				if (teamnum_wanted == CTF_TEAM_IGNORETEAM) //just want to find players
				{
					return temp;
				}
				else if (teamnum_wanted == CTF_TEAM_ANYTEAM) //want to find players on teams
				{
					if (temp->client->ctf.teamnum > CTF_TEAM_UNDEFINED) //CTF_TEAM_UNDEFINED or less are not real teams
						return temp;
				}
				else if (temp->client->ctf.teamnum == teamnum_wanted) //want player on specific team
				{
					return temp;
				}
			}
		}
		temp = G_Find (temp, FOFS(classname), "player");
	}
	*/

	return NULL; //didn't find anything to return before here.
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x218d0
movq 0x60c97(%rip), %rax     # 0x82558
movq (%rax), %rax
addq $0x4a8, %rax            # imm = 0x4A8
movq %rax, -0x28(%rbp)
jmp 0x218de
movq -0x10(%rbp), %rax
addq $0x4a8, %rax            # imm = 0x4A8
movq %rax, -0x28(%rbp)
jmp 0x218e0
movq -0x28(%rbp), %rax
movq 0x60c6d(%rip), %rcx     # 0x82558
movq (%rcx), %rcx
addq $0x4a8, %rcx            # imm = 0x4A8
subq %rcx, %rax
movl $0x4a8, %ecx            # imm = 0x4A8
cqto
idivq %rcx
movq 0x61437(%rip), %rcx     # 0x82d40
movslq 0x610(%rcx), %rcx
cmpq %rcx, %rax
jge 0x219a1
movq -0x28(%rbp), %rdi
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
callq 0x18e40
cmpl $0x0, %eax
je 0x2198e
movq -0x28(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0x2198c
cmpl $-0x4, -0x1c(%rbp)
jne 0x21946
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x219a9
cmpl $-0x5, -0x1c(%rbp)
jne 0x21969
movq -0x28(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0x1100(%rax)
jle 0x21967
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x219a9
jmp 0x21988
movq -0x28(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x1100(%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0x21986
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x219a9
jmp 0x21988
jmp 0x2198a
jmp 0x2198c
jmp 0x2198e
movq -0x28(%rbp), %rax
addq $0x4a8, %rax            # imm = 0x4A8
movq %rax, -0x28(%rbp)
jmp 0x218e0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)