// File: /workspace/github_c_makefile_star2_O3/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 0x4e9e2
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %r15
movq %rsi, 0x10(%rsp)
movq %rdx, (%rsp)
movss 0x5cd3(%rip), %xmm0     # 0x54404
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x19510
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x48(%rsp)
movss 0x4cf3(%rip), %xmm0     # 0x5344c
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x19510
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x38(%rsp)
movq 0x1a620(%rip), %rax     # 0x68da0
imull $0xaaaaaaab, (%rax), %edx # imm = 0xAAAAAAAB
addl $0x2aaaaaaa, %edx       # imm = 0x2AAAAAAA
movq 0x58(%r15), %rax
movl 0xf5c(%rax), %ecx
cmpl $0x55555555, %edx       # imm = 0x55555555
jb 0x4e7c0
testl %ecx, %ecx
movq (%rsp), %rsi
movq 0x10(%rsp), %rbx
jne 0x4e9d1
leaq 0x58(%r15), %rcx
movq %rcx, 0x8(%rsp)
addq $0xf5c, %rax            # imm = 0xF5C
jmp 0x4e7e5
leaq 0x58(%r15), %rdx
cmpl $0x27f, %ecx            # imm = 0x27F
movq %rdx, 0x8(%rsp)
jg 0x4e7f2
addq $0xf5c, %rax            # imm = 0xF5C
cmpl $0x5f, %ecx
movq (%rsp), %rsi
movq 0x10(%rsp), %rbx
jg 0x4e7fd
movl $0x60, (%rax)
movl $0x60, %ecx
jmp 0x4e802
movq (%rsp), %rsi
movq 0x10(%rsp), %rbx
jmp 0x4e802
addl $0x20, %ecx
movl %ecx, (%rax)
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
leaq 0x4c(%rsp), %rdx
movq %rbx, %rdi
callq 0x19760
movsd (%rbx), %xmm0
leaq 0x18(%rsp), %rax
movsd %xmm0, (%rax)
movss 0x8(%rbx), %xmm0
movss %xmm0, 0x8(%rax)
movq 0x19dcc(%rip), %r13     # 0x68600
leaq 0xa0(%rsp), %r12
leaq 0x30(%rsp), %r14
leaq 0x58(%rsp), %rbx
subq $0x8, %rsp
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x48(%rsp), %rdx
movq %r14, %rcx
leaq 0x54(%rsp), %r8
movq %r15, %r9
pushq $0x6000003              # imm = 0x6000003
callq *0x60(%r13)
addq $0x10, %rsp
movl $0x9, %ecx
movq %rbx, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x98(%rsp), %rbp
testb $0x4, 0xc8(%rbp)
jne 0x4e895
cmpq $0x0, 0x58(%rbp)
je 0x4e8d6
movq %r15, %rax
cmpq %r15, %rbp
je 0x4e8d8
cmpl $0x0, 0x27c(%rbp)
je 0x4e8d1
movq %rbp, %rdi
movq %r15, %rsi
movq %r15, %rdx
movq (%rsp), %rcx
leaq 0x64(%rsp), %r8
leaq 0x70(%rsp), %r9
movl $0x2, %eax
pushq %rax
pushq $0x0
pushq $0x5
pushq %rax
callq 0x190f0
addq $0x20, %rsp
movq %rbp, %rax
jmp 0x4e8d8
xorl %eax, %eax
movsd 0x64(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movss 0x6c(%rsp), %xmm0
movss %xmm0, 0x20(%rsp)
testq %rax, %rax
jne 0x4e846
movq 0x8(%rsp), %rax
movq (%rax), %rax
cmpl $0x61, 0xf5c(%rax)
movq (%rsp), %r14
movq %r15, 0x8(%rsp)
movq 0x10(%rsp), %r15
jl 0x4e9d1
movq 0x8(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x28(%rsp)
movl $0x60, %ebp
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movq %r15, %rdi
movq %r14, %rsi
leaq 0x4c(%rsp), %r12
movq %r12, %rdx
callq 0x19760
subq $0x8, %rsp
movq %r13, %rbx
leaq 0xa8(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
movq 0x10(%rsp), %r12
movq %r12, %r9
pushq $0x6000003              # imm = 0x6000003
callq *0x60(%rbx)
addq $0x10, %rsp
movl $0x9, %ecx
leaq 0x58(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %r13
rep  movsq (%rsi), %es:(%rdi)
movl $0x3, %edi
callq *0xc8(%rbx)
movl $0x7, %edi
callq *0xc8(%rbx)
leaq 0x64(%rsp), %rdi
callq *0xf0(%rbx)
movq 0x28(%rsp), %rdi
movl $0x1, %esi
callq *0xb0(%rbx)
addl $0x20, %ebp
movq 0x58(%r12), %rax
cmpl 0xf5c(%rax), %ebp
jl 0x4e92f
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq