// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_ctffunc.c
// Function: ctf_playerdropflag
void ctf_playerdropflag(edict_t * whichplayer, gitem_t *item)
{
	edict_t * whichflag;
	char flagcolor[MAX_INFO_STRING];
	char message[MAX_INFO_STRING];

	flagcolor[0] = 0;
	//this function doesn't use validate player because it should always succeed
	//even for players that are not inuse

	if (whichplayer && whichplayer->client)
	{
		whichflag = ctf_getteamflag(whichplayer->client->ctf.teamnum, CTF_TEAM_OPPOSING);
		ctf_resetflagandplayer(whichflag,whichplayer);
		if (whichflag)
		{
			//reset & relink the flag
			ctf_ResetFlagProps(whichflag);
			whichflag->owner = whichplayer;
			whichflag->touch = drop_temp_touch; // untouchable?
			whichflag->think = Drop_Flag_Think;
			whichflag->nextthink = level.time + 1;

			//toss the flag out from player
			ctf_TossEnt(whichplayer, whichflag);

			//annouce to the world
			ctf_teamstring(flagcolor, whichplayer->client->ctf.teamnum, CTF_TEAM_OPPOSING);
			Com_sprintf(message, sizeof message, "%s lost the %s flag.\n",
				whichplayer->client->pers.netname, flagcolor );
			
			stats_add(whichplayer, STATS_OFFENSE_FLAGLOST, 1); // STATS - LM_Hati

			// STDLog Flag Carrier Frag - Surt
			sl_LogScore( &gi,
				whichplayer->client->pers.netname,
				NULL,
				"FC LostFlag",
				NULL,
				0, //value of this event FIXME we need to make these symbolic surt
				level.time );
			ctf_BSafePrint(PRINT_HIGH, message);

			whichflag->droptime = level.time;
			gi.linkentity (whichflag);

		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movb $0x0, (%rsp)
testq %rdi, %rdi
je 0x21608
movq %rdi, %rbx
movq 0x58(%rdi), %rax
testq %rax, %rax
je 0x21608
movl 0x1100(%rax), %eax
cmpl $0x2, %eax
je 0x214e1
cmpl $0x1, %eax
jne 0x214ed
movq 0x48381(%rip), %rax     # 0x69860
jmp 0x214e8
movq 0x48310(%rip), %rax     # 0x697f8
movq (%rax), %r14
jmp 0x214f0
xorl %r14d, %r14d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x19080
testq %r14, %r14
je 0x21608
movq %r14, %rdi
callq 0x18580
movq %rbx, 0x110(%r14)
movq 0x4806e(%rip), %rax     # 0x69588
movq %rax, 0x220(%r14)
movq 0x483c8(%rip), %rax     # 0x698f0
movq %rax, 0x210(%r14)
movq 0x4886a(%rip), %rax     # 0x69da0
movss 0x4(%rax), %xmm0
addss 0x329e5(%rip), %xmm0    # 0x53f28
movss %xmm0, 0x200(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x188a0
movq 0x58(%rbx), %r13
movl 0x1100(%r13), %esi
movq %rsp, %rbp
movq %rbp, %rdi
movl $0xfffffffa, %edx       # imm = 0xFFFFFFFA
callq 0x181f0
movl $0x2c0, %r12d           # imm = 0x2C0
addq %r12, %r13
leaq 0x33020(%rip), %rdx     # 0x545a2
leaq 0x200(%rsp), %r15
movq %r15, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r13, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x18e10
movl $0x1, %edx
movq %rbx, %rdi
movl $0xe, %esi
callq 0x19330
addq 0x58(%rbx), %r12
movq 0x487e4(%rip), %r13     # 0x69da0
movss 0x4(%r13), %xmm0
movq 0x48037(%rip), %rbx     # 0x69600
leaq 0x32fe8(%rip), %rcx     # 0x545b8
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x18e90
movl $0x2, %edi
movq %r15, %rsi
callq 0x19270
movss 0x4(%r13), %xmm0
movss %xmm0, 0x4a0(%r14)
movq %r14, %rdi
callq *0x90(%rbx)
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq