// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_func.c
// Function: train_next
void train_next (edict_t *self)
{
	edict_t		*ent;
	vec3_t		dest;
	qboolean	first;

	first = true;
again:
	if (!self->target)
	{
//		gi.dprintf ("train_next: no next target\n");
		return;
	}

	ent = G_PickTarget (self->target);
	if (!ent)
	{
		gi.dprintf ("train_next: bad target %s\n", self->target);
		return;
	}

	self->target = ent->target;

	// check for a teleport path_corner
	if (ent->spawnflags & 1)
	{
		if (!first)
		{
			gi.dprintf ("connected teleport path_corners, see %s at %s\n", ent->classname, vtos(ent->s.origin));
			return;
		}
		first = false;
		VectorSubtract (ent->s.origin, self->mins, self->s.origin);
		VectorCopy (self->s.origin, self->s.old_origin);
		self->s.event = EV_OTHER_TELEPORT;
		gi.linkentity (self);
		goto again;
	}

	self->moveinfo.wait = ent->wait;
	self->target_ent = ent;

	if (!(self->flags & FL_TEAMSLAVE))
	{
		if (self->moveinfo.sound_start)
			gi.sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self->moveinfo.sound_start, 1, ATTN_STATIC, 0);
		self->s.sound = self->moveinfo.sound_middle;
	}

	VectorSubtract (ent->s.origin, self->mins, dest);
	self->moveinfo.state = STATE_TOP;
	VectorCopy (self->s.origin, self->moveinfo.start_origin);
	VectorCopy (dest, self->moveinfo.end_origin);
	Move_Calc (self, dest, train_wait);
	self->spawnflags |= TRAIN_START_ON;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
xorl %ebp, %ebp
movq 0x3a33f(%rip), %r15     # 0x66600
movq 0x150(%rbx), %rdi
testq %rdi, %rdi
je 0x2c44c
callq 0x18380
testq %rax, %rax
je 0x2c369
movq %rax, %r14
movq 0x150(%rax), %rax
movq %rax, 0x150(%rbx)
testb $0x1, 0x140(%r14)
je 0x2c389
testb $0x1, %bpl
jne 0x2c457
movss 0x4(%r14), %xmm0
subss 0xcc(%rbx), %xmm0
movss %xmm0, 0x4(%rbx)
movss 0x8(%r14), %xmm1
subss 0xd0(%rbx), %xmm1
movss %xmm1, 0x8(%rbx)
movss 0xc(%r14), %xmm2
subss 0xd4(%rbx), %xmm2
movss %xmm2, 0xc(%rbx)
movss %xmm0, 0x1c(%rbx)
movss %xmm1, 0x20(%rbx)
movss %xmm2, 0x24(%rbx)
movl $0x7, 0x50(%rbx)
movq %rbx, %rdi
callq *0x90(%r15)
movb $0x1, %bpl
jmp 0x2c2c1
movq 0x8(%r15), %rcx
movq 0x150(%rbx), %rsi
leaq 0x25a8d(%rip), %rdi     # 0x51e08
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
movss 0x2f8(%r14), %xmm0
movss %xmm0, 0x384(%rbx)
movq %r14, 0x188(%rbx)
testb $0x4, 0x11d(%rbx)
jne 0x2c3da
movl 0x368(%rbx), %edx
testl %edx, %edx
je 0x2c3d1
pushq $0xa
popq %rsi
movss 0x22b69(%rip), %xmm0    # 0x4ef28
movss 0x22b45(%rip), %xmm1    # 0x4ef0c
xorps %xmm2, %xmm2
movq %rbx, %rdi
callq *0x20(%r15)
movl 0x36c(%rbx), %eax
movl %eax, 0x4c(%rbx)
movsd 0x4(%r14), %xmm0
movsd 0xcc(%rbx), %xmm1
subps %xmm1, %xmm0
leaq 0x8(%rsp), %rsi
movlps %xmm0, (%rsi)
movss 0xc(%r14), %xmm1
subss 0xd4(%rbx), %xmm1
movss %xmm1, 0x8(%rsi)
andl $0x0, 0x388(%rbx)
movsd 0x4(%rbx), %xmm2
movsd %xmm2, 0x338(%rbx)
movss 0xc(%rbx), %xmm2
movss %xmm2, 0x340(%rbx)
movlps %xmm0, 0x350(%rbx)
movss %xmm1, 0x358(%rbx)
movq 0x3ab73(%rip), %rdx     # 0x66fb0
movq %rbx, %rdi
callq 0x18f90
orb $0x1, 0x140(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r15), %r15
movq 0x138(%r14), %rbx
addq $0x4, %r14
movq %r14, %rdi
callq 0x19200
leaq 0x259ae(%rip), %rdi     # 0x51e23
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
movq %r15, %rcx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rcx