// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_ctffunc.c
// Function: ctf_ResetFlagProps
void ctf_ResetFlagProps(edict_t * whichflag)
{
	float		*v;
	trace_t		tr;
	vec3_t		dest;

	if (whichflag->owner)
	{
		whichflag->s.modelindex = whichflag->owner->s.modelindex3; // Turn on model
	}
	if (whichflag->model)
		gi.setmodel (whichflag, whichflag->model);
	else
		gi.setmodel (whichflag, whichflag->item->world_model);
	
	v = tv(-15,-15,-15);
	VectorCopy (v, whichflag->mins);
	v = tv(15,15,33);
	VectorCopy (v, whichflag->maxs);
	
	whichflag->solid = SOLID_TRIGGER;
	gi.linkentity(whichflag); //we changed solidity

	whichflag->movetype = MOVETYPE_TOSS;
	whichflag->touch = Touch_Item; //this then calls the pickup function as a wrapper
	whichflag->owner = NULL;
	whichflag->droptime = 0;
	v = tv(0,0,-128);
	VectorAdd (whichflag->s.origin, v, dest);
	
	tr = gi.trace (whichflag->s.origin, whichflag->mins, whichflag->maxs, dest, whichflag, MASK_SOLID);
	
	VectorCopy (tr.endpos, whichflag->s.origin);
	VectorClear (whichflag->s.angles);
	
	//surt, a flag caught moving can land off the pedastal if you don't clear the velocity
	VectorClear(whichflag->velocity);
	whichflag->flags |= FL_RESPAWN;
	
	whichflag->nextthink = level.time + FRAMETIME;	
	whichflag->think = ctf_flagwave;

}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rdi, %rbx
movq 0x110(%rdi), %rax
testq %rax, %rax
je 0x1f47c
movl 0x30(%rax), %eax
movl %eax, 0x28(%rbx)
movq 0x120(%rbx), %rsi
movq 0x47176(%rip), %r13     # 0x66600
movq 0x58(%r13), %rax
testq %rsi, %rsi
jne 0x1f49e
movq 0x330(%rbx), %rcx
movq 0x30(%rcx), %rsi
movq %rbx, %rdi
callq *%rax
movss 0x2ffa5(%rip), %xmm0    # 0x4f450
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x196c0
movss (%rax), %xmm0
leaq 0xcc(%rbx), %r14
movss %xmm0, 0xcc(%rbx)
movss 0x4(%rax), %xmm0
movss %xmm0, 0xd0(%rbx)
movss 0x8(%rax), %xmm0
movss %xmm0, 0xd4(%rbx)
movss 0x2ff69(%rip), %xmm0    # 0x4f454
movss 0x2ff65(%rip), %xmm2    # 0x4f458
movaps %xmm0, %xmm1
callq 0x196c0
movss (%rax), %xmm0
leaq 0xd8(%rbx), %r15
movss %xmm0, 0xd8(%rbx)
movss 0x4(%rax), %xmm0
movss %xmm0, 0xdc(%rbx)
movss 0x8(%rax), %xmm0
movss %xmm0, 0xe0(%rbx)
movl $0x1, 0x108(%rbx)
movq %rbx, %rdi
callq *0x90(%r13)
movl $0x7, 0x118(%rbx)
movq 0x47333(%rip), %rax     # 0x66880
movq %rax, 0x220(%rbx)
andq $0x0, 0x110(%rbx)
andl $0x0, 0x4a0(%rbx)
movss 0x2fef1(%rip), %xmm2    # 0x4f45c
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x196c0
leaq 0x4(%rbx), %rsi
movsd 0x4(%rbx), %xmm0
movsd (%rax), %xmm1
addps %xmm0, %xmm1
leaq 0x8(%rsp), %r8
movlps %xmm1, (%r8)
movss 0xc(%rbx), %xmm0
addss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%r8)
movl $0x3, (%rsp)
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r14, %rdx
movq %r15, %rcx
movq %rbx, %r9
callq *0x60(%r13)
movss 0x14(%r12), %xmm0
movsd 0xc(%r12), %xmm1
movsd %xmm1, 0x4(%rbx)
movss %xmm0, 0xc(%rbx)
andl $0x0, 0x18(%rbx)
andq $0x0, 0x10(%rbx)
andl $0x0, 0x1c8(%rbx)
andq $0x0, 0x1c0(%rbx)
orb $-0x80, 0x11f(%rbx)
movq 0x477a7(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
addss 0x2fc8a(%rip), %xmm0    # 0x4f290
movss %xmm0, 0x200(%rbx)
movq 0x46fab(%rip), %rax     # 0x665c0
movq %rax, 0x210(%rbx)
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq