// File: /workspace/github_c_makefile_star2_O1/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 $0x98, %rsp
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movq 0x2a0(%rdi), %rax
movss 0x4(%rax), %xmm0
subss 0x4(%rdi), %xmm0
leaq 0x20(%rsp), %rdi
movss %xmm0, (%rdi)
movss 0x8(%rax), %xmm0
subss 0x8(%rbx), %xmm0
movss %xmm0, 0x4(%rdi)
movss 0xc(%rax), %xmm0
subss 0xc(%rbx), %xmm0
movss %xmm0, 0x8(%rdi)
callq 0x192e0
ucomiss (%r15), %xmm0
jbe 0x3f78b
xorl %r14d, %r14d
jmp 0x3fa00
leaq 0x4(%rbx), %r13
movss 0x4(%r15), %xmm2
ucomiss 0xcc(%rbx), %xmm2
movl %ebp, 0x8(%rsp)
movq %r14, 0x18(%rsp)
jbe 0x3f7c5
movss 0xd8(%rbx), %xmm1
ucomiss %xmm2, %xmm1
jbe 0x3f7c5
movq 0x2a0(%rbx), %rax
subss 0xd8(%rax), %xmm0
jmp 0x3f7ec
xorps %xmm1, %xmm1
ucomiss %xmm2, %xmm1
movq 0x2a0(%rbx), %rax
jbe 0x3f7de
movss 0xcc(%rax), %xmm1
jmp 0x3f7e6
movss 0xd8(%rax), %xmm1
movss %xmm1, 0x4(%r15)
leaq 0x20(%rsp), %rsi
leaq 0xc(%rsp), %r12
movq %r13, %rdi
movss %xmm0, 0x4(%rsp)
movq %r12, %rdx
callq 0x19770
movq 0x29df2(%rip), %rax     # 0x69600
subq $0x8, %rsp
xorl %r14d, %r14d
leaq 0x58(%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 0x146e6(%rip), %xmm0    # 0x53f28
ucomiss 0x8(%rbp), %xmm0
jbe 0x3f871
cmpl $0x0, 0x27c(%r12)
je 0x3fa00
testb $0x4, 0xc8(%r12)
jne 0x3f86a
cmpq $0x0, 0x58(%r12)
je 0x3f871
movq 0x2a0(%rbx), %r12
leaq 0x10(%rbx), %rdi
leaq 0x50(%rsp), %rbp
leaq 0x38(%rsp), %rdx
leaq 0x2c(%rsp), %rcx
movq %rbp, %rsi
callq 0x183a0
leaq 0xc(%rsp), %r14
movq %r13, %rdi
movss 0x4(%rsp), %xmm0
movq %rbp, %rsi
movq %r14, %rdx
callq 0x19770
movss 0x4(%r15), %xmm0
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
movq %r14, %rdx
callq 0x19770
movss 0x8(%r15), %xmm0
movq %r14, %rdi
leaq 0x2c(%rsp), %rsi
movq %r14, %rdx
callq 0x19770
movq 0x2a0(%rbx), %rax
movss (%r14), %xmm0
movss 0x4(%r14), %xmm1
subss 0x4(%rax), %xmm0
leaq 0x20(%rsp), %rcx
movss %xmm0, (%rcx)
subss 0x8(%rax), %xmm1
movss %xmm1, 0x4(%rcx)
movss 0x8(%r14), %xmm0
subss 0xc(%rax), %xmm0
movss %xmm0, 0x8(%rcx)
movl 0x8(%rsp), %ebp
movl %ebp, %eax
shrl $0x1f, %eax
addl %ebp, %eax
sarl %eax
movq 0x29e49(%rip), %r9      # 0x69768
movq %r12, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
movq %r14, %r8
pushq $0x20
pushq $0x8
pushq %rax
pushq 0x30(%rsp)
callq 0x190f0
addq $0x20, %rsp
testb $0x4, 0xc8(%r12)
jne 0x3f954
cmpq $0x0, 0x58(%r12)
je 0x3f783
movq 0x2a0(%rbx), %rsi
leaq 0xe4(%rsi), %rdi
addq $0xfc, %rsi
movss 0x15a93(%rip), %xmm0    # 0x55404
leaq 0x44(%rsp), %r14
movq %r14, %rdx
callq 0x19770
movss (%r14), %xmm0
movss 0x4(%r14), %xmm1
subss 0xc(%rsp), %xmm0
movss %xmm0, (%r14)
subss 0x10(%rsp), %xmm1
movss %xmm1, 0x4(%r14)
movss 0x8(%r14), %xmm0
subss 0x14(%rsp), %xmm0
movss %xmm0, 0x8(%r14)
movq %r14, %rdi
callq 0x18390
movl $0x1c0, %edi            # imm = 0x1C0
addq 0x2a0(%rbx), %rdi
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movq %r14, %rsi
movq %rdi, %rdx
callq 0x19770
movq 0x2a0(%rbx), %rax
movss 0x1c8(%rax), %xmm0
movl $0x1, %r14d
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3fa00
movq $0x0, 0x2b8(%rax)
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq