// File: /workspace/github_c_makefile_star2_O3/QwazyWabbitWOS[P]lmctf60/p_client.c
// Function: ClientBegin
void ClientBegin (edict_t *ent)
{
	int 	i;
	char	message[MAX_INFO_STRING];
	
	ent->client = game.clients + (ent - g_edicts - 1);

	//sprintf(DBuffer, "cb0 t %d p %d r %d", ent->client->ctf.teamnum,
	//	ent->client->pers.spectator, ent->client->resp.spectator);
	//Debug_Show(DBuffer);
	//ctf_BSafePrint(PRINT_HIGH, DBuffer);

	//if(ent->client->ctf.teamnum <= CTF_TEAM_OBSERVER)
	//{
	//	ent->client->pers.spectator = 1;
	//	ent->client->resp.spectator = 1;
	//}
	//else
	//{
	//	ent->client->pers.spectator = 0;
	//	ent->client->resp.spectator = 0;
	//}


	if (deathmatch->value)
	{
		ClientBeginDeathmatch (ent);
		return;
	}

	// if there is already a body waiting for us (a loadgame), just
	// take it, otherwise spawn one from scratch
	if (ent->inuse == true)
	{
		// the client has cleared the client side viewangles upon
		// connecting to the server, which is different than the
		// state when the game is saved, so we need to compensate
		// with deltaangles
		for (i=0 ; i<3 ; i++)
			ent->client->ps.pmove.delta_angles[i] = ANGLE2SHORT(ent->client->ps.viewangles[i]);
	}
	else
	{
		// a spawn point will completely reinitialize the entity
		// except for the persistent data that was initialized at
		// ClientConnect() time
		G_InitEdict (ent);
		ent->classname = "player";
		InitClientResp (ent->client);
		PutClientInServer (ent);
	}


	//sprintf(DBuffer, "cb1 t %d p %d r %d", ent->client->ctf.teamnum,
	//	ent->client->pers.spectator, ent->client->resp.spectator);
	//Debug_Show(DBuffer);

	if (level.intermissiontime)
	{
		MoveClientToIntermission (ent);
	}
	else
	{
		// send effect if in a multiplayer game
		if (game.maxclients > 1)
		{
			gi.WriteByte (svc_muzzleflash);
			gi.WriteShort (ent-g_edicts);
			gi.WriteByte (MZ_LOGIN);
			gi.multicast (ent->s.origin, MULTICAST_PVS);

			sprintf(message, "%s entered the game\n", ent->client->pers.netname);
			ctf_BSafePrint(PRINT_HIGH, message);
		}
	}

	// make sure all view stuff is valid
	ClientEndServerFrame (ent);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdi, %rbx
movq 0x23450(%rip), %rbp     # 0x68d40
movq 0x22c61(%rip), %r13     # 0x68558
movq %rdi, %rdx
subq (%r13), %rdx
movq 0x408(%rbp), %rax
shrq $0x3, %rdx
movabsq $0x6a86036fad87bc40, %rcx # imm = 0x6A86036FAD87BC40
imulq %rdx, %rcx
leaq (%rax,%rcx), %rdx
addq $-0x9140, %rdx          # imm = 0xFFFF6EC0
movq %rdx, 0x58(%rdi)
movq 0x23593(%rip), %rdx     # 0x68ec0
movq (%rdx), %rdx
movss 0x20(%rdx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x4593f
jnp 0x45958
movq %rbx, %rdi
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x18ea0
cmpl $0x1, 0x60(%rbx)
jne 0x459a2
addq %rcx, %rax
movq $-0x2449, %rcx          # imm = 0xDBB7
movss 0xe3f0(%rip), %xmm0     # 0x53d60
movss 0xe3ec(%rip), %xmm1     # 0x53d64
movss (%rax,%rcx,4), %xmm2
mulss %xmm0, %xmm2
divss %xmm1, %xmm2
cvttss2si %xmm2, %edx
movw %dx, -0x489a(%rax,%rcx,2)
incq %rcx
cmpq $-0x2446, %rcx          # imm = 0xDBBA
jne 0x45978
jmp 0x45a3c
movq %rbx, %rdi
callq 0x18dd0
leaq 0xe9de(%rip), %rax      # 0x5438f
movq %rax, 0x138(%rbx)
movq 0x58(%rbx), %r14
leaq 0x1100(%r14), %r15
leaq 0x4b5de(%rip), %rdi     # 0x90fa8
movl $0x8038, %edx           # imm = 0x8038
movq %r15, %rsi
callq 0x18c80
leaq 0x758(%r14), %r12
movl $0x6b0, %edx            # imm = 0x6B0
movq %r12, %rdi
xorl %esi, %esi
callq 0x18880
movq 0x233ac(%rip), %rax     # 0x68da0
movl (%rax), %eax
movl %eax, 0xdf0(%r14)
movq 0x23154(%rip), %rax     # 0x68b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
testb $0x4, %al
je 0x45a1d
cmpl $-0x4, (%r15)
ja 0x45a1d
movl $0x0, (%r15)
addq $0xc0, %r14
movl $0x698, %edx            # imm = 0x698
movq %r12, %rdi
movq %r14, %rsi
callq 0x18c80
movq %rbx, %rdi
callq 0x18a20
movq 0x2335d(%rip), %rax     # 0x68da0
movss 0xc8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x45a55
jnp 0x45a5f
movq %rbx, %rdi
callq 0x190e0
jmp 0x45ad9
cmpl $0x2, 0x610(%rbp)
jl 0x45ad9
movq 0x22b91(%rip), %r14     # 0x68600
movl $0x1, %edi
callq *0xc8(%r14)
movq %rbx, %rax
subq (%r13), %rax
shrq $0x3, %rax
imull $0x8ce2cabd, %eax, %edi # imm = 0x8CE2CABD
callq *0xd0(%r14)
movl $0x9, %edi
callq *0xc8(%r14)
leaq 0x4(%rbx), %rdi
movl $0x2, %esi
callq *0xb0(%r14)
movl $0x2c0, %edx            # imm = 0x2C0
addq 0x58(%rbx), %rdx
leaq 0x149fe(%rip), %rsi     # 0x5a4bd
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x196f0
movl $0x2, %edi
movq %r14, %rsi
callq 0x19270
movq %rbx, %rdi
callq 0x18b00
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq