// File: /workspace/github_c_makefile_star2_O3/QwazyWabbitWOS[P]lmctf60/g_func.c
// Function: SP_func_button
void SP_func_button (edict_t *ent)
{
	vec3_t	abs_movedir;
	float	dist;

	G_SetMovedir (ent->s.angles, ent->movedir);
	ent->movetype = MOVETYPE_STOP;
	ent->solid = SOLID_BSP;
	gi.setmodel (ent, ent->model);

	if (ent->sounds != 1)
		ent->moveinfo.sound_start = gi.soundindex ("switches/butn2.wav");
	
	if (!ent->speed)
		ent->speed = 40;
	if (!ent->accel)
		ent->accel = ent->speed;
	if (!ent->decel)
		ent->decel = ent->speed;

	if (!ent->wait)
		ent->wait = 3;
	if (!st.lip)
		st.lip = 4;

	VectorCopy (ent->s.origin, ent->pos1);
	abs_movedir[0] = fabs(ent->movedir[0]);
	abs_movedir[1] = fabs(ent->movedir[1]);
	abs_movedir[2] = fabs(ent->movedir[2]);
	dist = abs_movedir[0] * ent->size[0] + abs_movedir[1] * ent->size[1] + abs_movedir[2] * ent->size[2] - st.lip;
	VectorMA (ent->pos1, dist, ent->movedir, ent->pos2);

	ent->use = button_use;
	ent->s.effects |= EF_ANIM01;

	if (ent->health)
	{
		ent->max_health = ent->health;
		ent->die = button_killed;
		ent->takedamage = DAMAGE_YES;
	}
	else if (! ent->targetname)
		ent->touch = button_touch;

	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);

	gi.linkentity (ent);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
addq $0x10, %rdi
leaq 0x19c(%rbx), %r14
movq %r14, %rsi
callq 0x19630
movl $0x3, %eax
movl %eax, 0x118(%rbx)
movl %eax, 0x108(%rbx)
movq 0x3b334(%rip), %rax     # 0x68600
movq 0x120(%rbx), %rsi
movq %rbx, %rdi
movq %rax, %r15
callq *0x58(%rax)
cmpl $0x1, 0x28c(%rbx)
je 0x2d2f6
leaq 0x28a63(%rip), %rdi     # 0x55d4f
callq *0x48(%r15)
movl %eax, 0x368(%rbx)
movss 0x190(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x2d31a
jp 0x2d31a
movl $0x42200000, 0x190(%rbx) # imm = 0x42200000
movss 0x2892e(%rip), %xmm0    # 0x55c48
movss 0x194(%rbx), %xmm2
ucomiss %xmm1, %xmm2
jne 0x2d331
jp 0x2d331
movss %xmm0, 0x194(%rbx)
movss 0x198(%rbx), %xmm2
ucomiss %xmm1, %xmm2
jne 0x2d348
jp 0x2d348
movss %xmm0, 0x198(%rbx)
movss 0x2f8(%rbx), %xmm0
ucomiss %xmm1, %xmm0
jne 0x2d361
jp 0x2d361
movl $0x40400000, 0x2f8(%rbx) # imm = 0x40400000
movq 0x3b300(%rip), %rcx     # 0x68668
movl 0x20(%rcx), %eax
testl %eax, %eax
jne 0x2d37b
movl $0x4, 0x20(%rcx)
movl $0x4, %eax
movsd 0x4(%rbx), %xmm0
movsd %xmm0, 0x1a8(%rbx)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x1b0(%rbx)
movss 0x19c(%rbx), %xmm1
movaps 0x25b9c(%rip), %xmm2    # 0x52f40
andps %xmm2, %xmm1
movss 0x1a0(%rbx), %xmm3
andps %xmm2, %xmm3
movss 0x1a4(%rbx), %xmm0
andps %xmm2, %xmm0
mulss 0x100(%rbx), %xmm3
mulss 0xfc(%rbx), %xmm1
mulss 0x104(%rbx), %xmm0
leaq 0x1a8(%rbx), %rdi
xorps %xmm2, %xmm2
cvtsi2ss %eax, %xmm2
addss %xmm3, %xmm1
addss %xmm1, %xmm0
subss %xmm2, %xmm0
leaq 0x1b4(%rbx), %rdx
movq %r14, %rsi
callq 0x19760
movq 0x3affb(%rip), %rax     # 0x68400
movq %rax, 0x228(%rbx)
orb $0x4, 0x41(%rbx)
movl 0x254(%rbx), %eax
testl %eax, %eax
je 0x2d43a
movl %eax, 0x258(%rbx)
movq 0x3b629(%rip), %rax     # 0x68a50
movq %rax, 0x238(%rbx)
movl $0x1, 0x27c(%rbx)
jmp 0x2d452
cmpq $0x0, 0x158(%rbx)
jne 0x2d452
movq 0x3b965(%rip), %rax     # 0x68db0
movq %rax, 0x220(%rbx)
movl $0x1, 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)
movq %rbx, %rdi
movq %r15, %rax
popq %rbx
popq %r14
popq %r15
jmpq *0x90(%rax)