// File: /workspace/github_c_makefile_star2_O3/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
movq 0x150(%rdi), %rdi
testq %rdi, %rdi
je 0x2ea94
xorl %ebp, %ebp
movq 0x39cfc(%rip), %r15     # 0x68600
callq 0x18350
testq %rax, %rax
je 0x2e9ac
movq %rax, %r14
movq 0x150(%rax), %rax
movq %rax, 0x150(%rbx)
testb $0x1, 0x140(%r14)
je 0x2e9cc
testb $0x1, %bpl
jne 0x2ea9f
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)
movq 0x150(%rbx), %rdi
movb $0x1, %bpl
testq %rdi, %rdi
jne 0x2e904
jmp 0x2ea94
movq 0x8(%r15), %rcx
movq 0x150(%rbx), %rsi
leaq 0x2746a(%rip), %rdi     # 0x55e28
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 0x2ea1f
movl 0x368(%rbx), %edx
testl %edx, %edx
je 0x2ea16
movss 0x24529(%rip), %xmm0    # 0x52f28
movss 0x24509(%rip), %xmm1    # 0x52f10
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl $0xa, %esi
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)
movl $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 0x3a52b(%rip), %rdx     # 0x68fb0
movq %rbx, %rdi
callq 0x18e70
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 0x190a0
leaq 0x27386(%rip), %rdi     # 0x55e43
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