// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_weapon.c
// Function: fire_hit
qboolean fire_hit (edict_t *self, vec3_t aim, int damage, int kick)
{
	trace_t		tr;
	vec3_t		forward, right, up;
	vec3_t		v;
	vec3_t		point;
	float		range;
	vec3_t		dir;

	//see if enemy is in range
	VectorSubtract (self->enemy->s.origin, self->s.origin, dir);
	range = VectorLength(dir);
	if (range > aim[0])
		return false;

	if (aim[1] > self->mins[0] && aim[1] < self->maxs[0])
	{
		// the hit is straight on so back the range up to the edge of their bbox
		range -= self->enemy->maxs[0];
	}
	else
	{
		// this is a side hit so adjust the "right" value out to the edge of their bbox
		if (aim[1] < 0)
			aim[1] = self->enemy->mins[0];
		else
			aim[1] = self->enemy->maxs[0];
	}

	VectorMA (self->s.origin, range, dir, point);

	tr = gi.trace (self->s.origin, NULL, NULL, point, self, MASK_SHOT);
	if (tr.fraction < 1)
	{
		if (!tr.ent->takedamage)
			return false;
		// if it will hit any client/monster then hit the one we wanted to hit
		if ((tr.ent->svflags & SVF_MONSTER) || (tr.ent->client))
			tr.ent = self->enemy;
	}

	AngleVectors(self->s.angles, forward, right, up);
	VectorMA (self->s.origin, range, forward, point);
	VectorMA (point, aim[1], right, point);
	VectorMA (point, aim[2], up, point);
	VectorSubtract (point, self->enemy->s.origin, dir);

	// do the damage
	T_Damage (tr.ent, self, self, dir, point, vec3_origin, damage, kick/2, DAMAGE_NO_KNOCKBACK, MOD_HIT);

	if (!(tr.ent->svflags & SVF_MONSTER) && (!tr.ent->client))
		return false;

	// do our special form of knockback here
	VectorMA (self->enemy->absmin, 0.5, self->enemy->size, v);
	VectorSubtract (v, point, v);
	VectorNormalize (v);
	VectorMA (self->enemy->velocity, kick, v, self->enemy->velocity);
	if (self->enemy->velocity[2] > 0)
		self->enemy->groundentity = NULL;
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movq 0x2a0(%rdi), %rax
movsd 0x4(%rax), %xmm0
movsd 0x4(%rdi), %xmm1
subps %xmm1, %xmm0
leaq 0x28(%rsp), %rdi
movlps %xmm0, (%rdi)
movss 0xc(%rax), %xmm0
subss 0xc(%rbx), %xmm0
movss %xmm0, 0x8(%rdi)
callq 0x19460
ucomiss (%r15), %xmm0
jbe 0x3ba26
xorl %r14d, %r14d
jmp 0x3bc74
leaq 0x4(%rbx), %r13
movss 0x4(%r15), %xmm2
ucomiss 0xcc(%rbx), %xmm2
movl %ebp, 0xc(%rsp)
movq %r14, 0x20(%rsp)
jbe 0x3ba60
movss 0xd8(%rbx), %xmm1
ucomiss %xmm2, %xmm1
jbe 0x3ba60
movq 0x2a0(%rbx), %rax
subss 0xd8(%rax), %xmm0
jmp 0x3ba87
xorps %xmm1, %xmm1
ucomiss %xmm2, %xmm1
movq 0x2a0(%rbx), %rax
jbe 0x3ba79
movss 0xcc(%rax), %xmm1
jmp 0x3ba81
movss 0xd8(%rax), %xmm1
movss %xmm1, 0x4(%r15)
leaq 0x28(%rsp), %rsi
leaq 0x10(%rsp), %r12
movq %r13, %rdi
movss %xmm0, 0x8(%rsp)
movq %r12, %rdx
callq 0x19940
movq 0x2ab57(%rip), %rax     # 0x66600
subq $0x8, %rsp
xorl %r14d, %r14d
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
movq %rbx, %r9
pushq $0x6000003              # imm = 0x6000003
callq *0x60(%rax)
addq $0x10, %rsp
movq 0x40(%rbp), %r12
movss 0x1344b(%rip), %xmm0    # 0x4ef28
ucomiss 0x8(%rbp), %xmm0
jbe 0x3bb0c
cmpl $0x0, 0x27c(%r12)
je 0x3bc74
testb $0x4, 0xc8(%r12)
jne 0x3bb05
cmpq $0x0, 0x58(%r12)
je 0x3bb0c
movq 0x2a0(%rbx), %r12
leaq 0x10(%rbx), %rdi
leaq 0x60(%rsp), %rbp
leaq 0x44(%rsp), %rdx
leaq 0x38(%rsp), %rcx
movq %rbp, %rsi
callq 0x183d0
leaq 0x10(%rsp), %r14
movq %r13, %rdi
movss 0x8(%rsp), %xmm0
movq %rbp, %rsi
movq %r14, %rdx
callq 0x19940
movss 0x4(%r15), %xmm0
movq %r14, %rdi
leaq 0x44(%rsp), %rsi
movq %r14, %rdx
callq 0x19940
movss 0x8(%r15), %xmm0
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
movq %r14, %rdx
callq 0x19940
movq 0x2a0(%rbx), %rax
movsd (%r14), %xmm0
movsd 0x4(%rax), %xmm1
subps %xmm1, %xmm0
leaq 0x28(%rsp), %rcx
movlps %xmm0, (%rcx)
movss 0x8(%r14), %xmm0
subss 0xc(%rax), %xmm0
movss %xmm0, 0x8(%rcx)
pushq $0x2
popq %rsi
movl 0xc(%rsp), %ebp
movl %ebp, %eax
cltd
idivl %esi
movq 0x2abbd(%rip), %r9      # 0x66768
movq %r12, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
movq %r14, %r8
pushq $0x20
pushq $0x8
pushq %rax
pushq 0x38(%rsp)
callq 0x19260
addq $0x20, %rsp
testb $0x4, 0xc8(%r12)
jne 0x3bbe0
cmpq $0x0, 0x58(%r12)
je 0x3ba1e
movq 0x2a0(%rbx), %rsi
leaq 0xe4(%rsi), %rdi
addq $0xfc, %rsi
movss 0x14803(%rip), %xmm0    # 0x50400
leaq 0x50(%rsp), %r14
movq %r14, %rdx
callq 0x19940
movsd (%r14), %xmm0
movsd 0x10(%rsp), %xmm1
subps %xmm1, %xmm0
movlps %xmm0, (%r14)
movss 0x8(%r14), %xmm0
subss 0x18(%rsp), %xmm0
movss %xmm0, 0x8(%r14)
movq %r14, %rdi
callq 0x183c0
movl $0x1c0, %edi            # imm = 0x1C0
addq 0x2a0(%rbx), %rdi
cvtsi2ss %ebp, %xmm0
movq %r14, %rsi
movq %rdi, %rdx
callq 0x19940
movq 0x2a0(%rbx), %rax
movss 0x1c8(%rax), %xmm0
pushq $0x1
popq %r14
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3bc74
andq $0x0, 0x2b8(%rax)
movl %r14d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq