// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq 0x27a2a(%rip), %rax     # 0x82d40
movq 0x408(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x27230(%rip), %rdx     # 0x82558
movq (%rdx), %rdx
subq %rdx, %rax
movl $0x4a8, %esi            # imm = 0x4A8
cqto
idivq %rsi
subq $0x1, %rax
imulq $0x9140, %rax, %rax     # imm = 0x9140
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x58(%rax)
movq 0x27b6b(%rip), %rax     # 0x82ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x5b369
jp 0x5b369
jmp 0x5b377
movq -0x8(%rbp), %rdi
callq 0x19020
jmp 0x5b512
movq -0x8(%rbp), %rax
cmpl $0x1, 0x60(%rax)
jne 0x5b3de
movl $0x0, -0xc(%rbp)
cmpl $0x3, -0xc(%rbp)
jge 0x5b3dc
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0xc(%rbp), %rcx
movss 0x15986(%rip), %xmm0    # 0x70d28
mulss 0x1c(%rax,%rcx,4), %xmm0
movss 0x15974(%rip), %xmm1    # 0x70d24
divss %xmm1, %xmm0
cvttss2si %xmm0, %eax
andl $0xffff, %eax           # imm = 0xFFFF
movw %ax, %dx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0xc(%rbp), %rcx
movw %dx, 0x14(%rax,%rcx,2)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x5b388
jmp 0x5b40f
movq -0x8(%rbp), %rdi
callq 0x18f50
movq -0x8(%rbp), %rax
leaq 0x15fa5(%rip), %rcx     # 0x71397
movq %rcx, 0x138(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x18ee0
movq -0x8(%rbp), %rdi
callq 0x18af0
movq 0x2798a(%rip), %rax     # 0x82da0
movss 0xc8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x5b42a
jp 0x5b42a
jmp 0x5b438
movq -0x8(%rbp), %rdi
callq 0x192b0
jmp 0x5b509
movq 0x27901(%rip), %rax     # 0x82d40
cmpl $0x1, 0x610(%rax)
jle 0x5b507
movl $0x1, %edi
movq 0x271a8(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x2719b(%rip), %rax     # 0x82600
movq 0xd0(%rax), %rax
movq %rax, -0x218(%rbp)
movq -0x8(%rbp), %rax
movq 0x270da(%rip), %rcx     # 0x82558
movq (%rcx), %rcx
subq %rcx, %rax
movl $0x4a8, %ecx            # imm = 0x4A8
cqto
idivq %rcx
movq %rax, %rcx
movq -0x218(%rbp), %rax
movl %ecx, %edi
callq *%rax
movl $0x9, %edi
movq 0x27158(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x2714b(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
movl $0x2, %esi
callq *%rax
leaq -0x210(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdx
addq $0xc0, %rdx
addq $0x200, %rdx            # imm = 0x200
leaq 0x1bca0(%rip), %rsi     # 0x7718f
movb $0x0, %al
callq 0x19940
leaq -0x210(%rbp), %rsi
movl $0x2, %edi
callq 0x19470
jmp 0x5b509
movq -0x8(%rbp), %rdi
callq 0x18bd0
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nopl (%rax,%rax)