// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, (%rsp)
movq %rsi, 0x10(%rsp)
testq %rdi, %rdi
je 0x4a4e2
movq %rdi, %r15
movss 0x5f8b(%rip), %xmm0     # 0x50404
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x196c0
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x48(%rsp)
movss 0x4fab(%rip), %xmm0     # 0x4f44c
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x196c0
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x38(%rsp)
movq 0x1c8d8(%rip), %rax     # 0x66da0
movl (%rax), %eax
pushq $0x3
popq %rcx
cltd
idivl %ecx
movq 0x58(%r15), %rax
movl 0xf5c(%rax), %ecx
testl %edx, %edx
je 0x4a4f4
testl %ecx, %ecx
je 0x4a517
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58(%r15), %rdx
movq %rdx, 0x8(%rsp)
cmpl $0x27f, %ecx            # imm = 0x27F
jg 0x4a52f
addq $0xf5c, %rax            # imm = 0xF5C
cmpl $0x5f, %ecx
jle 0x4a526
addl $0x20, %ecx
movl %ecx, (%rax)
jmp 0x4a52f
leaq 0x58(%r15), %rcx
movq %rcx, 0x8(%rsp)
addq $0xf5c, %rax            # imm = 0xF5C
movl $0x60, (%rax)
pushq $0x60
popq %rcx
pushq $0x60
popq %r14
cvtsi2ss %ecx, %xmm0
leaq 0x4c(%rsp), %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x19940
movsd (%rbx), %xmm0
leaq 0x18(%rsp), %rax
movsd %xmm0, (%rax)
leaq 0x8(%rbx), %rcx
movq 0x1c09b(%rip), %r13     # 0x66600
leaq 0xa0(%rsp), %r12
leaq 0x58(%rsp), %rbp
movq %r15, %rax
movss (%rcx), %xmm0
movss %xmm0, 0x20(%rsp)
testq %rax, %rax
je 0x4a62e
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x48(%rsp), %rdx
leaq 0x38(%rsp), %rcx
leaq 0x54(%rsp), %r8
movq %r15, %r9
pushq $0x6000003              # imm = 0x6000003
callq *0x60(%r13)
addq $0x10, %rsp
pushq $0x9
popq %rcx
movq %rbp, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x98(%rsp), %rbx
testb $0x4, 0xc8(%rbx)
jne 0x4a5d7
cmpq $0x0, 0x58(%rbx)
je 0x4a616
movq %r15, %rax
cmpq %r15, %rbx
je 0x4a618
cmpl $0x0, 0x27c(%rbx)
je 0x4a611
movq %rbx, %rdi
movq %r15, %rsi
movq %r15, %rdx
movq (%rsp), %rcx
leaq 0x64(%rsp), %r8
leaq 0x70(%rsp), %r9
pushq $0x2
popq %rax
pushq %rax
pushq $0x0
pushq $0x5
pushq %rax
callq 0x19260
addq $0x20, %rsp
movq %rbx, %rax
jmp 0x4a618
xorl %eax, %eax
movsd 0x64(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x6c(%rsp), %rcx
jmp 0x4a575
leaq 0x4(%r15), %rax
movq %rax, 0x28(%rsp)
leaq 0xa0(%rsp), %rbp
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rax
movq (%rax), %rax
cmpl 0xf5c(%rax), %r14d
jge 0x4a4e2
cvtsi2ss %r14d, %xmm0
movq %rbx, %rdi
movq (%rsp), %rsi
leaq 0x4c(%rsp), %r12
movq %r12, %rdx
callq 0x19940
subq $0x8, %rsp
movq %rbp, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
movq %r15, %r9
pushq $0x6000003              # imm = 0x6000003
callq *0x60(%r13)
addq $0x10, %rsp
pushq $0x9
popq %rcx
leaq 0x58(%rsp), %rdi
movq %rbp, %rsi
rep  movsq (%rsi), %es:(%rdi)
pushq $0x3
popq %rdi
callq *0xc8(%r13)
pushq $0x7
popq %rdi
callq *0xc8(%r13)
leaq 0x64(%rsp), %rdi
callq *0xf0(%r13)
movq 0x28(%rsp), %rdi
pushq $0x1
popq %rsi
callq *0xb0(%r13)
addl $0x20, %r14d
jmp 0x4a644