// File: /workspace/github_c_makefile_star2_O3/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 0x214d7
movq %rdi, %rbx
movq 0x58(%rdi), %rax
testq %rax, %rax
je 0x214d7
movl 0x1100(%rax), %eax
cmpl $0x1, %eax
je 0x213b5
cmpl $0x2, %eax
jne 0x214e9
movq 0x47445(%rip), %rax     # 0x687f8
jmp 0x213bc
movq 0x474a4(%rip), %rax     # 0x68860
movq (%rax), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x19080
testq %r14, %r14
je 0x214d7
movq %r14, %rdi
callq 0x18580
movq %rbx, 0x110(%r14)
movq 0x4719f(%rip), %rax     # 0x68588
movq %rax, 0x220(%r14)
movq 0x474f9(%rip), %rax     # 0x688f0
movq %rax, 0x210(%r14)
movq 0x4799b(%rip), %rax     # 0x68da0
movss 0x4(%rax), %xmm0
addss 0x31b16(%rip), %xmm0    # 0x52f28
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 0x32181(%rip), %rdx     # 0x535d2
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 0x47915(%rip), %r13     # 0x68da0
movss 0x4(%r13), %xmm0
movq 0x47168(%rip), %rbx     # 0x68600
leaq 0x32149(%rip), %rcx     # 0x535e8
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
xorl %edi, %edi
movq %rbx, %rsi
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x19080