// File: /workspace/github_c_makefile_star2_O1/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 0x2efbc
xorl %ebp, %ebp
movq 0x3a7ec(%rip), %r15     # 0x69600
callq 0x18350
testq %rax, %rax
je 0x2eebc
movq %rax, %r14
movq 0x150(%rax), %rax
movq %rax, 0x150(%rbx)
testb $0x1, 0x140(%r14)
je 0x2eedc
testb $0x1, %bpl
jne 0x2efc7
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 0x2ee14
jmp 0x2efbc
movq 0x8(%r15), %rcx
movq 0x150(%rbx), %rsi
leaq 0x27e62(%rip), %rdi     # 0x56d30
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 0x2ef2f
movl 0x368(%rbx), %edx
testl %edx, %edx
je 0x2ef26
movss 0x25019(%rip), %xmm0    # 0x53f28
movss 0x24ff5(%rip), %xmm1    # 0x53f0c
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl $0xa, %esi
callq *0x20(%r15)
movl 0x36c(%rbx), %eax
movl %eax, 0x4c(%rbx)
movss 0x4(%r14), %xmm0
subss 0xcc(%rbx), %xmm0
leaq 0xc(%rsp), %rsi
movss %xmm0, (%rsi)
movss 0x8(%r14), %xmm1
subss 0xd0(%rbx), %xmm1
movss %xmm1, 0x4(%rsi)
movss 0xc(%r14), %xmm2
subss 0xd4(%rbx), %xmm2
movss %xmm2, 0x8(%rsi)
movl $0x0, 0x388(%rbx)
movss 0x4(%rbx), %xmm3
movss %xmm3, 0x338(%rbx)
movq 0x8(%rbx), %rax
movq %rax, 0x33c(%rbx)
movss %xmm0, 0x350(%rbx)
movss %xmm1, 0x354(%rbx)
movss %xmm2, 0x358(%rbx)
movq 0x3b003(%rip), %rdx     # 0x69fb0
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 0x27d66(%rip), %rdi     # 0x56d4b
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