// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x420, %rsp            # imm = 0x420
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x220(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x234e9
movq -0x8(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x234e9
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x1100(%rax), %edi
movl $0xfffffffa, %esi       # imm = 0xFFFFFFFA
callq 0x18ef0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x19240
cmpq $0x0, -0x18(%rbp)
je 0x234e7
movq -0x18(%rbp), %rdi
callq 0x185e0
movq -0x8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x110(%rax)
movq -0x18(%rbp), %rax
movq 0x5f1cd(%rip), %rcx     # 0x82588
movq %rcx, 0x220(%rax)
movq -0x18(%rbp), %rax
movq 0x5f523(%rip), %rcx     # 0x828f0
movq %rcx, 0x210(%rax)
movss 0x4cb10(%rip), %xmm0    # 0x6feec
movq 0x5f9bd(%rip), %rax     # 0x82da0
addss 0x4(%rax), %xmm0
movq -0x18(%rbp), %rax
movss %xmm0, 0x200(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x18910
leaq -0x220(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x1100(%rax), %esi
movl $0xfffffffa, %edx       # imm = 0xFFFFFFFA
callq 0x18210
leaq -0x420(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rcx
addq $0xc0, %rcx
addq $0x200, %rcx            # imm = 0x200
leaq -0x220(%rbp), %r8
movl $0x200, %esi            # imm = 0x200
leaq 0x4d162(%rip), %rdx     # 0x705b2
movb $0x0, %al
callq 0x18f90
movq -0x8(%rbp), %rdi
movl $0xe, %esi
movl $0x1, %edx
callq 0x19550
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
addq $0xc0, %rsi
addq $0x200, %rsi            # imm = 0x200
movq 0x5f919(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
movq 0x5f16d(%rip), %rdi     # 0x82600
xorl %eax, %eax
movl %eax, %r8d
leaq 0x4d129(%rip), %rcx     # 0x705c8
xorl %r9d, %r9d
movq %r8, %rdx
callq 0x19010
leaq -0x420(%rbp), %rsi
movl $0x2, %edi
callq 0x19470
movq 0x5f8de(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
movq -0x18(%rbp), %rax
movss %xmm0, 0x4a0(%rax)
movq 0x5f126(%rip), %rax     # 0x82600
movq 0x90(%rax), %rax
movq -0x18(%rbp), %rdi
callq *%rax
jmp 0x234e9
addq $0x420, %rsp            # imm = 0x420
popq %rbp
retq
nopw %cs:(%rax,%rax)