// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_weapon.c
// Function: fire_rail
void fire_rail (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick)
{
	vec3_t		from;
	vec3_t		end;
	trace_t		tr;
	edict_t		*ignore;
	int			mask;
	qboolean	water;

	if (!self)	// self must not be null
		return;

#ifdef WEAP_BALANCE_OK
	if ((int)ctfflags->value & CTF_WEAP_BALANCE)
	{
		fire_lead (self, start, aimdir, 4, 0, TE_GUNSHOT, 512, 512, MOD_RAILGUN);
		fire_lead (self, start, aimdir, 4, 0, TE_GUNSHOT, 512, -512, MOD_RAILGUN);
		fire_lead (self, start, aimdir, 4, 0, TE_GUNSHOT, -512, 512, MOD_RAILGUN);
		fire_lead (self, start, aimdir, 4, 0, TE_GUNSHOT, -512, -512, MOD_RAILGUN);
	}
#endif


	VectorMA (start, 8192, aimdir, end);
	VectorCopy (start, from);
	ignore = self;
	water = false;
	mask = MASK_SHOT|CONTENTS_SLIME|CONTENTS_LAVA;
	while (ignore)
	{
		tr = gi.trace (from, NULL, NULL, end, ignore, mask);

		if (tr.contents & (CONTENTS_SLIME|CONTENTS_LAVA))
		{
			mask &= ~(CONTENTS_SLIME|CONTENTS_LAVA);
			water = true;
		}
		else
		{
			//ZOID--added so rail goes through SOLID_BBOX entities (gibs, etc)
			if ((tr.ent->svflags & SVF_MONSTER) || (tr.ent->client) ||
				(tr.ent->solid == SOLID_BBOX))
				ignore = tr.ent;
			else
				ignore = NULL;

			if ((tr.ent != self) && (tr.ent->takedamage))
				T_Damage (tr.ent, self, self, aimdir, tr.endpos, tr.plane.normal, damage, kick, 0, MOD_RAILGUN);
		}

		VectorCopy (tr.endpos, from);
	}

	// send gun puff / flash
	gi.WriteByte (svc_temp_entity);
	gi.WriteByte (TE_RAILTRAIL);
	gi.WritePosition (start);
	gi.WritePosition (tr.endpos);
	gi.multicast (self->s.origin, MULTICAST_PHS);
//	gi.multicast (start, MULTICAST_PHS);
	if (water)
	{
		gi.WriteByte (svc_temp_entity);
		gi.WriteByte (TE_RAILTRAIL);
		gi.WritePosition (start);
		gi.WritePosition (tr.endpos);
		gi.multicast (tr.endpos, MULTICAST_PHS);
	}

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x5399a
jmp 0x53c43
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdx
movss 0x22896(%rip), %xmm0    # 0x76244
callq 0x199c0
movq -0x10(%rbp), %rax
movss (%rax), %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm0
movss %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movss 0x8(%rax), %xmm0
movss %xmm0, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x90(%rbp)
movl $0x600001b, -0x8c(%rbp) # imm = 0x600001B
cmpq $0x0, -0x88(%rbp)
je 0x53b3f
movq 0x2ebf0(%rip), %rax     # 0x82600
movq 0x60(%rax), %rax
leaq -0x2c(%rbp), %rsi
leaq -0x38(%rbp), %r8
movq -0x88(%rbp), %r9
movl -0x8c(%rbp), %r10d
leaq -0xd8(%rbp), %rdi
xorl %ecx, %ecx
movq %rcx, %rdx
movl %r10d, (%rsp)
callq *%rax
leaq -0x80(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
movl $0x48, %edx
callq 0x18dc0
movl -0x48(%rbp), %eax
andl $0x18, %eax
cmpl $0x0, %eax
je 0x53a7a
movl -0x8c(%rbp), %eax
andl $-0x19, %eax
movl %eax, -0x8c(%rbp)
movl $0x1, -0x90(%rbp)
jmp 0x53b1c
movq -0x40(%rbp), %rax
movl 0xc8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x53aa4
movq -0x40(%rbp), %rax
cmpq $0x0, 0x58(%rax)
jne 0x53aa4
movq -0x40(%rbp), %rax
cmpl $0x2, 0x108(%rax)
jne 0x53ab1
movq -0x40(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x53abc
movq $0x0, -0x88(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x8(%rbp), %rax
je 0x53b1a
movq -0x40(%rbp), %rax
cmpl $0x0, 0x27c(%rax)
je 0x53b1a
movq -0x40(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x8(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq -0x80(%rbp), %r8
addq $0xc, %r8
leaq -0x80(%rbp), %r9
addq $0x18, %r9
movl -0x1c(%rbp), %r10d
movl -0x20(%rbp), %eax
xorl %r11d, %r11d
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
movl $0xb, 0x18(%rsp)
callq 0x192c0
jmp 0x53b1c
movss -0x74(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x70(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
movss -0x6c(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
jmp 0x539fb
movl $0x3, %edi
movq 0x2eab5(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movl $0x3, %edi
movq 0x2eaa3(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x2ea96(%rip), %rax     # 0x82600
movq 0xf0(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq 0x2ea82(%rip), %rax     # 0x82600
movq 0xf0(%rax), %rax
leaq -0x80(%rbp), %rdi
addq $0xc, %rdi
callq *%rax
movq 0x2ea6a(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
movl $0x1, %esi
callq *%rax
cmpl $0x0, -0x90(%rbp)
je 0x53c22
movl $0x3, %edi
movq 0x2ea3f(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movl $0x3, %edi
movq 0x2ea2d(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x2ea20(%rip), %rax     # 0x82600
movq 0xf0(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq 0x2ea0c(%rip), %rax     # 0x82600
movq 0xf0(%rax), %rax
leaq -0x80(%rbp), %rdi
addq $0xc, %rdi
callq *%rax
movq 0x2e9f4(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
leaq -0x80(%rbp), %rdi
addq $0xc, %rdi
movl $0x1, %esi
callq *%rax
movq -0x8(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x53c43
movq -0x8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
addq $0xc, %rsi
movl $0x2, %edx
callq 0x19080
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax)