// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_func.c
// Function: SP_func_door
void SP_func_door (edict_t *ent)
{
	vec3_t	abs_movedir;

	if (ent->sounds != 1)
	{
		ent->moveinfo.sound_start = gi.soundindex  ("doors/dr1_strt.wav");
		ent->moveinfo.sound_middle = gi.soundindex  ("doors/dr1_mid.wav");
		ent->moveinfo.sound_end = gi.soundindex  ("doors/dr1_end.wav");
	}

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

	ent->blocked = door_blocked;
	ent->use = door_use;
	
	if (!ent->speed)
		ent->speed = 100;
	if (deathmatch->value)
		ent->speed *= 2;

	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 = 8;
	if (!ent->dmg)
		ent->dmg = 2;

	// calculate second position
	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]);
	ent->moveinfo.distance = abs_movedir[0] * ent->size[0] + abs_movedir[1] * ent->size[1] + abs_movedir[2] * ent->size[2] - st.lip;
	VectorMA (ent->pos1, ent->moveinfo.distance, ent->movedir, ent->pos2);

	// if it starts open, switch the positions
	if (ent->spawnflags & DOOR_START_OPEN)
	{
		VectorCopy (ent->pos2, ent->s.origin);
		VectorCopy (ent->pos1, ent->pos2);
		VectorCopy (ent->s.origin, ent->pos1);
	}

	ent->moveinfo.state = STATE_BOTTOM;

	if (ent->health)
	{
		ent->takedamage = DAMAGE_YES;
		ent->die = door_killed;
		ent->max_health = ent->health;
	}
	else if (ent->targetname && ent->message)
	{
		gi.soundindex ("misc/talk.wav");
		ent->touch = door_touch;
	}
	
	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);

	if (ent->spawnflags & 16)
		ent->s.effects |= EF_ANIM_ALL;
	if (ent->spawnflags & 64)
		ent->s.effects |= EF_ANIM_ALLFAST;

	// to simplify logic elsewhere, make non-teamed doors into a team of one
	if (!ent->team)
		ent->teammaster = ent;

	gi.linkentity (ent);

	ent->nextthink = level.time + FRAMETIME;
	if (ent->health || ent->targetname)
		ent->think = Think_CalcMoveSpeed;
	else
		ent->think = Think_SpawnDoorTrigger;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x1, 0x28c(%rdi)
je 0x2b726
movq 0x3af0d(%rip), %r14     # 0x66600
leaq 0x26684(%rip), %rdi     # 0x51d7e
callq *0x48(%r14)
movl %eax, 0x368(%rbx)
leaq 0x26686(%rip), %rdi     # 0x51d91
callq *0x48(%r14)
movl %eax, 0x36c(%rbx)
leaq 0x26687(%rip), %rdi     # 0x51da3
callq *0x48(%r14)
movl %eax, 0x370(%rbx)
leaq 0x10(%rbx), %rdi
leaq 0x19c(%rbx), %r14
movq %r14, %rsi
callq 0x197f0
movl $0x2, 0x118(%rbx)
movl $0x3, 0x108(%rbx)
movq 0x3aeac(%rip), %r15     # 0x66600
movq 0x120(%rbx), %rsi
movq %rbx, %rdi
callq *0x58(%r15)
movq 0x3ad07(%rip), %rax     # 0x66470
movq %rax, 0x218(%rbx)
movq 0x3b249(%rip), %rax     # 0x669c0
movq %rax, 0x228(%rbx)
movss 0x190(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x2b7a2
jp 0x2b7a2
movl $0x42c80000, 0x190(%rbx) # imm = 0x42C80000
movss 0x2648a(%rip), %xmm0    # 0x51c2c
movq 0x3b717(%rip), %rax     # 0x66ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm2
ucomiss %xmm1, %xmm2
jne 0x2b7b8
jnp 0x2b7c4
addss %xmm0, %xmm0
movss %xmm0, 0x190(%rbx)
movss 0x194(%rbx), %xmm2
ucomiss %xmm1, %xmm2
jne 0x2b7db
jp 0x2b7db
movss %xmm0, 0x194(%rbx)
movss 0x198(%rbx), %xmm2
ucomiss %xmm1, %xmm2
jne 0x2b7f2
jp 0x2b7f2
movss %xmm0, 0x198(%rbx)
movss 0x2f8(%rbx), %xmm0
ucomiss %xmm1, %xmm0
jne 0x2b80b
jp 0x2b80b
movl $0x40400000, 0x2f8(%rbx) # imm = 0x40400000
movq 0x3ae56(%rip), %rcx     # 0x66668
movl 0x20(%rcx), %eax
testl %eax, %eax
jne 0x2b823
movl $0x8, 0x20(%rcx)
pushq $0x8
popq %rax
cmpl $0x0, 0x280(%rbx)
jne 0x2b836
movl $0x2, 0x280(%rbx)
leaq 0x1a8(%rbx), %rdi
movsd 0x4(%rbx), %xmm0
movsd %xmm0, 0x1a8(%rbx)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x1b0(%rbx)
movss 0x19c(%rbx), %xmm1
movaps 0x236da(%rip), %xmm2    # 0x4ef40
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
addss %xmm3, %xmm1
cvtsi2ss %eax, %xmm2
addss %xmm1, %xmm0
subss %xmm2, %xmm0
movss %xmm0, 0x380(%rbx)
leaq 0x1b4(%rbx), %rdx
movq %r14, %rsi
callq 0x19940
movl 0x140(%rbx), %eax
testb $0x1, %al
je 0x2b903
movsd 0x1b4(%rbx), %xmm0
movsd %xmm0, 0x4(%rbx)
movss 0x1bc(%rbx), %xmm1
movss %xmm1, 0xc(%rbx)
movss 0x1a8(%rbx), %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movhps 0x1ac(%rbx), %xmm1      # xmm1 = xmm1[0,1],mem[0,1]
movsd %xmm0, 0x1a8(%rbx)
movups %xmm1, 0x1b0(%rbx)
movl $0x1, 0x388(%rbx)
movl 0x254(%rbx), %ecx
testl %ecx, %ecx
je 0x2ba38
movl $0x1, 0x27c(%rbx)
movq 0x3aaac(%rip), %rdx     # 0x663d8
movq %rdx, 0x238(%rbx)
movl %ecx, 0x258(%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)
testb $0x10, %al
je 0x2b9c9
orb $0x10, 0x41(%rbx)
testb $0x40, %al
je 0x2b9d1
orb $0x20, 0x41(%rbx)
cmpq $0x0, 0x168(%rbx)
jne 0x2b9e2
movq %rbx, 0x2d0(%rbx)
movq %rbx, %rdi
callq *0x90(%r15)
movq 0x3b3ad(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
addss 0x23890(%rip), %xmm0    # 0x4f290
movss %xmm0, 0x200(%rbx)
cmpl $0x0, 0x254(%rbx)
jne 0x2ba24
cmpq $0x0, 0x158(%rbx)
jne 0x2ba24
movq 0x3b116(%rip), %rax     # 0x66b38
jmp 0x2ba2b
movq 0x3b3e5(%rip), %rax     # 0x66e10
movq %rax, 0x210(%rbx)
popq %rbx
popq %r14
popq %r15
retq
cmpq $0x0, 0x158(%rbx)
je 0x2b939
cmpq $0x0, 0x130(%rbx)
je 0x2b939
leaq 0x2635a(%rip), %rdi     # 0x51db5
callq *0x48(%r15)
movq 0x3b502(%rip), %rax     # 0x66f68
movq %rax, 0x220(%rbx)
movl 0x140(%rbx), %eax
jmp 0x2b939