// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_weapon.c
// Function: fire_lead
static void fire_lead (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int te_impact, int hspread, int vspread, int mod)
{
	trace_t		tr;
	vec3_t		dir;
	vec3_t		forward, right, up;
	vec3_t		end;
	float		r;
	float		u;
	vec3_t		water_start;
	qboolean	water = false;
	int			content_mask = MASK_SHOT | MASK_WATER;

	tr = gi.trace (self->s.origin, NULL, NULL, start, self, MASK_SHOT);
	if (!(tr.fraction < 1.0))
	{
		vectoangles (aimdir, dir);
		AngleVectors (dir, forward, right, up);

		r = crandom()*hspread;
		u = crandom()*vspread;
		VectorMA (start, 8192, forward, end);
		VectorMA (end, r, right, end);
		VectorMA (end, u, up, end);

		if (gi.pointcontents (start) & MASK_WATER)
		{
			water = true;
			VectorCopy (start, water_start);
			content_mask &= ~MASK_WATER;
		}

		tr = gi.trace (start, NULL, NULL, end, self, content_mask);

		// see if we hit water
		if (tr.contents & MASK_WATER)
		{
			int		color;

			water = true;
			VectorCopy (tr.endpos, water_start);

			if (!VectorCompare (start, tr.endpos))
			{
				if (tr.contents & CONTENTS_WATER)
				{
					if (strcmp(tr.surface->name, "*brwater") == 0)
						color = SPLASH_BROWN_WATER;
					else
						color = SPLASH_BLUE_WATER;
				}
				else if (tr.contents & CONTENTS_SLIME)
					color = SPLASH_SLIME;
				else if (tr.contents & CONTENTS_LAVA)
					color = SPLASH_LAVA;
				else
					color = SPLASH_UNKNOWN;

				if (color != SPLASH_UNKNOWN)
				{
					gi.WriteByte (svc_temp_entity);
					gi.WriteByte (TE_SPLASH);
					gi.WriteByte (8);
					gi.WritePosition (tr.endpos);
					gi.WriteDir (tr.plane.normal);
					gi.WriteByte (color);
					gi.multicast (tr.endpos, MULTICAST_PVS);
				}

				// change bullet's course when it enters water
				VectorSubtract (end, start, dir);
				vectoangles (dir, dir);
				AngleVectors (dir, forward, right, up);
				r = crandom()*hspread*2;
				u = crandom()*vspread*2;
				VectorMA (water_start, 8192, forward, end);
				VectorMA (end, r, right, end);
				VectorMA (end, u, up, end);
			}

			// re-trace ignoring water this time
			tr = gi.trace (water_start, NULL, NULL, end, self, MASK_SHOT);
		}
	}

	// send gun puff / flash
	if (!((tr.surface) && (tr.surface->flags & SURF_SKY)))
	{
		if (tr.fraction < 1.0)
		{
			if (tr.ent->takedamage)
			{
				T_Damage (tr.ent, self, self, aimdir, tr.endpos, tr.plane.normal, damage, kick, DAMAGE_BULLET, mod);
			}
			else
			{
				if (strncmp (tr.surface->name, "sky", 3) != 0)
				{
					gi.WriteByte (svc_temp_entity);
					gi.WriteByte (te_impact);
					gi.WritePosition (tr.endpos);
					gi.WriteDir (tr.plane.normal);
					gi.multicast (tr.endpos, MULTICAST_PVS);

					if (self->client)
						PlayerNoise(self, tr.endpos, PNOISE_IMPACT);
				}
			}
		}
	}

	// if went through water, determine where the end and make a bubble trail
	if (water)
	{
		vec3_t	pos;

		VectorSubtract (tr.endpos, water_start, dir);
		VectorNormalize (dir);
		VectorMA (tr.endpos, -2, dir, pos);
		if (gi.pointcontents (pos) & MASK_WATER)
			VectorCopy (pos, tr.endpos);
		else
			tr = gi.trace (pos, NULL, NULL, water_start, tr.ent, MASK_WATER);

		VectorAdd (water_start, tr.endpos, pos);
		VectorScale (pos, 0.5, pos);

		gi.WriteByte (svc_temp_entity);
		gi.WriteByte (TE_BUBBLETRAIL);
		gi.WritePosition (water_start);
		gi.WritePosition (tr.endpos);
		gi.multicast (pos, MULTICAST_PVS);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movl $0x0, -0xc4(%rbp)
movl $0x600003b, -0xc8(%rbp) # imm = 0x600003B
movq 0x30baa(%rip), %rax     # 0x82600
movq 0x60(%rax), %rax
movq -0x8(%rbp), %rsi
addq $0x4, %rsi
movq -0x10(%rbp), %r8
movq -0x8(%rbp), %r9
leaq -0x110(%rbp), %rdi
xorl %ecx, %ecx
movq %rcx, %rdx
movl $0x6000003, (%rsp)      # imm = 0x6000003
callq *%rax
leaq -0x70(%rbp), %rdi
leaq -0x110(%rbp), %rsi
movl $0x48, %edx
callq 0x18dc0
movss -0x68(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x1e49b(%rip), %xmm0    # 0x6ff40
ucomisd %xmm1, %xmm0
ja 0x51fbc
movq -0x18(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
callq 0x192a0
leaq -0x7c(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x94(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
callq 0x183e0
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x1e798(%rip), %xmm1    # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x1f928(%rip), %xmm0    # 0x71428
subsd %xmm0, %xmm1
movsd 0x2108c(%rip), %xmm0    # 0x72b98
mulsd %xmm1, %xmm0
cvtsi2sdl 0x10(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xb0(%rbp)
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x1e74d(%rip), %xmm1    # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x1f8dd(%rip), %xmm0    # 0x71428
subsd %xmm0, %xmm1
movsd 0x21041(%rip), %xmm0    # 0x72b98
mulsd %xmm1, %xmm0
cvtsi2sdl 0x18(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xb4(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0xac(%rbp), %rdx
movss 0x246ba(%rip), %xmm0    # 0x76244
callq 0x199c0
leaq -0xac(%rbp), %rdi
movss -0xb0(%rbp), %xmm0
leaq -0x94(%rbp), %rsi
leaq -0xac(%rbp), %rdx
callq 0x199c0
leaq -0xac(%rbp), %rdi
movss -0xb4(%rbp), %xmm0
leaq -0xa0(%rbp), %rsi
leaq -0xac(%rbp), %rdx
callq 0x199c0
movq 0x30a26(%rip), %rax     # 0x82600
movq 0x68(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
andl $0x38, %eax
cmpl $0x0, %eax
je 0x51c37
movl $0x1, -0xc4(%rbp)
movq -0x10(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm0
movss %xmm0, -0xbc(%rbp)
movq -0x10(%rbp), %rax
movss 0x8(%rax), %xmm0
movss %xmm0, -0xb8(%rbp)
movl -0xc8(%rbp), %eax
andl $-0x39, %eax
movl %eax, -0xc8(%rbp)
movq 0x309c2(%rip), %rax     # 0x82600
movq 0x60(%rax), %rax
movq -0x10(%rbp), %rsi
leaq -0xac(%rbp), %r8
movq -0x8(%rbp), %r9
movl -0xc8(%rbp), %r10d
leaq -0x158(%rbp), %rdi
xorl %ecx, %ecx
movq %rcx, %rdx
movl %r10d, (%rsp)
callq *%rax
leaq -0x70(%rbp), %rdi
leaq -0x158(%rbp), %rsi
movl $0x48, %edx
callq 0x18dc0
movl -0x38(%rbp), %eax
andl $0x38, %eax
cmpl $0x0, %eax
je 0x51fba
movl $0x1, -0xc4(%rbp)
movss -0x64(%rbp), %xmm0
movss %xmm0, -0xc0(%rbp)
movss -0x60(%rbp), %xmm0
movss %xmm0, -0xbc(%rbp)
movss -0x5c(%rbp), %xmm0
movss %xmm0, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x70(%rbp), %rsi
addq $0xc, %rsi
callq 0x18c60
cmpl $0x0, %eax
jne 0x51f73
movl -0x38(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x51d11
movq -0x40(%rbp), %rdi
leaq 0x24680(%rip), %rsi     # 0x7636f
callq 0x18bf0
cmpl $0x0, %eax
jne 0x51d05
movl $0x3, -0x15c(%rbp)
jmp 0x51d0f
movl $0x2, -0x15c(%rbp)
jmp 0x51d4d
movl -0x38(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x51d28
movl $0x4, -0x15c(%rbp)
jmp 0x51d4b
movl -0x38(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x51d3f
movl $0x5, -0x15c(%rbp)
jmp 0x51d49
movl $0x0, -0x15c(%rbp)
jmp 0x51d4b
jmp 0x51d4d
cmpl $0x0, -0x15c(%rbp)
je 0x51df3
movl $0x3, %edi
movq 0x3089a(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movl $0xa, %edi
movq 0x30888(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movl $0x8, %edi
movq 0x30876(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x30869(%rip), %rax     # 0x82600
movq 0xf0(%rax), %rax
leaq -0x70(%rbp), %rdi
addq $0xc, %rdi
callq *%rax
movq 0x30851(%rip), %rax     # 0x82600
movq 0xf8(%rax), %rax
leaq -0x70(%rbp), %rdi
addq $0x18, %rdi
callq *%rax
movq 0x30839(%rip), %rax     # 0x82600
movq 0xc8(%rax), %rax
movl -0x15c(%rbp), %edi
callq *%rax
movq 0x30823(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
leaq -0x70(%rbp), %rdi
addq $0xc, %rdi
movl $0x2, %esi
callq *%rax
movss -0xac(%rbp), %xmm0
movq -0x10(%rbp), %rax
subss (%rax), %xmm0
movss %xmm0, -0x7c(%rbp)
movss -0xa8(%rbp), %xmm0
movq -0x10(%rbp), %rax
subss 0x4(%rax), %xmm0
movss %xmm0, -0x78(%rbp)
movss -0xa4(%rbp), %xmm0
movq -0x10(%rbp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, -0x74(%rbp)
leaq -0x7c(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
callq 0x192a0
leaq -0x7c(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x94(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
callq 0x183e0
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x1e413(%rip), %xmm1    # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x1f5a3(%rip), %xmm0    # 0x71428
subsd %xmm0, %xmm1
movsd 0x20d07(%rip), %xmm0    # 0x72b98
mulsd %xmm1, %xmm0
cvtsi2sdl 0x10(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x20cf2(%rip), %xmm1    # 0x72b98
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xb0(%rbp)
callq 0x19c80
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x1e3bc(%rip), %xmm1    # 0x70288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x1f54c(%rip), %xmm0    # 0x71428
subsd %xmm0, %xmm1
movsd 0x20cb0(%rip), %xmm0    # 0x72b98
mulsd %xmm1, %xmm0
cvtsi2sdl 0x18(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x20c9b(%rip), %xmm1    # 0x72b98
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xb4(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0xac(%rbp), %rdx
movss 0x2431a(%rip), %xmm0    # 0x76244
callq 0x199c0
leaq -0xac(%rbp), %rdi
movss -0xb0(%rbp), %xmm0
leaq -0x94(%rbp), %rsi
leaq -0xac(%rbp), %rdx
callq 0x199c0
leaq -0xac(%rbp), %rdi
movss -0xb4(%rbp), %xmm0
leaq -0xa0(%rbp), %rsi
leaq -0xac(%rbp), %rdx
callq 0x199c0
movq 0x30686(%rip), %rax     # 0x82600
movq 0x60(%rax), %rax
leaq -0xc0(%rbp), %rsi
leaq -0xac(%rbp), %r8
movq -0x8(%rbp), %r9
leaq -0x1a8(%rbp), %rdi
xorl %ecx, %ecx
movq %rcx, %rdx
movl $0x6000003, (%rsp)      # imm = 0x6000003
callq *%rax
leaq -0x70(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
movl $0x48, %edx
callq 0x18dc0
jmp 0x51fbc
cmpq $0x0, -0x40(%rbp)
je 0x51fd6
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x52101
movss -0x68(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x1df59(%rip), %xmm0    # 0x6ff40
ucomisd %xmm1, %xmm0
jbe 0x520ff
movq -0x30(%rbp), %rax
cmpl $0x0, 0x27c(%rax)
je 0x52048
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x8(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq -0x70(%rbp), %r8
addq $0xc, %r8
leaq -0x70(%rbp), %r9
addq $0x18, %r9
movl -0x1c(%rbp), %r11d
movl -0x20(%rbp), %r10d
movl 0x20(%rbp), %eax
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl $0x10, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x192c0
jmp 0x520fd
movq -0x40(%rbp), %rdi
leaq 0x22989(%rip), %rsi     # 0x749dc
movl $0x3, %edx
callq 0x18200
cmpl $0x0, %eax
je 0x520fb
movl $0x3, %edi
movq 0x3058e(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x30581(%rip), %rax     # 0x82600
movq 0xc8(%rax), %rax
movl -0x24(%rbp), %edi
callq *%rax
movq 0x3056e(%rip), %rax     # 0x82600
movq 0xf0(%rax), %rax
leaq -0x70(%rbp), %rdi
addq $0xc, %rdi
callq *%rax
movq 0x30556(%rip), %rax     # 0x82600
movq 0xf8(%rax), %rax
leaq -0x70(%rbp), %rdi
addq $0x18, %rdi
callq *%rax
movq 0x3053e(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
leaq -0x70(%rbp), %rdi
addq $0xc, %rdi
movl $0x2, %esi
callq *%rax
movq -0x8(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x520f9
movq -0x8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
addq $0xc, %rsi
movl $0x2, %edx
callq 0x19080
jmp 0x520fb
jmp 0x520fd
jmp 0x520ff
jmp 0x52101
cmpl $0x0, -0xc4(%rbp)
je 0x522c2
movss -0x64(%rbp), %xmm0
subss -0xc0(%rbp), %xmm0
movss %xmm0, -0x7c(%rbp)
movss -0x60(%rbp), %xmm0
subss -0xbc(%rbp), %xmm0
movss %xmm0, -0x78(%rbp)
movss -0x5c(%rbp), %xmm0
subss -0xb8(%rbp), %xmm0
movss %xmm0, -0x74(%rbp)
leaq -0x7c(%rbp), %rdi
callq 0x183d0
leaq -0x70(%rbp), %rdi
addq $0xc, %rdi
leaq -0x7c(%rbp), %rsi
leaq -0x1b4(%rbp), %rdx
movss 0x1f2ac(%rip), %xmm0    # 0x71414
callq 0x199c0
movq 0x3048c(%rip), %rax     # 0x82600
movq 0x68(%rax), %rax
leaq -0x1b4(%rbp), %rdi
callq *%rax
andl $0x38, %eax
cmpl $0x0, %eax
je 0x521b2
movss -0x1b4(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x1b0(%rbp), %xmm0
movss %xmm0, -0x60(%rbp)
movss -0x1ac(%rbp), %xmm0
movss %xmm0, -0x5c(%rbp)
jmp 0x521f9
movq 0x30447(%rip), %rax     # 0x82600
movq 0x60(%rax), %rax
leaq -0x1b4(%rbp), %rsi
leaq -0xc0(%rbp), %r8
movq -0x30(%rbp), %r9
leaq -0x200(%rbp), %rdi
xorl %ecx, %ecx
movq %rcx, %rdx
movl $0x38, (%rsp)
callq *%rax
leaq -0x70(%rbp), %rdi
leaq -0x200(%rbp), %rsi
movl $0x48, %edx
callq 0x18dc0
movss -0xc0(%rbp), %xmm0
addss -0x64(%rbp), %xmm0
movss %xmm0, -0x1b4(%rbp)
movss -0xbc(%rbp), %xmm0
addss -0x60(%rbp), %xmm0
movss %xmm0, -0x1b0(%rbp)
movss -0xb8(%rbp), %xmm0
addss -0x5c(%rbp), %xmm0
movss %xmm0, -0x1ac(%rbp)
leaq -0x1b4(%rbp), %rdi
leaq -0x1b4(%rbp), %rsi
movss 0x20902(%rip), %xmm0    # 0x72b50
callq 0x18a80
movl $0x3, %edi
movq 0x303a1(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movl $0xb, %edi
movq 0x3038f(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x30382(%rip), %rax     # 0x82600
movq 0xf0(%rax), %rax
leaq -0xc0(%rbp), %rdi
callq *%rax
movq 0x3036b(%rip), %rax     # 0x82600
movq 0xf0(%rax), %rax
leaq -0x70(%rbp), %rdi
addq $0xc, %rdi
callq *%rax
movq 0x30353(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
leaq -0x1b4(%rbp), %rdi
movl $0x2, %esi
callq *%rax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nopl (%rax,%rax)