// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_func.c
// Function: SP_func_plat
void SP_func_plat (edict_t *ent)
{
	VectorClear (ent->s.angles);
	ent->solid = SOLID_BSP;
	ent->movetype = MOVETYPE_PUSH;

	gi.setmodel (ent, ent->model);

	ent->blocked = plat_blocked;

	if (!ent->speed)
		ent->speed = 20;
	else
		ent->speed *= 0.1f;

	if (!ent->accel)
		ent->accel = 5;
	else
		ent->accel *= 0.1f;

	if (!ent->decel)
		ent->decel = 5;
	else
		ent->decel *= 0.1f;

	if (!ent->dmg)
		ent->dmg = 2;

	if (!st.lip)
		st.lip = 8;

	// pos1 is the top position, pos2 is the bottom
	VectorCopy (ent->s.origin, ent->pos1);
	VectorCopy (ent->s.origin, ent->pos2);
	if (st.height)
		ent->pos2[2] -= st.height;
	else
		ent->pos2[2] -= (ent->maxs[2] - ent->mins[2]) - st.lip;

	ent->use = Use_Plat;

	plat_spawn_inside_trigger (ent);	// the "start moving" trigger	

	if (ent->targetname)
	{
		ent->moveinfo.state = STATE_UP;
	}
	else
	{
		VectorCopy (ent->pos2, ent->s.origin);
		gi.linkentity (ent);
		ent->moveinfo.state = STATE_BOTTOM;
	}

	ent->moveinfo.speed = ent->speed;
	ent->moveinfo.accel = ent->accel;
	ent->moveinfo.decel = ent->decel;
	ent->moveinfo.wait = ent->wait;
	VectorCopy (ent->pos1, ent->moveinfo.start_origin);
	VectorCopy (ent->s.angles, ent->moveinfo.start_angles);
	VectorCopy (ent->pos2, ent->moveinfo.end_origin);
	VectorCopy (ent->s.angles, ent->moveinfo.end_angles);

	ent->moveinfo.sound_start = gi.soundindex ("plats/pt1_strt.wav");
	ent->moveinfo.sound_middle = gi.soundindex ("plats/pt1_mid.wav");
	ent->moveinfo.sound_end = gi.soundindex ("plats/pt1_end.wav");
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
andl $0x0, 0x18(%rdi)
andq $0x0, 0x10(%rdi)
movl $0x3, 0x108(%rdi)
movl $0x2, 0x118(%rdi)
movq 0x3bf22(%rip), %r14     # 0x66600
movq 0x120(%rdi), %rsi
callq *0x58(%r14)
movq 0x3bfd8(%rip), %rax     # 0x666c8
movq %rax, 0x218(%rbx)
movsd 0x190(%rbx), %xmm0
xorps %xmm1, %xmm1
cmpneqps %xmm0, %xmm1
mulps 0x27573(%rip), %xmm0    # 0x51c80
andps %xmm1, %xmm0
andnps 0x27579(%rip), %xmm1    # 0x51c90
orps %xmm0, %xmm1
movlps %xmm1, 0x190(%rbx)
movss 0x198(%rbx), %xmm0
movss 0x24b5f(%rip), %xmm1    # 0x4f290
mulss %xmm0, %xmm1
xorps %xmm2, %xmm2
cmpneqss %xmm0, %xmm2
andps %xmm2, %xmm1
movss 0x247bc(%rip), %xmm0    # 0x4ef04
andnps %xmm0, %xmm2
orps %xmm1, %xmm2
movss %xmm2, 0x198(%rbx)
cmpl $0x0, 0x280(%rbx)
jne 0x2a769
movl $0x2, 0x280(%rbx)
movq 0x3bef8(%rip), %rcx     # 0x66668
movl 0x20(%rcx), %eax
testl %eax, %eax
jne 0x2a781
movl $0x8, 0x20(%rcx)
pushq $0x8
popq %rax
movsd 0x8(%rbx), %xmm0
movss 0x4(%rbx), %xmm1
shufps $0x40, %xmm0, %xmm1     # xmm1 = xmm1[0,0],xmm0[0,1]
shufps $0x78, %xmm1, %xmm1     # xmm1 = xmm1[0,2,3,1]
movups %xmm1, 0x1a8(%rbx)
movss %xmm0, 0x1b8(%rbx)
movl 0x28(%rcx), %ecx
testl %ecx, %ecx
je 0x2a7af
cvtsi2ss %ecx, %xmm1
jmp 0x2a7c7
movss 0xe0(%rbx), %xmm1
subss 0xd4(%rbx), %xmm1
cvtsi2ss %eax, %xmm2
subss %xmm2, %xmm1
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
subss %xmm1, %xmm0
movss %xmm0, 0x1bc(%rbx)
movq 0x3c46a(%rip), %rax     # 0x66c48
movq %rax, 0x228(%rbx)
movq %rbx, %rdi
callq 0x18840
cmpq $0x0, 0x158(%rbx)
je 0x2a7fb
pushq $0x2
jmp 0x2a821
movsd 0x1b4(%rbx), %xmm0
movsd %xmm0, 0x4(%rbx)
movss 0x1bc(%rbx), %xmm0
movss %xmm0, 0xc(%rbx)
movq %rbx, %rdi
callq *0x90(%r14)
pushq $0x1
popq %rax
movl %eax, 0x388(%rbx)
movsd 0x190(%rbx), %xmm0
shufps $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movlps %xmm0, 0x374(%rbx)
movss 0x198(%rbx), %xmm0
movss %xmm0, 0x37c(%rbx)
movss 0x2f8(%rbx), %xmm0
movss %xmm0, 0x384(%rbx)
movsd 0x1ac(%rbx), %xmm0
movss 0x1a8(%rbx), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movss 0x10(%rbx), %xmm2
movaps %xmm2, %xmm3
shufps $0xd4, %xmm0, %xmm3     # xmm3 = xmm3[0,1],xmm0[1,3]
shufps $0x28, %xmm3, %xmm1     # xmm1 = xmm1[0,2],xmm3[2,0]
movups %xmm1, 0x338(%rbx)
movsd 0x14(%rbx), %xmm0
movaps %xmm0, %xmm1
movhps 0x1b4(%rbx), %xmm1      # xmm1 = xmm1[0,1],mem[0,1]
movups %xmm1, 0x348(%rbx)
movss 0x1bc(%rbx), %xmm1
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movups %xmm1, 0x358(%rbx)
leaq 0x27441(%rip), %rdi     # 0x51cf8
callq *0x48(%r14)
movl %eax, 0x368(%rbx)
leaq 0x27443(%rip), %rdi     # 0x51d0b
callq *0x48(%r14)
movl %eax, 0x36c(%rbx)
leaq 0x27444(%rip), %rdi     # 0x51d1d
callq *0x48(%r14)
movl %eax, 0x370(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq