// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/p_weapon.c
// Function: fire_fieldgun
void fire_fieldgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count)
{
	int		i;
	trace_t	tr;
	vec3_t	end, from;
	vec3_t	mins, maxs;
	float		*v;
	edict_t	*target;

	if (!self)
		return;
	
	v = tv(-32, -32, -32);
	VectorCopy (v, mins);
	v = tv(32,32,32);
	VectorCopy (v, maxs);

	if ((level.framenum % 3) && self->client->hooklength)
	{
		return;
	}

	//for (i = 0; i < count; i++)
	//	fire_lead (self, start, aimdir, damage, kick, TE_SHOTGUN, hspread, vspread);

	//fire_shotgun (self, start, aimdir, damage, kick, hspread, vspread, count);
	// send gun puff / flash
	if (self->client->hooklength < 640)
	{
		if (self->client->hooklength < 96)
			self->client->hooklength = 96;
		else
			self->client->hooklength += 32;
	}

	VectorMA (start, self->client->hooklength, aimdir, end);
	VectorCopy (start, from);

	target = self;
	while (target)
	{
		tr = gi.trace (from, mins, maxs, end, self, MASK_SHOT);

		if ((tr.ent->svflags & SVF_MONSTER) || (tr.ent->client))
			target = tr.ent;
		else
			target = NULL;

		if (target && (target != self) && (target->takedamage))
			T_Damage (target, self, self, aimdir, tr.endpos, tr.plane.normal, 2, 5, 0, MOD_SHOTGUN);

		VectorCopy (tr.endpos, from);
	}

	for (i=96; i < self->client->hooklength; i+=32)
	{
		VectorMA (start, i, aimdir, end);
		
		tr = gi.trace (start, NULL, NULL, end, self, MASK_SHOT);
		//T_RadiusDamage(self, self, 10, self, 32);

		gi.WriteByte (svc_temp_entity);
		gi.WriteByte (TE_ROCKET_EXPLOSION);
		gi.WritePosition (tr.endpos);
		gi.multicast (self->s.origin, MULTICAST_PHS);
	}
}

// Assembly:
testq %rdi, %rdi
je 0x4f6dd
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %r15
movss 0x5fbd(%rip), %xmm0     # 0x55408
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movq %rdx, (%rsp)
movq %rsi, %r14
callq 0x19510
movss (%rax), %xmm0
movss %xmm0, 0x18(%rsp)
movss 0x4(%rax), %xmm0
movss %xmm0, 0x1c(%rsp)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x20(%rsp)
movss 0x4fb7(%rip), %xmm0     # 0x5443c
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x19510
movq %r14, %rdi
movq (%rsp), %rsi
movss (%rax), %xmm0
movss %xmm0, 0xc(%rsp)
movss 0x4(%rax), %xmm0
movss %xmm0, 0x10(%rsp)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x14(%rsp)
movq 0x1a8e2(%rip), %rax     # 0x69da0
imull $0xaaaaaaab, (%rax), %eax # imm = 0xAAAAAAAB
addl $0x2aaaaaaa, %eax       # imm = 0x2AAAAAAA
cmpl $0x55555555, %eax       # imm = 0x55555555
jb 0x4f4e1
movq 0x58(%r15), %rax
cmpl $0x0, 0xf5c(%rax)
jne 0x4f6cc
movq 0x58(%r15), %rax
movl 0xf5c(%rax), %ecx
cmpl $0x27f, %ecx            # imm = 0x27F
jg 0x4f507
leal 0x20(%rcx), %edx
cmpl $0x60, %ecx
movl $0x60, %ecx
cmovgel %edx, %ecx
movl %ecx, 0xf5c(%rax)
xorps %xmm0, %xmm0
cvtsi2ssl 0xf5c(%rax), %xmm0
leaq 0x3c(%rsp), %rdx
callq 0x19770
movss (%r14), %xmm0
leaq 0x24(%rsp), %rcx
movss %xmm0, (%rcx)
movss 0x4(%r14), %xmm0
movss %xmm0, 0x4(%rcx)
movss 0x8(%r14), %xmm0
movss %xmm0, 0x8(%rcx)
movq 0x1a0b9(%rip), %rbx     # 0x69600
leaq 0x90(%rsp), %rbp
leaq 0x48(%rsp), %r12
subq $0x8, %rsp
movq %rbp, %rdi
leaq 0x2c(%rsp), %rsi
leaq 0x20(%rsp), %rdx
leaq 0x14(%rsp), %rcx
leaq 0x44(%rsp), %r8
movq %r15, %r9
pushq $0x6000003              # imm = 0x6000003
callq *0x60(%rbx)
addq $0x10, %rsp
movl $0x9, %ecx
movq %r12, %rdi
movq %rbp, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x88(%rsp), %r13
testb $0x4, 0xc8(%r13)
jne 0x4f5a8
cmpq $0x0, 0x58(%r13)
jne 0x4f5a8
xorl %r13d, %r13d
testq %r13, %r13
sete %al
cmpq %r15, %r13
sete %cl
orb %al, %cl
movq %r14, %rdi
jne 0x4f5f3
cmpl $0x0, 0x27c(%r13)
je 0x4f5f3
movq %r13, %rdi
movq %r15, %rsi
movq %r15, %rdx
movq (%rsp), %rcx
leaq 0x54(%rsp), %r8
leaq 0x60(%rsp), %r9
movl $0x2, %eax
pushq %rax
pushq $0x0
pushq $0x5
pushq %rax
callq 0x190f0
movq %r14, %rdi
addq $0x20, %rsp
movss 0x54(%rsp), %xmm0
movss %xmm0, 0x24(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x28(%rsp)
testq %r13, %r13
jne 0x4f554
movq 0x58(%r15), %rax
cmpl $0x61, 0xf5c(%rax)
movq (%rsp), %rsi
jl 0x4f6cc
leaq 0x4(%r15), %rax
movq %rax, 0x30(%rsp)
movl $0x60, %ebp
leaq 0x3c(%rsp), %r12
leaq 0x90(%rsp), %r13
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movq %r12, %rdx
callq 0x19770
subq $0x8, %rsp
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
movq %r15, %r9
pushq $0x6000003              # imm = 0x6000003
callq *0x60(%rbx)
addq $0x10, %rsp
movl $0x9, %ecx
leaq 0x48(%rsp), %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x3, %edi
callq *0xc8(%rbx)
movl $0x7, %edi
callq *0xc8(%rbx)
leaq 0x54(%rsp), %rdi
callq *0xf0(%rbx)
movq 0x30(%rsp), %rdi
movl $0x1, %esi
callq *0xb0(%rbx)
movq %r14, %rdi
movq (%rsp), %rsi
addl $0x20, %ebp
movq 0x58(%r15), %rax
cmpl 0xf5c(%rax), %ebp
jl 0x4f642
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq