// File: /workspace/github_c_makefile_star2_O2/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 0x1fb9b
movq %rdi, %r14
movq 0x58(%rdi), %rax
testq %rax, %rax
je 0x1fb9b
movl 0x1100(%rax), %eax
cmpl $0x2, %eax
je 0x1fa7e
cmpl $0x1, %eax
jne 0x1fa8a
movq 0x46de4(%rip), %rax     # 0x66860
jmp 0x1fa85
movq 0x46d73(%rip), %rax     # 0x667f8
movq (%rax), %rbx
jmp 0x1fa8c
xorl %ebx, %ebx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x191d0
testq %rbx, %rbx
je 0x1fb9b
movq %rbx, %rdi
callq 0x185c0
movq %r14, 0x110(%rbx)
movq 0x46ad2(%rip), %rax     # 0x66588
movq %rax, 0x220(%rbx)
movq 0x46e2c(%rip), %rax     # 0x668f0
movq %rax, 0x210(%rbx)
movq 0x472ce(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
addss 0x2f449(%rip), %xmm0    # 0x4ef28
movss %xmm0, 0x200(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x18900
movq 0x58(%r14), %r13
movl 0x1100(%r13), %esi
movq %rsp, %rbp
pushq $-0x6
popq %rdx
movq %rbp, %rdi
callq 0x18210
movl $0x2c0, %r12d           # imm = 0x2C0
addq %r12, %r13
leaq 0x2fab7(%rip), %rdx     # 0x4f5d2
leaq 0x200(%rsp), %r15
movq %r15, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r13, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x18f30
pushq $0xe
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x194d0
addq 0x58(%r14), %r12
movq 0x4724f(%rip), %r13     # 0x66da0
movss 0x4(%r13), %xmm0
movq 0x46aa2(%rip), %r14     # 0x66600
leaq 0x2fa83(%rip), %rcx     # 0x4f5e8
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x18fb0
pushq $0x2
popq %rdi
movq %r15, %rsi
callq 0x193f0
movss 0x4(%r13), %xmm0
movss %xmm0, 0x4a0(%rbx)
movq %rbx, %rdi
callq *0x90(%r14)
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq