// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_items.c
// Function: tossflag
void tossflag (edict_t *ent, vec3_t dir)
{	
	float		*v;
	vec3_t		temp;
	trace_t	tr;
		
	v = tv(-15,-15,-15);
	VectorCopy (v, ent->mins);
	v = tv(15,15,33);
	VectorCopy (v, ent->maxs);
	
	ent->flags |= FL_RESPAWN;
	ent->spawnflags = DROPPED_ITEM;

	if (ent->model)
		gi.setmodel (ent, ent->model);
	else
		gi.setmodel (ent, ent->item->world_model);
	//ent->solid = SOLID_BBOX;
	ent->solid = SOLID_TRIGGER;
	ent->movetype = MOVETYPE_TOSS;  
	ent->touch = Touch_Item;

	VectorCopy(ent->s.origin, temp);
	VectorClear (ent->s.angles);

	if (!dir || !dir[0] ) // Random toss
	{
		
		v = tv(0, 0, 48);
		VectorAdd (ent->s.origin, v, ent->s.origin);
		ent->velocity[0] = -500 + (random() * 1000);
		ent->velocity[1] = -500 + (random() * 1000);
		ent->velocity[2] = 400;
		
	}
	else
	{
		VectorScale(dir, 64, dir);
		VectorAdd (ent->s.origin, dir, ent->s.origin);
		VectorScale(dir, 4, dir);
		VectorCopy(dir, ent->velocity);
	}

	tr = gi.trace (temp, ent->mins, ent->maxs, ent->s.origin, ent, MASK_SOLID);
	if (tr.fraction < 1.0 || tr.allsolid)
	{
		VectorCopy(temp, ent->s.origin);
	}

	// FLAG MODEL SUPPORT
	ent->nextthink = level.time + FRAMETIME;
	ent->think = ctf_flagwave;

	ent->droptime = level.time;

	gi.linkentity (ent);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r13
movq %rdi, %rbx
movss 0x231ab(%rip), %xmm0    # 0x54440
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x19510
movss (%rax), %xmm0
movss %xmm0, 0xcc(%rbx)
movss 0x4(%rax), %xmm0
movss %xmm0, 0xd0(%rbx)
movss 0x8(%rax), %xmm0
movss %xmm0, 0xd4(%rbx)
movss 0x23176(%rip), %xmm0    # 0x54444
movss 0x23172(%rip), %xmm2    # 0x54448
movaps %xmm0, %xmm1
callq 0x19510
movss (%rax), %xmm0
movss %xmm0, 0xd8(%rbx)
movss 0x4(%rax), %xmm0
movss %xmm0, 0xdc(%rbx)
movss 0x8(%rax), %xmm0
movss %xmm0, 0xe0(%rbx)
orb $-0x80, 0x11f(%rbx)
movl $0x10000, 0x140(%rbx)   # imm = 0x10000
movq 0x120(%rbx), %rsi
movq 0x382dd(%rip), %rbp     # 0x69600
movq 0x58(%rbp), %rax
testq %rsi, %rsi
jne 0x31337
movq 0x330(%rbx), %rcx
movq 0x30(%rcx), %rsi
movq %rbx, %rdi
callq *%rax
leaq 0xcc(%rbx), %r14
leaq 0xd8(%rbx), %r15
movl $0x1, 0x108(%rbx)
movl $0x7, 0x118(%rbx)
movq 0x3851b(%rip), %rax     # 0x69880
movq %rax, 0x220(%rbx)
leaq 0x4(%rbx), %r12
movss 0x4(%rbx), %xmm0
movss %xmm0, 0x14(%rsp)
movss 0x8(%rbx), %xmm0
movss %xmm0, 0x18(%rsp)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x1c(%rsp)
movl $0x0, 0x18(%rbx)
movq $0x0, 0x10(%rbx)
testq %r13, %r13
je 0x31436
movss (%r13), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x313b9
jnp 0x31436
movss 0x22b57(%rip), %xmm0    # 0x53f18
movq %r13, %rdi
movq %r13, %rsi
callq 0x189d0
movss 0x4(%rbx), %xmm0
movss 0x8(%rbx), %xmm1
addss (%r13), %xmm0
movss %xmm0, 0x4(%rbx)
addss 0x4(%r13), %xmm1
movss %xmm1, 0x8(%rbx)
movss 0xc(%rbx), %xmm0
addss 0x8(%r13), %xmm0
movss %xmm0, 0xc(%rbx)
movss 0x22b04(%rip), %xmm0    # 0x53f08
movq %r13, %rdi
movq %r13, %rsi
callq 0x189d0
movss (%r13), %xmm0
movss %xmm0, 0x1c0(%rbx)
movss 0x4(%r13), %xmm0
movss %xmm0, 0x1c4(%rbx)
movss 0x8(%r13), %xmm0
jmp 0x314e1
movss 0x22e5a(%rip), %xmm2    # 0x54298
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x19510
movss 0x4(%rbx), %xmm0
movss 0x8(%rbx), %xmm1
addss (%rax), %xmm0
movss %xmm0, 0x4(%rbx)
addss 0x4(%rax), %xmm1
movss %xmm1, 0x8(%rbx)
movss 0xc(%rbx), %xmm0
addss 0x8(%rax), %xmm0
movss %xmm0, 0xc(%rbx)
callq 0x19a20
movl $0x7fff, %r13d          # imm = 0x7FFF
andl %r13d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x22df6(%rip), %xmm0    # 0x54288
mulss 0x22a76(%rip), %xmm0    # 0x53f10
addss 0x25a2a(%rip), %xmm0    # 0x56ecc
movss %xmm0, 0x1c0(%rbx)
callq 0x19a20
andl %r13d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x22dc7(%rip), %xmm0    # 0x54288
mulss 0x22a47(%rip), %xmm0    # 0x53f10
addss 0x259fb(%rip), %xmm0    # 0x56ecc
movss %xmm0, 0x1c4(%rbx)
movss 0x259ef(%rip), %xmm0    # 0x56ed0
movss %xmm0, 0x1c8(%rbx)
movl $0x3, (%rsp)
leaq 0x20(%rsp), %r13
leaq 0x14(%rsp), %rsi
movq %r13, %rdi
movq %r14, %rdx
movq %r15, %rcx
movq %r12, %r8
movq %rbx, %r9
callq *0x60(%rbp)
movss 0x22a14(%rip), %xmm0    # 0x53f28
ucomiss 0x8(%r13), %xmm0
ja 0x31522
cmpl $0x0, 0x20(%rsp)
je 0x31543
movss 0x14(%rsp), %xmm0
movss %xmm0, 0x4(%rbx)
movss 0x18(%rsp), %xmm0
movss %xmm0, 0x8(%rbx)
movss 0x1c(%rsp), %xmm0
movss %xmm0, 0xc(%rbx)
movq 0x38856(%rip), %rax     # 0x69da0
movss 0x4(%rax), %xmm0
movss 0x22d39(%rip), %xmm1    # 0x54290
addss %xmm0, %xmm1
movss %xmm1, 0x200(%rbx)
movq 0x38056(%rip), %rax     # 0x695c0
movq %rax, 0x210(%rbx)
movss %xmm0, 0x4a0(%rbx)
movq %rbx, %rdi
callq *0x90(%rbp)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq